MCP (Model Context Protocol) Support

May 30, 2026 · View on GitHub

Overview

CLIO supports the Model Context Protocol (MCP), an open standard that lets AI applications connect to external tool servers. With MCP, you can extend CLIO's capabilities by connecting to third-party tools - databases, APIs, file systems, and more - without modifying CLIO itself.

MCP servers provide tools that the AI can discover and call just like CLIO's built-in tools. The protocol uses JSON-RPC 2.0 over stdio for communication.


Requirements

MCP servers are typically distributed as npm packages or Python packages. You need at least one of the following runtimes installed:

RuntimeUsed ForInstall
npx (Node.js)npm-based MCP serversbrew install node / apt install nodejs npm
nodeLocal JS MCP serversComes with Node.js
uvxPython MCP servers (uv)pip install uv
python3Python MCP serversUsually pre-installed

If no compatible runtime is found, MCP is silently disabled and CLIO works normally without it.


Configuration

MCP servers are configured in ~/.clio/config.json under the mcp key:

{
  "mcp": {
    "filesystem": {
      "command": ["npx", "-y", "@modelcontextprotocol/server-filesystem", "/path/to/dir"],
      "enabled": true
    },
    "sqlite": {
      "command": ["npx", "-y", "@modelcontextprotocol/server-sqlite", "path/to/database.db"],
      "enabled": true
    },
    "memory": {
      "command": ["npx", "-y", "@modelcontextprotocol/server-memory"],
      "enabled": true
    }
  }
}

Server Config Options

KeyTypeDescription
typeStringlocal (default, stdio) or remote (HTTP/SSE)
commandArrayCommand and arguments for local servers
urlStringURL endpoint for remote servers
headersObjectCustom HTTP headers for remote servers
enabledBooleanSet to false to disable without removing config
environmentObjectExtra environment variables (local servers only)
timeoutNumberConnection/request timeout in seconds (default: 30)

Example: Local Server

{
  "mcp": {
    "filesystem": {
      "command": ["npx", "-y", "@modelcontextprotocol/server-filesystem", "/path/to/dir"],
      "enabled": true
    }
  }
}

Example: Remote Server

{
  "mcp": {
    "remote-tools": {
      "type": "remote",
      "url": "https://mcp.example.com/api",
      "headers": {
        "Authorization": "Bearer your-api-key"
      },
      "timeout": 60
    }
  }
}

Example: Custom Environment

{
  "mcp": {
    "github": {
      "command": ["npx", "-y", "@modelcontextprotocol/server-github"],
      "environment": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_xxxxx"
      }
    }
  }
}

Commands

/mcp or /mcp status

Show connection status of all configured MCP servers:

✓ filesystem (MCP Filesystem Server) - 11 tool(s)
✗ broken-server (failed: Connection refused)
− disabled-server (disabled)

/mcp list

List all tools from all connected MCP servers:

MCP Tools (14 total):

  [filesystem]
    mcp_filesystem_read_file: Read the complete contents of a file...
    mcp_filesystem_write_file: Create a new file or overwrite...
    mcp_filesystem_list_directory: Get a detailed listing...
    ...

  [sqlite]
    mcp_sqlite_read_query: Execute a SELECT query...
    mcp_sqlite_write_query: Execute an INSERT, UPDATE, or DELETE...
    mcp_sqlite_list_tables: List all tables in the database

/mcp add <name> <command...> or /mcp add <name> <url>

Add and connect to a new MCP server:

# Local server (stdio)
/mcp add filesystem npx -y @modelcontextprotocol/server-filesystem /tmp

# Remote server (HTTP/SSE)
/mcp add remote-tools https://mcp.example.com/api

This also saves the server to your config for persistence across sessions.

/mcp remove <name>

Disconnect and remove an MCP server:

/mcp remove filesystem

How It Works

  1. Startup: CLIO reads MCP config and creates a transport for each enabled server
    • Local servers (type: local or default): Spawned as subprocesses, communicate via stdio
    • Remote servers (type: remote): Connected via HTTP POST with SSE streaming support
  2. Handshake: Sends initialize request (MCP 2025-11-25 protocol), receives capabilities
  3. Discovery: Calls tools/list to discover what tools the server provides
  4. Registration: Each MCP tool is registered as a CLIO tool with the mcp_ prefix
  5. Execution: When the AI calls an MCP tool, CLIO sends tools/call via JSON-RPC
  6. Shutdown: On exit, CLIO closes stdin to each server and waits for clean exit

Tool Naming

MCP tools are namespaced to prevent collisions:

mcp_<servername>_<toolname>

For example, a read_file tool from the filesystem server becomes: mcp_filesystem_read_file

The AI sees these as regular tools and can call them alongside built-in tools.


ServerPackageDescription
Filesystem@modelcontextprotocol/server-filesystemRead/write files in specified directories
SQLite@modelcontextprotocol/server-sqliteQuery SQLite databases
PostgreSQL@modelcontextprotocol/server-postgresQuery PostgreSQL databases
Memory@modelcontextprotocol/server-memoryKnowledge graph memory
GitHub@modelcontextprotocol/server-githubGitHub API operations
Git@modelcontextprotocol/server-gitGit repository operations
Fetch@modelcontextprotocol/server-fetchHTTP fetch with readability
Puppeteer@modelcontextprotocol/server-puppeteerBrowser automation
Brave Search@modelcontextprotocol/server-brave-searchWeb search via Brave

Browse more at: github.com/modelcontextprotocol/servers


Troubleshooting

"MCP not initialized"

MCP couldn't find any compatible runtime (npx, node, uvx, python). Install Node.js:

brew install node          # macOS
sudo apt install nodejs npm  # Debian/Ubuntu

Server shows "failed" status

Run the server command manually to check for errors:

npx -y @modelcontextprotocol/server-filesystem /tmp

Common issues:

  • Package not found (check spelling)
  • Missing API keys (check environment config)
  • Permission denied (check file/directory permissions)

Server connects but tools don't work

Enable debug mode to see MCP JSON-RPC traffic:

./clio --debug --new
/mcp status

Debug output shows all JSON-RPC messages between CLIO and the MCP server.


OAuth 2.0 Authentication

CLIO supports OAuth 2.0 with PKCE for MCP servers that require authentication:

{
  "mcp": {
    "protected-server": {
      "type": "remote",
      "url": "https://mcp.example.com/api",
      "oauth": {
        "authorization_url": "https://auth.example.com/authorize",
        "token_url": "https://auth.example.com/token",
        "client_id": "your-client-id",
        "scopes": ["tools:read", "tools:execute"]
      }
    }
  }
}

On first connection, CLIO opens a browser for authorization. Tokens are cached at ~/.clio/mcp-tokens/<servername>.json (permissions 0600) and refreshed automatically.

To re-authenticate manually:

/mcp auth <servername>

Architecture

Module Structure

ModulePurpose
CLIO::MCP::ManagerServer lifecycle, tool discovery, routing
CLIO::MCP::ClientJSON-RPC 2.0 client implementation
CLIO::MCP::Transport::StdioLocal server communication (stdin/stdout)
CLIO::MCP::Transport::HTTPRemote server communication (HTTP POST + SSE)
CLIO::MCP::Auth::OAuthOAuth 2.0 + PKCE flow
CLIO::Tools::MCPBridgeTool registration bridge (MCP tools -> CLIO tools)

Limitations

  • No MCP resources - Only tools are bridged (resources and prompts planned)
  • No sampling - Server-initiated LLM requests not supported
  • No progress notifications - Long-running tools show no progress

Protocol Reference

CLIO implements the MCP 2025-11-25 specification: