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.
Quick start
Section titled “Quick start”Before starting, install the Bub app and ensure uvx is available on your PATH (it launches the example server without installing it).
-
Install the plugin and verify
Terminal window bub install bub-mcp@mainbub hooksbub installresolves and installsbub-mcpfrombub-contrib. Confirmmcpappears in thebub hooksoutput:load_state: builtin, mcpprovide_channels: builtin, mcpregister_cli_commands: builtin, mcp -
Configure an MCP server
bub-mcpreads~/.bub/mcp.jsonby default (or$BUB_HOME/mcp.jsonwhenBUB_HOMEis set). Configure the officialmcp-server-timeserver:Terminal window mkdir -p ~/.bubcat > ~/.bub/mcp.json <<'EOF'{"mcpServers": {"time": {"command": "uvx","args": ["mcp-server-time"]}}}EOFEntries with
commanduse the localstdiotransport automatically. -
Check connection and discovered tools
Run
bub mcp listto verify that the configuration takes effect:Terminal window bub mcp listOutput when connected:
🔌 MCP Tools- timeStatus: ConnectedTools: 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.describeon demand); setBUB_MCP_DEFERRED_TOOLS=falseto inject full schemas into the initial system prompt.
- MCP tools are registered as
-
Call the tool in a chat session
MCP connections are maintained by the
mcp.lifecyclebackground service, so usebub chatorbub gateway:Terminal window bub chatAsk a question:
What time is it in UTC right now?The model automatically calls
mcp.time_get_current_timeto answer.
Add more servers
Section titled “Add more servers”You can register multiple servers under mcpServers in ~/.bub/mcp.json.
Remote servers (HTTP / SSE)
Section titled “Remote servers (HTTP / SSE)”When a tool runs as a remote service or in a container, configure it with url, transport, and optional headers:
{ "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" } } }}Local filesystem server
Section titled “Local filesystem server”For local tools that need directory restrictions, pass allowed paths through args:
{ "mcpServers": { "filesystem": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp/bub-sandbox"] } }}Manage servers from the CLI
Section titled “Manage servers from the CLI”Besides editing the JSON file directly, you can use bub mcp commands to add or remove servers:
# Add local stdio serversbub mcp add --transport stdio time -- uvx mcp-server-timebub mcp add --transport stdio --env API_KEY=secret custom -- node ./my-server.js
# Add remote HTTP or SSE serversbub mcp add --transport http weather https://weather.example.com/mcpbub mcp add --transport sse --header "Authorization: Bearer token" events https://events.example.com/mcp
# Remove a serverbub mcp remove timeUse alongside Agent Plugins
Section titled “Use alongside Agent Plugins”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> |
Troubleshooting
Section titled “Troubleshooting”| 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 |