-
Notifications
You must be signed in to change notification settings - Fork 2.4k
fix: correctly parse extension name from tool call for MCP apps #6482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Extension names can contain underscores (e.g., special characters like
parentheses are normalized to '_'). When an extension name ends with a
special character like 'my_server(local)', it becomes 'my_server_local_'.
The previous code used split('__')[0] which incorrectly split on the
first '__' occurrence. This fix uses lastIndexOf('__') to find the
actual delimiter between extension name and tool name.
Example: 'my_server_local___get_time' now correctly parses as:
- extension: 'my_server_local_'
- tool: 'get_time'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a bug in MCP app resource loading where extension names containing special characters (normalized to underscores) were incorrectly parsed from tool call names.
Changes:
- Fixed extension name extraction logic in
McpAppWrapperto uselastIndexOf('__')instead ofsplit('__')[0]to correctly handle extension names ending with underscores - Added comprehensive comment explaining the tool naming convention and why the fix is necessary
| const delimiterIndex = toolCallName.lastIndexOf('__'); | ||
| const extensionName = delimiterIndex === -1 ? '' : toolCallName.substring(0, delimiterIndex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DOsinga I think this will work for double parentheses as well.
Since the delimiterIndex is the position of the last _ _ occurrence, this should successfully trim off the tool name while keeping the parentheses-to-underscores conversion intact.
extension(yeah) -> extension_yeah_ __tool_name
extension((yeah)) -> extension__yeah__ __tool_name
Do you agree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eh yeah. but I dont think there's anything stopping authors from putting underscores in toolnames. I think longer term we should just not concat this and then take it apart again (this also makes extension names no unqiue after normalization). we should just pass the original names of extensions and tools around
DOsinga
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So sorry! I thought we were just randomly discussing. didnt mean to not approve
…ased * 'main' of github.com:block/goose: Fix popular topics not starting chat when clicked (#6508) fix[desktop]: deeplink ui repeat on refresh (#6469) fixed test compilation on main branch (#6512) fix: correctly parse extension name from tool call for MCP apps (#6482) fixed 0 token in openrouter steaming (#6493) feat(goose-acp): enable parallel sessions with isolated agent state (#6392) copilot instruction to flag prelease docs (#6504) docs: acp mcp support (#6491) feat: add flatpak support for linux (#6387)
* 'main' of github.com:block/goose: (28 commits) chore(deps): bump aiohttp from 3.13.0 to 3.13.3 in /scripts/provider-error-proxy (#6539) chore(deps): bump brotli from 1.1.0 to 1.2.0 in /scripts/provider-error-proxy (#6538) docs: temp correction for agent directory (#6544) chore: upgrade rmcp (#6516) docs: clarify directory in /documentation readme (#6541) Release 1.20.0 Standalone mcp apps (#6458) don't add escaping to the command field (#6519) Fix popular topics not starting chat when clicked (#6508) fix[desktop]: deeplink ui repeat on refresh (#6469) fixed test compilation on main branch (#6512) fix: correctly parse extension name from tool call for MCP apps (#6482) fixed 0 token in openrouter steaming (#6493) feat(goose-acp): enable parallel sessions with isolated agent state (#6392) copilot instruction to flag prelease docs (#6504) docs: acp mcp support (#6491) feat: add flatpak support for linux (#6387) fix(code_execution): serialize record_result output as JSON (#6495) perf(google): avoid accumulating thoughtSignatures across conversation history (#6462) fix(openai): make tool_call arguments optional and fix silent stream termination (#6309) ...
Summary
Fixes MCP app resource loading failures when extension names contain special characters that get normalized to underscores.
Problem
When an extension name ends with a special character (like parentheses), it gets normalized to an underscore. For example:
my_server(local)becomesmy_server_local_The previous code used
split('__')[0]to extract the extension name from a tool call name. This incorrectly split on the first__occurrence instead of the last one (which is the actual delimiter).For a tool call like
my_server_local___get_time:split('__')[0]→my_server_local(wrong - missing trailing_)lastIndexOf('__')→my_server_local_(correct)This caused MCP app resource requests to fail with "Extension not found" errors because the extension name didn't match.
Solution
Use
lastIndexOf('__')to find the delimiter between extension name and tool name, which is consistent with how the server parses tool names.Testing
Tested with an MCP extension named
extappsbasicserverreach(local)which normalizes toextappsbasicserverreach_local_. MCP app resources now load correctly.