Skip to main content

bub-mcp

Expose configured MCP servers as Bub tools.

Installation

uv pip install bub-mcp

Configuration

The plugin reads MCP server definitions from a dedicated JSON file under Bub home:

  • ~/.bub/mcp.json
  • or $BUB_HOME/mcp.json when BUB_HOME is set

The file must contain a top-level mcpServers mapping:

{
  "mcpServers": {
    "weather": {
      "url": "https://weather.example.com/mcp",
      "transport": "http"
    },
    "local": {
      "command": "python",
      "args": ["./server.py"]
    }
  }
}

Discovered MCP tools are registered as Bub deferred tools by default: the model only sees their names until it loads their definitions with tool.describe, which keeps large MCP tool sets out of the prompt. Set BUB_MCP_DEFERRED_TOOLS=false to expose them directly instead.

CLI Usage

Use the CLI to inspect and manage mcp.json:

bub mcp list

Add an HTTP server:

bub mcp add --transport http weather https://weather.example.com/mcp

Add an SSE server with headers:

bub mcp add \
  --transport sse \
  --header "Authorization: Bearer token" \
  events \
  https://events.example.com/mcp

Add a stdio server with environment variables:

bub mcp add \
  --transport stdio \
  --env API_KEY=secret \
  filesystem \
  -- npx -y @modelcontextprotocol/server-filesystem /tmp

Remove a server:

bub mcp remove weather

bub mcp add writes the server config into mcp.json and performs a connection test before exiting.

Lifecycle

The plugin owns mcp.json connections through Bub's provide_lifespan hook, so every entry point that enters framework.running() (bub gateway, bub chat, bub run, bub acp, ...) connects the configured servers. Discovery runs in the background; the first turn waits for it before binding tools. Servers that fail to connect are reported by the mcp tool and do not stop Bub.

Embedding

Other Bub plugins can reuse the MCP connection and tool bridge with a read-only configuration:

from bub_mcp.plugin import MCPManager

manager = MCPManager.from_server_configs(
    {"weather": {"url": "https://weather.example.com/mcp"}}
)

# Inside the embedding application's async lifecycle, e.g. its own provide_lifespan hook:
await manager.connect()
try:
    manager.bind_agent(agent)
    # Run the agent while its MCP connections are open.
finally:
    await manager.stop()

start() begins discovery in the background instead of waiting for it like connect(). Discovered tools belong to the manager and are available through manager.tools; they are not provided through the provide_tools hook. Bub collects those tools when a BubAgent is created, so tools discovered afterward would not reach existing agents. The plugin's load_state hook waits for startup discovery and binds tools to the turn's Agent (including an explicit _runtime_agent). Stopping the manager removes its bindings and restores any tools it replaced.

An embedding application can call manager.bind_agent(agent) after startup discovery completes, or await manager.bind_runtime_tools(framework, message) from its own load_state hook. Both paths use instance tools. This requires Bub's instance-tool API introduced in upstream PR #311.

The default MCPManager() behavior remains backed by Bub's mcp.json. Read-only managers reject add() and remove() so an embedding plugin remains the owner of its source configuration. MCPChannel remains as a deprecated alias of MCPManager; it is no longer a Bub channel.

Metadata

Release files for bub-mcp 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bub-mcp 0.4.0
File Size Uploaded Provenance Actions
bub_mcp-0.4.0.tar.gz 9.7 kB With provenance Details for bub_mcp-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bub-mcp 0.4.0
File Interpreter ABI Platform Actions
bub_mcp-0.4.0-py3-none-any.whl Python 3 none any Details for bub_mcp-0.4.0-py3-none-any.whl

Total release size: 20.9 kB

Release files / bub_mcp-0.4.0.tar.gz

Download URL bub_mcp-0.4.0.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8cc58c6805cd7d11c1f7f9e77af1afbf83ef36e051e25285c1825721ec3ea642
BLAKE2b-256 checksum
How to use checksums
6f65138ca58b7321dbf4c54d490d9dc174637b0b724c1231bbbc487c80fbd7f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

Release files / bub_mcp-0.4.0-py3-none-any.whl

Download URL bub_mcp-0.4.0-py3-none-any.whl
Size 11.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
22920cf2a6e7047709f04b57640188d492f6fa1c6ef9cce2908703cdf9df86da
BLAKE2b-256 checksum
How to use checksums
018df721617cd5fca7f95ace22d37804332a321d751293d0a44662fa3ea6cadb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

Security for bub-mcp 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for bub_mcp-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page