Skip to main content
PicoClaw supports the Model Context Protocol (MCP), allowing you to extend the agent with external tools and services. MCP provides a standardized way to connect AI assistants with external data sources and tools.

Overview

MCP enables PicoClaw to:
  • Connect to external MCP servers
  • Use tools provided by MCP servers
  • Access external data sources and APIs
  • Integrate with third-party services

How MCP Works

Configuration

Add MCP server configuration to ~/.picoclaw/config.json:

Server Configuration

Available MCP Servers

MCP has a growing ecosystem of official and community servers:

Official Servers

Filesystem

Read and manipulate local files.

GitHub

Interact with GitHub repositories, issues, and PRs.

PostgreSQL

Query and manage PostgreSQL databases.

Google Drive

Access Google Drive files.

Slack

Interact with Slack workspaces.

Finding More Servers

Browse available MCP servers:

Using MCP Tools

Once MCP servers are configured, their tools are automatically available to the agent.

Tool Discovery

The agent sees MCP tools with the mcp_ prefix:

Tool Naming Convention

MCP tools are named:
Examples:
  • mcp_github_create_issue - GitHub server’s “create_issue” tool
  • mcp_filesystem_read_file - Filesystem server’s “read_file” tool
  • mcp_postgres_query - Postgres server’s “query” tool

Name Sanitization

Tool names are sanitized for compatibility:
  • Converted to lowercase
  • Special characters replaced with underscores
  • Limited to 64 characters (OpenAI API limit)
  • Hash appended if sanitization is lossy
Examples:
  • My-Tool! → my_tool
  • Very Long Tool Name With Spaces → very_long_tool_name_with_spaces
  • Tool@#$%Name → tool_name_12ab34cd (hash appended)

Automatic Usage

The agent uses MCP tools automatically: Example 1: GitHub Integration
Example 2: Database Query

Implementation Details

MCPTool Wrapper

Each MCP tool is wrapped to implement PicoClaw’s Tool interface:

Tool Execution Flow

  1. Agent calls MCP tool via name (e.g., mcp_github_create_issue)
  2. MCPTool wrapper forwards to MCP Manager
  3. MCP Manager communicates with external server
  4. Server executes tool and returns result
  5. Result wrapped in ToolResult and returned to agent

Error Handling

MCP tool errors are properly handled:
Errors include:
  • Connection failures
  • Server not responding
  • Tool execution errors
  • Invalid parameters

Content Types

MCP tools can return different content types:
  • Text: Plain text responses
  • Images: Image data with MIME type
  • Other: Custom content types
Example handling:

Security Considerations

Server Trust

Only configure MCP servers from trusted sources:
  • Official MCP servers from Model Context Protocol
  • Well-maintained community servers
  • Servers you’ve audited yourself

Credential Management

Never commit credentials to config files: ❌ Bad:
✅ Good:
Then set environment variable:

Workspace Restrictions

MCP tools respect PicoClaw’s workspace restrictions:
  • If restrict_to_workspace: true, tools are sandboxed
  • External servers may have their own access controls
  • Review server permissions before enabling

Creating Custom MCP Servers

You can create custom MCP servers for your specific needs.

Example: Custom Weather Server

Register Custom Server

Troubleshooting

Server Not Starting

  1. Check command is available:
  1. Test server manually:
  1. Check logs:

Tools Not Appearing

  1. Verify server is enabled:
  1. Check server configuration:
    • Command path correct
    • Arguments properly formatted
    • Environment variables set
  2. Restart gateway:

Authentication Errors

  1. Verify credentials:
    • API tokens are valid
    • Environment variables are set
    • Credentials have necessary permissions
  2. Check token format:
    • GitHub: ghp_...
    • Slack: xoxb-...

Tool Execution Fails

  1. Check tool parameters:
    • Review required parameters
    • Verify parameter types
    • Check parameter constraints
  2. Test tool independently:
    • Use MCP inspector/debugger
    • Call tool directly from server

MCP Resources

Documentation

Tools & Utilities