
mcp-broker
io.github.NavinAgrawalPublished by GitHub account NavinAgrawalv1.4.1Updated Nov 3, 2026
Local MCP broker that exposes one compact entry for many upstream servers.
Overview
Local MCP broker that fronts many upstream MCP servers behind one compact stdio entry, exposing search, describe, call, status and session-close tools.
- What you can do
- Search and describe upstream tools through the broker facade, with schemas fetched on demand
- Call upstream tools through broker routing, optionally trimming responses server-side
- Inspect profile-visible upstream state, auth probes and last errors without starting tools
- Release caller-owned per-session upstream processes without stopping shared ones
- Start, reuse, isolate and clean up upstream MCP servers, with profile tool budgets and mutating-tool gates
- Render, back up and roll back MCP client configs, plus LaunchAgent, systemd and Windows task install flows
- When to use it
- Useful when a developer's MCP clients (Codex, Claude Code, AGY and similar) carry more upstream servers and tool definitions than fit comfortably in every session, or when duplicate upstream processes, scattered OAuth state and orphaned processes need one local owner.
- Requirements
- Runs as a local process on the user's machine, installed from PyPI (pipx, uv or Homebrew) or a repo clone. Needs Python 3.10 or newer as python3, make, and a clone of the repo for the Makefile flows; Node.js and npx for npm-based upstreams. macOS LaunchAgent use needs launchctl; Linux and Windows use systemd or PowerShell Scheduled Tasks. A private YAML config is created from the public template.
Installation
In SourceWeft
- Open mcp-broker in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
README
mcp-broker
[mcp-broker routing backbone brand header]
mcp-broker is a local Model Context Protocol process broker for MCP clients.
Think PgBouncer for MCP: one stable local endpoint in front of many upstream MCP servers. The broker owns upstream startup, reuse, cleanup, profile exposure, status, and safe tool routing.
The core idea is simple: do not make every agent session load every upstream tool definition before the user asks a task.
Why this exists
AI coding sessions with many MCP servers tend to accumulate the same problems:
- every client config repeats the same MCP server list
- every new session can start duplicate upstream processes
- OAuth, browser state, local files, and database handles spread across tools
- raw tool lists consume context before the task begins
- hosted connector caches can duplicate local MCP tools
- orphaned MCP processes survive after client sessions exit
mcp-broker puts a small broker facade in front of those upstreams. It is not a hosted workflow builder; it is local infrastructure for keeping MCP clients small, predictable, and under one config contract.
The client sees a small set of broker tools:
The upstream MCPs still exist. They are discovered and called through the broker when a task needs them.
Measured context reduction
On 2026-05-24, the measured Codex setup went from many raw MCP and hosted app tool definitions to one broker facade plus a pruned codex_apps cache.
The 92.94% number is a tool-definition count reduction. The 83.65% number is a token reduction for canonical serialized tool payloads measured with tiktoken o200k_base.
See docs/context-reduction-measurement.md for evidence and caveats.
What it does
- Runs one local broker daemon over a Unix socket.
- Exposes one lightweight stdio client shim to MCP clients.
- Starts upstream MCP servers on demand.
- Reuses shared upstreams across sessions when configured.
- Isolates per-session upstreams when state must not be shared.
- Maps upstream tools into stable namespaces.
- Exposes compact search, describe, call, status, and caller-bound session-close tools.
- Enforces profile-level tool budgets and exposure gates.
- Blocks mutating upstream exposure unless a profile allowlist grants it.
- Stores runtime state under
$HOME/mcp/mcp-broker, outside the repo. - Renders MCP client config entries with dry-run, backup, and rollback.
- Provides LaunchAgent install and uninstall flows for macOS.
- Provides Linux systemd user-service render, install, unload, and removal flows.
- Provides Windows PowerShell Scheduled Task render, install, and removal flows.
- Includes unit, journey, live, and e2e tests through Makefile targets.
Core differentiators:
- Profile-scoped exposure: each MCP client gets a configured view of upstreams instead of every tool by default.
- Mutating-tool gates: mutating upstreams stay hidden until a profile allowlist grants access.
- Lifecycle ownership: shared and per-session upstreams are started, watched, stopped, and reaped by the broker.
- Client parity checks: rendered profiles can be validated through the same compact broker facade before config is applied.
Who this is for
Use mcp-broker if you:
- use Codex, Claude Code, AGY CLI, or other MCP clients
- have more MCP tools than you want in every session
- need shared local MCP servers without duplicate process startup
- want one place for OAuth state, browser state, sockets, logs, and cleanup
- need per-client profiles instead of the same tool list everywhere
- want a small broker facade instead of raw upstream tool dumps
This repo is not an enterprise MCP control plane. It is local desktop infrastructure for developer-agent workflows.
Current status
Implemented:
- YAML config loading from
config/broker.private.yaml, created fromconfig/broker.example.yaml. - Strict YAML contract validation for runtime, clients, profiles, upstreams, and policy blocks.
- Public JSON Schema validation through
config/broker.schema.json. - Runtime path derivation from
runtime.root. - Tool namespace mapping from configured upstream prefixes.
- Local upstream subprocess lifecycle management and process-group cleanup.
- Broker daemon over Unix socket.
- MCP client shim and renderers for configured MCP client profiles, including Codex, Claude, and AGY.
- AGY profile rendering to
.gemini/config/mcp_config.json, including its MCP allowed-server policy. - Dry-run client config rendering, apply-time backups, and rollback.
- LaunchAgent render and install scripts with dry-run defaults.
- Compact broker facade for search, describe, call, status, and caller-bound session close.
- Profile validation from YAML smoke probes.
- Discovery parity checks between compact client profiles.
- Public and maintainer quality gates through Makefile targets.
- Shared-runtime guardrail contracts through P3.8 E2E proof while hosted execution remains disabled by default.
Wiring status:
- Codex is wired through the broker.
- Claude is wired through the broker after profile validation and manual
/mcpacceptance. - AGY is wired through the broker by rendering
.gemini/config/mcp_config.json.
Public release status:
- The repo is designed to stay public-safe.
- Private upstream inventory, account paths, OAuth state, secrets, sockets, logs, and generated client configs stay outside git.
- Stable release metadata is validated by
make release-version-check; publication proof is tracked indocs/distribution.md. - Docker image support is available for container-friendly configs. Docker MCP Catalog submission still requires Docker review.
- MCPB metadata is present at
mcpb/manifest.jsonfor local directory review.
See ROADMAP.md for public-facing release work.
Architecture
mcp-broker has three runtime layers:
The config file is the contract. Profiles decide exposure, upstreams define transport and lifecycle behavior, and smoke probes define safe read calls for validation.
Comparison
Screenshots Or GIF
The quickstart flow should look like this:
[mcp-broker quickstart terminal]
In an MCP client, /mcp should show one mcp-broker entry. Use broker_status
to inspect profile-visible upstream state.
Quickstart
Prerequisites:
- macOS with
launchctlfor LaunchAgent use. - Python 3.10 or newer available as
python3. make.- Node.js and
npxfor npm-based upstream MCP servers. - A clone of this repo.
Package installs:
Homebrew installs the same console scripts as the Python package. Package installs do not write MCP client config; client wiring stays an explicit Makefile action.
Docker is for container-friendly configs:
Local stdio clients and MCPB-style installs use the package-owned lifecycle:
Create the local venv, install dependencies, and verify runtime layout:
Create private config from the public template:
config-init creates the destination directory when needed and copies the public
template as the starting point. It does not import local MCP inventory, user
paths, or secrets.
Edit config/broker.private.yaml for local upstreams. Keep secret values out of config. Use environment variable names or files under:
Run the quality gate:
Validate the configured YAML contract:
Start the broker:
Check status:
For the full install flow, see docs/install.md. For a clone-to-running adoption flow, see docs/adoption-guide.md#clone-to-running-path. For shared-runtime boundaries, see docs/shared-runtime-guardrails.md. P3.8 E2E proof covers tenant isolation, authz denial, quota denial, session affinity, audit events, rollback, degraded mode, local-only routing, and shared-eligible routing. Hosted execution remains unsupported in the public local broker.
Runtime layout
Default runtime root:
Runtime files are not repo files. Upstream OAuth state, browser state, secret files, sockets, logs, rendered client configs, backups, and daemon state belong under the runtime root.
Client wiring
Back up a client config:
Dry-run render:
Apply after reviewing the rendered file under $HOME/mcp/mcp-broker/renders/:
Rollback:
Use CLIENT=claude or CLIENT=agy after that profile smoke passes and that
client is intended to use the broker. For new JSON-based MCP clients, generate a
starter block:
See docs/add-profile.md for the full new-profile flow.
Compact broker facade
The compact facade keeps chat-facing profiles small:
Codex /mcp shows the single mcp-broker entry by design. Per-upstream visibility, status, and socket path come from broker_status.
Profiles and safety
Profiles decide which upstreams a client can see and call.
Supported concepts:
max_toolsprotects clients from huge tool lists.compact_tools_enabledexposes broker facade tools instead of raw upstream tools.broker_tool_name_styleadapts broker facade names for clients that cannot surface dotted tool names.result_size_charsdeclaresanthropic/maxResultSizeCharsonbroker_call_tool(at most 500000), so Claude Code keeps larger results inline.result_budget_charssendsmcp-broker/result_budget_charsin the_metaof every forwardedtools/call, so upstreams can size answers for the client. See docs/add-profile.md.mcp_allowed_serversrenders client settings for MCP clients that require an explicit server allowlist.allow_mutating_upstreamsis required before a mutating upstream can be exposed.sharedmode reuses one upstream process where shared account state is acceptable.per_sessionmode isolates upstream state per client session.per_callmode starts a fresh stdio process for each tool call or tool-list operation, then stops that process before returning.disabledmode keeps compatibility records without exposing the upstream.
Status reports active_call_count for in-flight per_call operations, including
tool discovery. It returns to zero after success, failure, or timeout cleanup.
This count is separate from session_count and is not a count of saved threads.
Reading status does not start an upstream; profile-hidden upstreams stay hidden.
Protected surfaces such as OAuth, browser state, filesystem roots, and databases require explicit config and validation. Public examples stay disabled or placeholder-based.
See docs/security-review.md and docs/upstream-compatibility-matrix.md. For a deeper safety checklist, see docs/safety.md.
Config contract
The public template is config/broker.example.yaml. The matching JSON Schema is config/broker.schema.json.
Supported top-level sections:
The loader rejects unknown keys. Runtime placeholders such as {runtime.root}, {runtime.state_dir}, and {runtime.secrets_dir} can be used in upstream command, args, working directory, and env file paths.
make config-validate checks the selected CONFIG_PATH against the public JSON Schema first, then runs the runtime loader so semantic rules are enforced from the same code path the broker uses.
Each enabled upstream exposed to a profile should define a safe smoke probe:
make profile-validation PROFILE=<profile> validates every enabled upstream visible to that profile through broker_status, broker_search_tools, broker_describe_tool, and the configured safe broker_call_tool.
Codex operator acceptance
Repo-owned tests validate broker behavior through the local client shim. The last Codex-specific check has to run inside an active Codex session because that is where the deferred MCP wrapper tools exist.
Generate the current acceptance steps from YAML:
The target reads the configured smoke probes and prints the exact
mcp__mcp_broker__ wrapper calls for search, describe, and safe call. It does
not invoke Codex, does not call an external LLM session, and is not part of
make quality-gate.
See docs/codex-deferred-tool-acceptance.md.
LaunchAgent
Render without writing:
Apply and load:
Unload or remove:
systemd
Linux user-service install uses the same runtime root and config path contract:
For package installs, set MCP_BROKER_DAEMON_COMMAND to the installed daemon
path before applying the service.
Windows
Windows startup uses PowerShell Scheduled Task commands with the same runtime root and config path contract:
Remove it with:
Test and release gates
Run all test tiers:
Run the public quality gate:
The coverage gate uses line and branch coverage for Python source.
Run the release gate when preparing a tag:
release-gate runs package, smoke, and mutation checks. Mutation receives a
release-scoped child count derived from LOCAL_CPU_BUDGET and
RELEASE_GATE_JOBS, so it does not take the full CPU budget while other
release children run. Mutation runs public unit and journey tests last and writes
var/quality/mutation_stats.json with total counts, score, and ranked
blocked_by_file entries. On macOS, the release gate runs mutation inside a
Linux container to avoid local mutmut fork failures. E2E tests remain in make quality-gate.
Run smoke and runtime cleanup checks:
Release or client config apply should wait for:
make quality-gatemake config-validatemake broker-smoke- dry-run config render for each intended client
- rollback test
make release-smokemake release-gatebefore taggingmake doctorwith no stale broker-owned resources
See docs/release-checklist.md.
Public commands
These targets use this repo plus declared Python and Node prerequisites:
For source contributions, install gitleaks on PATH and run make hooks-install
in each checkout. The tracked pre-commit hook requires a redacted staged secret
scan, then runs commit-tier affected tests through Make. Missing scanner tools,
empty staged scope, and scan or test failures block the commit. GITLEAKS and
PYTHON select the scanner and maintainer interpreter. Installation uses Git's
worktree-specific config and refuses unknown existing hooks or common
core.worktree/bare settings that need migration. No hosted workflow is started.
make quality-gate is repo-local. It does not call personal scripts outside this repo.
make codex-deferred-acceptance is maintainer-only. It does not invoke Codex
or an external LLM session. It reads the same YAML smoke probes and prints the
exact mcp__mcp_broker__ deferred wrapper calls to run inside an active Codex
session. See docs/codex-deferred-tool-acceptance.md.
Project tree
Generated reports stay under var/, especially var/coverage/, var/test-logs/, and var/quality/.
Docs
- SECURITY.md
- CONTRIBUTING.md
- ROADMAP.md
- docs/install.md
- docs/add-profile.md
- docs/migration.md
- docs/adoption-guide.md
- docs/comparison.md
- docs/distribution.md
- docs/github-publication.md
- docs/community-launch.md
- docs/auth-recipes.md
- docs/architecture.md
- docs/protocol.md
- docs/runtime-layout.md
- docs/safety.md
- docs/security-review.md
- docs/upstream-compatibility-matrix.md
- docs/codex-deferred-tool-acceptance.md
- docs/context-reduction-measurement.md
- docs/mutation-testing.md
- docs/release-checklist.md
- docs/troubleshooting.md
Design rules
- Keep upstream definitions in central config.
- Keep runtime state under
$HOME/mcp/mcp-broker. - Keep private upstream inventory in
config/broker.private.yaml, which is ignored by git. - Keep secret values out of config and source.
- Do not hardcode personal paths in source, tests, docs, or public config.
- Run build, test, runtime, and config operations through the Makefile.
Source: README.md at commit 5245398
Tools
0Version history
1- v1.4.1LatestSep 16, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts