Skip to content

MCP Servers

Codive supports the Model Context Protocol (MCP), allowing you to connect external tool providers and extend the agent’s capabilities beyond built-in tools.

MCP (Model Context Protocol) is a standardized protocol that enables AI agents to communicate with external tool servers. With MCP, you can:

  • Add custom tools from third-party servers
  • Access external services like filesystems, databases, and APIs
  • Use community-built servers from the MCP ecosystem
  • Build your own tool servers in any language

Codive implements MCP protocol version 2024-11-05 using JSON-RPC 2.0.

MCP servers are configured in your codive.toml or ~/.config/codive/config.toml file.

[[mcp.servers]]
name = "server-name"
transport = "stdio" # or "http"
# ... transport-specific options

Each server needs:

  • name - Unique identifier (used as tool prefix)
  • transport - Connection method: stdio or http

Spawns the MCP server as a child process and communicates via stdin/stdout. Best for local servers.

[[mcp.servers]]
name = "filesystem"
transport = "stdio"
command = "npx"
args = ["-y", "@anthropic/mcp-server-filesystem", "/home/user/projects"]

Options:

OptionDescription
commandExecutable to run
argsCommand-line arguments (array)
envEnvironment variables (optional)

Connects to a remote MCP server via HTTP. Best for cloud-hosted or shared servers.

[[mcp.servers]]
name = "remote-api"
transport = "http"
url = "https://mcp.example.com/api"
headers = { Authorization = "Bearer ${API_TOKEN}" }

Options:

OptionDescription
urlServer endpoint URL
headersHTTP headers (optional)

You can use environment variables in your configuration with ${VAR} syntax:

[[mcp.servers]]
name = "github"
transport = "stdio"
command = "npx"
args = ["-y", "@anthropic/mcp-server-github"]
env = { GITHUB_TOKEN = "${GITHUB_TOKEN}" }
[[mcp.servers]]
name = "api"
transport = "http"
url = "https://api.example.com/mcp"
headers = { Authorization = "Bearer ${API_KEY}" }
[[mcp.servers]]
name = "fs"
transport = "stdio"
command = "npx"
args = ["-y", "@anthropic/mcp-server-filesystem", "/path/to/directory"]

This exposes tools like fs_read_file, fs_write_file, fs_list_directory.

[[mcp.servers]]
name = "github"
transport = "stdio"
command = "npx"
args = ["-y", "@anthropic/mcp-server-github"]
env = { GITHUB_TOKEN = "${GITHUB_TOKEN}" }

Provides tools for repository operations, issues, pull requests, etc.

[[mcp.servers]]
name = "postgres"
transport = "stdio"
command = "npx"
args = ["-y", "@anthropic/mcp-server-postgres"]
env = { DATABASE_URL = "${DATABASE_URL}" }

You can configure multiple servers—they all run simultaneously:

[[mcp.servers]]
name = "filesystem"
transport = "stdio"
command = "npx"
args = ["-y", "@anthropic/mcp-server-filesystem", "."]
[[mcp.servers]]
name = "github"
transport = "stdio"
command = "npx"
args = ["-y", "@anthropic/mcp-server-github"]
env = { GITHUB_TOKEN = "${GITHUB_TOKEN}" }
[[mcp.servers]]
name = "slack"
transport = "stdio"
command = "npx"
args = ["-y", "@anthropic/mcp-server-slack"]
env = { SLACK_TOKEN = "${SLACK_TOKEN}" }

When Codive connects to MCP servers, it automatically discovers and registers their tools. Tools are prefixed with the server name to avoid conflicts:

Server NameMCP ToolCodive Tool Name
filesystemread_filefilesystem_read_file
githubcreate_issuegithub_create_issue
slacksend_messageslack_send_message

The agent uses these tools transparently—no special syntax required.

  1. Install an MCP server

    Most MCP servers are npm packages:

    Terminal window
    npm install -g @anthropic/mcp-server-filesystem

    Or use npx to run without installing (shown in examples above).

  2. Add configuration

    Add the server to your codive.toml:

    [[mcp.servers]]
    name = "filesystem"
    transport = "stdio"
    command = "mcp-server-filesystem"
    args = ["/home/user/projects"]
  3. Start Codive

    Codive automatically connects to configured servers on startup:

    Terminal window
    codive
  4. Verify connection

    The agent will have access to the server’s tools. You can ask:

    > What tools do you have available?

Codive handles MCP errors gracefully:

  • Connection failures don’t prevent startup—other servers still connect
  • Timeout protection (30 seconds per request)
  • Automatic cleanup when Codive exits

If a server fails to connect, you’ll see a warning but can continue using other tools.

You can build your own MCP servers in any language. The server needs to:

  1. Accept JSON-RPC 2.0 messages via stdin (stdio) or HTTP POST (http)
  2. Implement initialize, tools/list, and tools/call methods
  3. Return properly formatted responses
const readline = require('readline');
const tools = [
{
name: 'hello',
description: 'Says hello',
inputSchema: {
type: 'object',
properties: {
name: { type: 'string', description: 'Name to greet' }
},
required: ['name']
}
}
];
const rl = readline.createInterface({ input: process.stdin });
rl.on('line', (line) => {
const request = JSON.parse(line);
let result;
if (request.method === 'initialize') {
result = { protocolVersion: '2024-11-05', capabilities: { tools: {} } };
} else if (request.method === 'tools/list') {
result = { tools };
} else if (request.method === 'tools/call') {
const name = request.params.arguments.name;
result = { content: [{ type: 'text', text: `Hello, ${name}!` }] };
}
console.log(JSON.stringify({ jsonrpc: '2.0', id: request.id, result }));
});

The MCP ecosystem includes servers for:

  • Filesystem - File operations
  • GitHub - Repository, issues, PRs
  • Slack - Messaging
  • PostgreSQL - Database queries
  • Puppeteer - Browser automation
  • Google Drive - File storage
  • And many more…

Check github.com/anthropics/mcp-servers for the official server collection.

  1. Verify the command works standalone:

    Terminal window
    npx -y @anthropic/mcp-server-filesystem /tmp
  2. Check environment variables are set:

    Terminal window
    echo $GITHUB_TOKEN
  3. Look at Codive’s stderr output for connection errors

  1. Ensure the server name is unique
  2. Check the server implements tools/list correctly
  3. Restart Codive after config changes
  • MCP requests timeout after 30 seconds
  • For slow operations, consider breaking them into smaller steps
  • Check network connectivity for HTTP transport