Skip to content

Conversation

@mcowger
Copy link
Contributor

@mcowger mcowger commented Oct 22, 2025

fixes #3229

Context

Implement dynamic MCP native tool generation support.

Available MCP servers are enumerated for their published tools, and dynamic tool definitions are generated
in the form of use_mcp_tool___servername___toolname.

Implementation

  • Add helper functions to detect and parse dynamic MCP tool names
  • Normalize dynamic tools to standard use_mcp_tool format
  • Use triple underscores (___) as separator to allow underscores in tool names
  • Extract toolInputProps and convert to JSON string for MCP server compatibility
  • Renames properties called type to renamed_type internally before sending to model, because type is a reserved word for many parsers.
  • Update tool name generation in mcp_server.ts
  • Add test coverage for dynamic tool parsing

Screenshots

Screenshot 2025-10-21 at 10 31 00 PM

How to Test

Use an MCP server with JSON calling enabled. Ensure that MCP servers can be called, and that they produce expected results.

Get in Touch

mcowger

@changeset-bot
Copy link

changeset-bot bot commented Oct 22, 2025

🦋 Changeset detected

Latest commit: 312a863

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
kilo-code Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chrarnoldus
Copy link
Collaborator

hm, I get this error trying the GitHub MCP:

@mcowger
Copy link
Contributor Author

mcowger commented Oct 22, 2025

Got it. Lemme try that one and see where the bug is.

@mcowger
Copy link
Contributor Author

mcowger commented Oct 22, 2025

hm, I get this error trying the GitHub MCP:

Can you provide a prompt or model combo that had this result? I can't replicate this:

Screenshot 2025-10-22 at 9 08 51 AM

@chrarnoldus
Copy link
Collaborator

I got the error with OpenRouter and GPT-5 (other models also give errors, but generic ones).

Prompt doesn't matter, "say hi" will do.

@mcowger
Copy link
Contributor Author

mcowger commented Oct 22, 2025

I got the error with OpenRouter and GPT-5 (other models also give errors, but generic ones).

Prompt doesn't matter, "say hi" will do.

OK, I think I know whats up here. The MCP server defines a parameter called 'type'. The OpenAI spec doesn't mention any restrictions or reserved words for the contents of the parameters schema definition, but it definitely appears that at least OpenAI and SGlang barf on parameters called 'type'.

I'll need to think about how to handle this case.

…separator

- Add helper functions to detect and parse dynamic MCP tool names
- Normalize dynamic tools to standard 'use_mcp_tool' format
- Use triple underscores (___) as separator to allow underscores in tool names
- Update tool name generation in mcp_server.ts
- Add comprehensive test coverage for dynamic tool parsing
- Extract toolInputProps and convert to JSON string for MCP server compatibility
@mcowger
Copy link
Contributor Author

mcowger commented Oct 24, 2025

I don't particularly love this renaming solution @chrarnoldus - it feels hacky, but I don't really have a better idea. Open to suggestions.

I did confirm with qwen3-coder, haiku, GLM, and Sonnet 4.5, and with GH & Context7 MCPs

@chrarnoldus
Copy link
Collaborator

I'll try to think of other solutions as well, thanks for your work

@mcowger
Copy link
Contributor Author

mcowger commented Oct 25, 2025

I will say...it does work pretty reliable.

@mcowger
Copy link
Contributor Author

mcowger commented Oct 26, 2025

Closing in favor of #3288

@mcowger mcowger closed this Oct 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Model fails to call the mcp server correctly (Matt PR about native mcp server calls)

2 participants