Async capability routing runtime for LangChain, LangGraph, and MCP adapters.
pip install mcp-capability-router Copy PIP instructions
An async-first, runtime-isolated capability routing layer for LangChain, LangGraph, and langchain-mcp-adapters.
Model Context Protocol (MCP) servers can expose hundreds or thousands of tools, resources, and prompts. Loading all of that into an agent's context on every turn is slow, expensive, and drowns out the model's ability to pick the right capability. mcp-capability-router sits between your agent and your MCP servers: it discovers and indexes capability metadata cheaply, retrieves only the handful relevant to a query, and connects to a server lazily -- only when an operation actually needs it.
Connect an agent to a handful of MCP servers and the naive approach -- fetch every tool, resource, and prompt from every server at startup and hand the whole catalog to the model -- works fine. Connect it to a dozen servers, or a handful of servers that each expose hundreds of tools, and that same approach quietly breaks in three ways at once:
mcp-capability-router exists to make the scalable path the default path, without reinventing MCP transport or agent orchestration:
This package is not yet published to PyPI. Install it from source:
git clone https://github.com/smuniharish/mcp-capabilty-router.git cd mcp-capabilty-router pip install . Optional extras add integration-specific dependencies as needed:
pip install ".[mcp]" # langchain-mcp-adapters pip install ".[langgraph]" # LangGraph pip install ".[agents]" # LangChain create_agent, DeepAgents pip install ".[swarm]" # langgraph-swarm Requires Python 3.12.
import asyncio from mcp_capability_router import CapabilityType, MCPRuntime async def main(): async with MCPRuntime() as runtime: await runtime.register_server("filesystem", my_filesystem_adapter_factory) await runtime.refresh_server("filesystem") candidates = await runtime.retrieve("read a file", type=CapabilityType.TOOL, limit=5) result = await runtime.execute(candidates[0].capability_id, {"path": "notes.txt"}) print(result) asyncio.run(main()) See Getting started for wiring in a real langchain-mcp-adapters client, and Examples for runnable scripts covering real MCP servers, LangGraph/DeepAgents/langgraph-swarm integrations, and pluggable registries, retrievers, and metrics backends.
Full documentation -- architecture, concepts, guides, operations, API reference, and troubleshooting -- lives in docs/ and is built with MkDocs Material.
uv sync --extra dev uv run pytest uv run ruff check . uv run ruff format --check . uv run pyrefly check uv run mkdocs build License Apache License 2.0 -- see LICENSE.
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ Licensed under the Apache ...
agents dev docs examples langgraph mcp openai swarm
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.




