Invalid value for 'tools': maximum number of items is 128
Component
VS Code extension
Description
When I add too many MCP server and try to use Reflection Beam model, it returns an error "Invalid value for 'tools': maximum number of items is 128."
Plugins
No response
Kilo version
Latest (I think)
Steps to reproduce
Just install a bunch of MCP servers and try to use Reflection beam
Screenshot and/or share link
Operating System
Windows 11
Terminal
Windows Terminal
I'd like to work on this. Each request sends every enabled tool to the model. session/tools.ts adds all tools from every connected MCP server to the built-ins, and resolveTools (session/llm/request.ts) only removes tools that are denied by permission or user.tools. Nothing counts or caps the result, so many MCP servers can push it past the provider's 128-tool limit.
Options:
-
Clear error. Count the tools before the request. If there are too many, fail with the count, the limit, and a hint to disable MCP servers or deny tools. Small and predictable, but the user fixes it by hand.
-
Automatic trim plus a warning. Keep built-ins first, then MCP tools in server order, up to the limit. Chat keeps working, but tools go silently missing, and which ones depends on server order. Needs a limit per provider or model.
-
Better use of existing controls. mcp.
.enabled: false and permission rules like " _*": "deny" already remove tools from the request. The gap is visibility, for example showing the tool count per server in MCP settings. -
Lazy loading or a tool-search tool. I found no existing mechanism, so this is the largest change.
I'd suggest starting with option 1, with the error text pointing to option 3. It works whichever direction you choose later. Which do you prefer? And if trimming is the way, should the limit be hardcoded per provider or come from model metadata?
Related: #15812 reports the same tool-count failure (a 126-tool limit) with a single MCP server, so one server exposing many tools can hit it too, not just many servers. The options above apply the same way.