Skip to content

Conversation

@aaron-chen-aips
Copy link

@aaron-chen-aips aaron-chen-aips commented Nov 24, 2025

Title

Validate the MCP server name after splitting MCP {serverName}-{toolName}, as some MCP tool has hyphen (default separator) in the toolName and Litellm proxy will take the first part as the server name

Relevant issues

Fixes #16908

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🐛 Bug Fix

Changes

@vercel
Copy link

vercel bot commented Nov 24, 2025

@aaron-chen-aips is attempting to deploy a commit to the CLERKIEAI Team on Vercel.

A member of the Team first needs to authorize it.

@aaron-chen-aips aaron-chen-aips changed the title Change default to double hyphen Change default MCP tool separator to double hyphen Nov 24, 2025
@aaron-chen-aips aaron-chen-aips changed the title Change default MCP tool separator to double hyphen [Bug Fix] Change default MCP tool separator to double hyphen Nov 24, 2025
@krrishdholakia
Copy link
Contributor

@aaron-chen-aips this feels a bit clunky and error prone, can we try another separator? e.g. / ? cc: @uc4w6c for feedback

@aaron-chen-aips
Copy link
Author

aaron-chen-aips commented Nov 25, 2025

@aaron-chen-aips this feels a bit clunky and error prone, can we try another separator? e.g. / ? cc: @uc4w6c for feedback

Hey thanks @krrishdholakia - of course, just not sure if it's used in the URL somewhere as / may break the routing
Also Claude code uses similar formatting like {serverName}__{toolName} so it won't conflict with single hyphen
image
image

@uc4w6c
Copy link
Contributor

uc4w6c commented Nov 25, 2025

@aaron-chen-aips
Thank you for your work.
Looking at the implementation here:
https://github.com/BerriAI/litellm/blob/main/litellm/proxy/_experimental/mcp_server/server.py#L1324

I was thinking that we could apply a similar approach when calling tools — i.e., if there is only one allowed_mcp_server, we can omit the prefix, and if there are multiple, we can extract the server name from the prefix.
That way, the current delimiter format could still work without changing it.

@aaron-chen-aips
Copy link
Author

@aaron-chen-aips Thank you for your work. Looking at the implementation here: https://github.com/BerriAI/litellm/blob/main/litellm/proxy/_experimental/mcp_server/server.py#L1324

I was thinking that we could apply a similar approach when calling tools — i.e., if there is only one allowed_mcp_server, we can omit the prefix, and if there are multiple, we can extract the server name from the prefix. That way, the current delimiter format could still work without changing it.

Hey thanks @uc4w6c - I am not sure this would solve the issue. My current situation is I have multiple MCP servers in the config and one of them having - in the tool name.
When the MCP client passing in only the tool name, even with your suggested fix, litellm will treat the first par as server name and throwing errors

@krrishdholakia
Copy link
Contributor

krrishdholakia commented Nov 26, 2025

can we just check if the split string actually exists as a valid server name?

@aaron-chen-aips
Copy link
Author

Thanks - updated the PR to check if split serverName exists @krrishdholakia @uc4w6c

@aaron-chen-aips aaron-chen-aips changed the title [Bug Fix] Change default MCP tool separator to double hyphen [Bug Fix] Validate the MCP server name after splitting MCP {serverName}-{toolName} Nov 26, 2025
@aaron-chen-aips
Copy link
Author

can we just check if the split string actually exists as a valid server name?

Actually just re-think on this, this is still not ideal, as from the screenshot, backstage has a tool named backstage-search

image

So it will pass the check, because backstage is also the server name, it will still treat backstage as server name and search name. So ideally still have a uncommon separator so it won't exist in the tool name

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.

[Bug]: MCP gateway doesn't work if the tool name contains hyphen

3 participants