Adding MCP Backends
Adding MCP Backends
Section titled “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.
Overview
Section titled “Overview”Agent → ?t github → Gateway → MCP Backend (GitHub server) → Tool ResultsAgentCTX doesn’t run tools directly. It delegates to MCP-compatible servers and manages scoping, authorization, and caching.
Step 1: Register a Backend
Section titled “Step 1: Register a Backend”actx add github \ --command "npx -y @modelcontextprotocol/server-github" \ --roles "code,issues" \ --transport stdioThis adds an entry to .context/actx.yaml:
backends: - id: github cmd: "npx -y @modelcontextprotocol/server-github" roles: - code - issues transport: stdioStep 2: Configure Roles
Section titled “Step 2: Configure Roles”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 agentsStep 3: Choose a Transport
Section titled “Step 3: Choose a Transport”| Transport | When to Use |
|---|---|
stdio | Local MCP servers (npx, python scripts) |
sse | Remote servers with HTTP endpoints |
http | REST-based MCP adapters |
# Local server via stdioactx add filesystem --command "npx -y @modelcontextprotocol/server-filesystem ." --transport stdio
# Remote server via SSEactx add remote-api --command "node api-server.js" --transport sseStep 4: Verify
Section titled “Step 4: Verify”Start the gateway and search for tools:
actx start --transport sse --port 3100
# In another terminalactx query '?t github'You should see the tools from your registered backend in the results.
Lazy Spawning
Section titled “Lazy Spawning”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: falseTool Namespacing
Section titled “Tool Namespacing”All tools are automatically namespaced under their backend ID:
| Backend ID | MCP Tool Name | CTX Name |
|---|---|---|
github | issues.create | github.issues.create |
filesystem | read_file | filesystem.read_file |
godot | assets.decimate_mesh | godot.assets.decimate_mesh |
Popular MCP Servers
Section titled “Popular MCP Servers”| Server | Install Command | Roles |
|---|---|---|
| GitHub | npx -y @modelcontextprotocol/server-github | code, issues |
| Filesystem | npx -y @modelcontextprotocol/server-filesystem . | files |
| PostgreSQL | npx -y @modelcontextprotocol/server-postgres | database |
| Puppeteer | npx -y @modelcontextprotocol/server-puppeteer | browser |
See Also
Section titled “See Also”- actx add — CLI reference
- Gateway & Routing — how backends are managed