Skip to content

Connect MCP servers

Model Context Protocol (MCP) is an open protocol that lets Agents securely and consistently call local or remote tools and data sources.

By installing the bub-mcp plugin, you can seamlessly bring tools from across the MCP ecosystem into the Bub app.

stdio (subprocess)HTTP / SSE (remote)User / clientBub Agent runtimebub-mcp pluginLocal MCP server(e.g. filesystem / time)Remote MCP server(e.g. internal API /database)

Before starting, install the Bub app and ensure uvx is available on your PATH (it launches the example server without installing it).

  1. Install the plugin and verify

    Terminal window
    bub install bub-mcp@main
    bub hooks

    bub install resolves and installs bub-mcp from bub-contrib. Confirm mcp appears in the bub hooks output:

    load_state: builtin, mcp
    provide_channels: builtin, mcp
    register_cli_commands: builtin, mcp
  2. Configure an MCP server

    bub-mcp reads ~/.bub/mcp.json by default (or $BUB_HOME/mcp.json when BUB_HOME is set). Configure the official mcp-server-time server:

    Terminal window
    mkdir -p ~/.bub
    cat > ~/.bub/mcp.json <<'EOF'
    {
    "mcpServers": {
    "time": {
    "command": "uvx",
    "args": ["mcp-server-time"]
    }
    }
    }
    EOF

    Entries with command use the local stdio transport automatically.

  3. Check connection and discovered tools

    Run bub mcp list to verify that the configuration takes effect:

    Terminal window
    bub mcp list

    Output when connected:

    🔌 MCP Tools
    - time
    Status: Connected
    Tools: mcp.time_get_current_time, mcp.time_convert_time
    • MCP tools are registered as mcp.<server>_<tool>.
    • To save prompt tokens, MCP tools use deferred loading by default (the model calls tool.describe on demand); set BUB_MCP_DEFERRED_TOOLS=false to inject full schemas into the initial system prompt.
  4. Call the tool in a chat session

    MCP connections are maintained by the mcp.lifecycle background service, so use bub chat or bub gateway:

    Terminal window
    bub chat

    Ask a question:

    What time is it in UTC right now?

    The model automatically calls mcp.time_get_current_time to answer.

You can register multiple servers under mcpServers in ~/.bub/mcp.json.

When a tool runs as a remote service or in a container, configure it with url, transport, and optional headers:

~/.bub/mcp.json
{
"mcpServers": {
"weather": {
"url": "https://weather.example.com/mcp",
"transport": "http"
},
"internal_crm": {
"url": "https://crm.corp.internal/mcp",
"transport": "sse",
"headers": {
"Authorization": "Bearer YOUR_SECRET_TOKEN"
}
}
}
}

For local tools that need directory restrictions, pass allowed paths through args:

~/.bub/mcp.json
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp/bub-sandbox"]
}
}
}

Besides editing the JSON file directly, you can use bub mcp commands to add or remove servers:

Terminal window
# Add local stdio servers
bub mcp add --transport stdio time -- uvx mcp-server-time
bub mcp add --transport stdio --env API_KEY=secret custom -- node ./my-server.js
# Add remote HTTP or SSE servers
bub mcp add --transport http weather https://weather.example.com/mcp
bub mcp add --transport sse --header "Authorization: Bearer token" events https://events.example.com/mcp
# Remove a server
bub mcp remove time

Global MCP servers and Agent Plugins use separate lifecycle channels and tool prefixes, so they can run side by side:

Source Config file Lifecycle channel Tool name format
Global MCP ~/.bub/mcp.json mcp.lifecycle mcp.<server>_<tool>
Agent Plugin <plugin>/mcp.json agent-plugins.mcp mcp.<plugin>.<server>_<tool>
Symptom Possible cause Fix
mcp missing from bub hooks Plugin installed in another Python environment Check command -v bub and re-run bub install bub-mcp@main in that environment
bub mcp list shows Disconnected Server command failed or remote URL is unreachable Run uvx mcp-server-time or curl the URL directly to inspect the error
MCP tools unavailable in bub run "..." bub run does not start mcp.lifecycle Use bub chat or bub gateway instead
bub mcp add logs CancelledError on exit Subprocess cleanup log; config is usually saved Run bub mcp list to verify the entry was written
Permission denied when saving config ~/.bub/ is not writable Fix permissions on ~/.bub or point BUB_HOME to a writable directory