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

  1. At startup, agent-code connects to each configured server
  2. The initialize handshake negotiates capabilities
  3. Tools are discovered via tools/list and registered as mcp__server__tool in the agent's tool pool
  4. When the LLM calls an MCP tool, the request is proxied to the server via tools/call
  5. Resources can be browsed with ListMcpResources and read with ReadMcpResource

Commands

> /mcp
2 MCP server(s) configured:
  filesystem (stdio)
  github (stdio)
ServerWhat it provides
@modelcontextprotocol/server-filesystemFile system access with path restrictions
@modelcontextprotocol/server-githubGitHub API (issues, PRs, repos)
@modelcontextprotocol/server-postgresPostgreSQL query execution
@modelcontextprotocol/server-sqliteSQLite database access
@modelcontextprotocol/server-slackSlack messaging

Find more at modelcontextprotocol.io.