7. Tools, Tool Calling and MCP
7.1 Why tools matter
An LLM alone can generate text.
An agent with tools can interact with an environment.
Model
|
+--> Read files
+--> Search files
+--> Edit files
+--> Run commands
+--> Run tests
+--> Search web
+--> Use external integrations
7.2 Tool calling
Conceptually:
Model
|
| "I need to run tests"
v
Tool request
|
v
Runtime executes tool
|
v
Tool result
|
v
Model continues
The model does not magically execute a command. The surrounding application/runtime controls tool execution.
7.3 MCP
MCP stands for Model Context Protocol.
It is a protocol used to connect AI applications with external tools and data sources.
Conceptually:
OpenCode
|
v
MCP server
|
+--> GitHub
+--> Database
+--> Internal API
+--> Documentation
The exact MCP integration depends on the server and OpenCode configuration.
7.4 Tool safety
Tools can be powerful.
A tool that can:
delete files
push code
modify infrastructure
should not necessarily be unrestricted.
Use least privilege and approval gates.
Exercise
For each capability below, classify it as:
- Allow
- Ask
- Deny
Read source
Run tests
Git status
Git diff
Git commit
Git push
Delete production data
Explain your choices.