MCP (Model Context Protocol) lets you extend agent-code with tools and resources from external servers. Any MCP-compatible server can be connected.
Configuration
Add servers to your config file:
# .agent/settings.toml or ~/.config/agent-code/config.toml
[mcp_servers.filesystem]
command = "npx"
args = ["-y", "@modelcontextprotocol/server-filesystem", "/home/user/docs"]
[mcp_servers.github]
command = "npx"
args = ["-y", "@modelcontextprotocol/server-github"]
env = { GITHUB_TOKEN = "ghp_..." }
[mcp_servers.postgres]
command = "npx"
args = ["-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost/mydb"]
Transports
Stdio (default)
The server runs as a subprocess, communicating via stdin/stdout JSON-RPC:
[mcp_servers.myserver]
command = "path/to/server"
args = ["--flag", "value"]
env = { API_KEY = "..." }
SSE (HTTP)
For servers that expose an HTTP endpoint:
[mcp_servers.remote]
url = "http://localhost:8080"
How it works
- At startup, agent-code connects to each configured server
- The
initializehandshake negotiates capabilities - Tools are discovered via
tools/listand registered asmcp__server__toolin the agent's tool pool - When the LLM calls an MCP tool, the request is proxied to the server via
tools/call - Resources can be browsed with
ListMcpResourcesand read withReadMcpResource
Commands
> /mcp
2 MCP server(s) configured:
filesystem (stdio)
github (stdio)
Popular MCP servers
| Server | What it provides |
|---|---|
@modelcontextprotocol/server-filesystem | File system access with path restrictions |
@modelcontextprotocol/server-github | GitHub API (issues, PRs, repos) |
@modelcontextprotocol/server-postgres | PostgreSQL query execution |
@modelcontextprotocol/server-sqlite | SQLite database access |
@modelcontextprotocol/server-slack | Slack messaging |
Find more at modelcontextprotocol.io.