MCP Servers
MCP Servers
Section titled “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.
What is MCP?
Section titled “What is MCP?”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.
Configuration
Section titled “Configuration”MCP servers are configured in your codive.toml or ~/.config/codive/config.toml file.
Basic Structure
Section titled “Basic Structure”[[mcp.servers]]name = "server-name"transport = "stdio" # or "http"# ... transport-specific optionsEach server needs:
- name - Unique identifier (used as tool prefix)
- transport - Connection method:
stdioorhttp
Transport Types
Section titled “Transport Types”Stdio Transport
Section titled “Stdio Transport”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:
| Option | Description |
|---|---|
command | Executable to run |
args | Command-line arguments (array) |
env | Environment variables (optional) |
HTTP Transport
Section titled “HTTP Transport”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:
| Option | Description |
|---|---|
url | Server endpoint URL |
headers | HTTP headers (optional) |
Environment Variables
Section titled “Environment Variables”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}" }Example Configurations
Section titled “Example Configurations”Filesystem Access
Section titled “Filesystem Access”[[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.
GitHub Integration
Section titled “GitHub Integration”[[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.
Database Access
Section titled “Database Access”[[mcp.servers]]name = "postgres"transport = "stdio"command = "npx"args = ["-y", "@anthropic/mcp-server-postgres"]env = { DATABASE_URL = "${DATABASE_URL}" }Multiple Servers
Section titled “Multiple Servers”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}" }How Tools are Exposed
Section titled “How Tools are Exposed”When Codive connects to MCP servers, it automatically discovers and registers their tools. Tools are prefixed with the server name to avoid conflicts:
| Server Name | MCP Tool | Codive Tool Name |
|---|---|---|
filesystem | read_file | filesystem_read_file |
github | create_issue | github_create_issue |
slack | send_message | slack_send_message |
The agent uses these tools transparently—no special syntax required.
Setting Up MCP
Section titled “Setting Up MCP”-
Install an MCP server
Most MCP servers are npm packages:
Terminal window npm install -g @anthropic/mcp-server-filesystemOr use
npxto run without installing (shown in examples above). -
Add configuration
Add the server to your
codive.toml:[[mcp.servers]]name = "filesystem"transport = "stdio"command = "mcp-server-filesystem"args = ["/home/user/projects"] -
Start Codive
Codive automatically connects to configured servers on startup:
Terminal window codive -
Verify connection
The agent will have access to the server’s tools. You can ask:
> What tools do you have available?
Error Handling
Section titled “Error Handling”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.
Building Custom MCP Servers
Section titled “Building Custom MCP Servers”You can build your own MCP servers in any language. The server needs to:
- Accept JSON-RPC 2.0 messages via stdin (stdio) or HTTP POST (http)
- Implement
initialize,tools/list, andtools/callmethods - Return properly formatted responses
Minimal Example (Node.js)
Section titled “Minimal Example (Node.js)”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 }));});Available MCP Servers
Section titled “Available MCP Servers”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.
Troubleshooting
Section titled “Troubleshooting”Server won’t connect
Section titled “Server won’t connect”-
Verify the command works standalone:
Terminal window npx -y @anthropic/mcp-server-filesystem /tmp -
Check environment variables are set:
Terminal window echo $GITHUB_TOKEN -
Look at Codive’s stderr output for connection errors
Tools not appearing
Section titled “Tools not appearing”- Ensure the server name is unique
- Check the server implements
tools/listcorrectly - Restart Codive after config changes
Timeout errors
Section titled “Timeout errors”- MCP requests timeout after 30 seconds
- For slow operations, consider breaking them into smaller steps
- Check network connectivity for HTTP transport
Next Steps
Section titled “Next Steps”- Adding Tools - Create built-in Rust tools
- Custom Providers - Add new LLM providers