Skip to content

Conversation

@aharvard
Copy link
Collaborator

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) becomes my_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:

  • Before: split('__')[0]my_server_local (wrong - missing trailing _)
  • After: 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 to extappsbasicserverreach_local_. MCP app resources now load correctly.

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'
Copilot AI review requested due to automatic review settings January 13, 2026 21:44
Copy link
Contributor

Copilot AI left a 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 McpAppWrapper to use lastIndexOf('__') instead of split('__')[0] to correctly handle extension names ending with underscores
  • Added comprehensive comment explaining the tool naming convention and why the fix is necessary

@aharvard aharvard requested a review from DOsinga January 13, 2026 21:47
Comment on lines +105 to +106
const delimiterIndex = toolCallName.lastIndexOf('__');
const extensionName = delimiterIndex === -1 ? '' : toolCallName.substring(0, delimiterIndex);
Copy link
Collaborator Author

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?

Copy link
Collaborator

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

Copy link
Collaborator

@DOsinga DOsinga left a 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

@DOsinga DOsinga merged commit 06dcb09 into main Jan 15, 2026
29 of 30 checks passed
@DOsinga DOsinga deleted the fix/mcp-app-extension-name-parsing branch January 15, 2026 13:26
zanesq added a commit that referenced this pull request Jan 15, 2026
…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)
lifeizhou-ap added a commit that referenced this pull request Jan 15, 2026
* main:
  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)
zanesq added a commit that referenced this pull request Jan 16, 2026
* '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)
  ...
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.

3 participants