feat(mcp): budget the tools MCP servers put in front of the model - #110
Merged
Merged
Conversation
MCP was the largest standing-context line item kitbash did not measure — the one place where "we measure token cost" had an undefended hole. A skill body is statically countable, which is why context.budget can be enforced. An MCP server's real cost is not: it is the JSON schema of every tool the server exposes, and knowing that means asking the server — which for stdio means executing it. That is what the install gate exists to prevent, so kitbash does not connect, and does not print an estimate it cannot derive. What it counts exactly is what the manifest already states. Every tool in a declared allowlist is a tool definition carried for the whole session, so the allowlist is an exact floor. compile and doctor now report it, and say plainly that the token cost is unmeasured and why. A server declaring tools = ["*"] has no countable bound, so the total renders as "8+ (1 server(s) declare "*")" with a warning that it cannot be bounded, rather than folding into a total that would be wrong. max_mcp_tools in [policy] caps the declared total; a breach warns and fails --strict. The default is 100 — the only primary-source numeric limit across the clients (Windsurf documents it as a hard cap past which tools are dropped). The widely repeated Cursor "40 tool" limit is deliberately not encoded: it appears only in forum posts and blogs, never in Cursor's docs, and a tool whose pitch is measurement must not ship a folklore number. Adds 9 tests. 0.20.0.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The hole this closes
MCP was the largest standing-context line item Kitbash did not measure — the one place where "we measure token cost" had an undefended hole.
A skill body is statically countable, which is why
context.budgetcan be enforced at compile time. An MCP server's real cost is not: it's the JSON schema of every tool the server exposes, and knowing that means asking the server — which for stdio means executing it. That's exactly what the install gate exists to prevent. So Kitbash does not connect, and does not print an estimate it cannot derive.What it does count
Every tool in a declared allowlist is a tool definition the agent carries for the whole session, so the allowlist is an exact floor:
Reported on every
compileand bydoctor.A server declaring
tools = ["*"]has no countable bound, so the total renders as8+ (1 server(s) declare "*")and warns that it cannot be bounded — rather than folding into a total that would be wrong.Enforcement
max_mcp_toolsin[policy]caps the declared total. A breach warns and fails--strict.The default is 100 — the only primary-source numeric limit found across the clients (Windsurf documents it as a hard cap past which tools are dropped).
The widely-repeated Cursor "40 tool" limit is deliberately not encoded: it appears only in forum posts and third-party blogs, never in Cursor's own docs. A tool whose pitch is measurement must not ship a folklore number.
9 new tests; suite, typecheck, site
--checkand bench gate all green. Ships as 0.20.0.