Skip to content

Adding MCP Backends

This guide walks through connecting MCP (Model Context Protocol) servers to AgentCTX as tool backends. Once connected, agents can discover and call tools through the CTX language.

Agent → ?t github → Gateway → MCP Backend (GitHub server) → Tool Results

AgentCTX doesn’t run tools directly. It delegates to MCP-compatible servers and manages scoping, authorization, and caching.

Terminal window
actx add github \
--command "npx -y @modelcontextprotocol/server-github" \
--roles "code,issues" \
--transport stdio

This adds an entry to .context/actx.yaml:

backends:
- id: github
cmd: "npx -y @modelcontextprotocol/server-github"
roles:
- code
- issues
transport: stdio

Roles control which agents can see which tools. An agent must have a matching role to access a backend’s tools.

backends:
- id: admin-tools
roles: [admin] # Only admin agents
- id: dev-tools
roles: [code, issues] # Dev and PM agents
- id: public-tools
roles: [default] # All agents
TransportWhen to Use
stdioLocal MCP servers (npx, python scripts)
sseRemote servers with HTTP endpoints
httpREST-based MCP adapters
Terminal window
# Local server via stdio
actx add filesystem --command "npx -y @modelcontextprotocol/server-filesystem ." --transport stdio
# Remote server via SSE
actx add remote-api --command "node api-server.js" --transport sse

Start the gateway and search for tools:

Terminal window
actx start --transport sse --port 3100
# In another terminal
actx query '?t github'

You should see the tools from your registered backend in the results.

Backends are lazy-spawned by default:

  • The MCP server process doesn’t start until the first tool query
  • This keeps gateway startup fast
  • Unused backends consume zero resources

To change this behavior, set lazy: false in actx.yaml:

backends:
- id: always-on
cmd: "node critical-server.js"
roles: [monitoring]
transport: stdio
lazy: false

All tools are automatically namespaced under their backend ID:

Backend IDMCP Tool NameCTX Name
githubissues.creategithub.issues.create
filesystemread_filefilesystem.read_file
godotassets.decimate_meshgodot.assets.decimate_mesh
ServerInstall CommandRoles
GitHubnpx -y @modelcontextprotocol/server-githubcode, issues
Filesystemnpx -y @modelcontextprotocol/server-filesystem .files
PostgreSQLnpx -y @modelcontextprotocol/server-postgresdatabase
Puppeteernpx -y @modelcontextprotocol/server-puppeteerbrowser