Repository navigation
mcp-slim: Cut MCP tool schema & output tokens by 50%-98% for LlamaIndex MCP agents #24149
SalyyS1
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi everyone,
When building
FunctionAgent/ReActAgentworkflows in LlamaIndex backed byBasicMCPClient/McpToolSpec, connecting large MCP servers (GitHub, Postgres, Notion, internal APIs) can quickly add 10,000+ tokens of tool schema definitions to every agent step and cause recursive Pydanticcreate_model_from_json_schemaerrors when schemas contain$defs/$refcycles or root-levelanyOf.We built mcp-slim, a zero-dependency Python 3.10+ stdio proxy that sits between
BasicMCPClientand any stdio MCP server command:What it provides
$defs/$ref& flattens rootanyOf/oneOf/allOfbeforeMcpToolSpecbuilds Pydantic models, cuttingtools/listschema tokens by ~50% (or -98.7% with--lazyBM25 tool search).tools/calloutputs (-43%+tokens) while keeping JSON 100% valid and flatteningEmbeddedResourcetext blocks.--allow-tools/--deny-toolson bothtools/listandtools/calland redacts leaked secrets/tokens viaSecretGuard.Repository: https://github.com/SalyyS1/mcp-slim
If you use MCP tools with LlamaIndex agents, we would love your feedback (and a star on SalyyS1/mcp-slim if you find it useful)!
All reactions