Skip to content

Conversation

@JAORMX
Copy link
Collaborator

@JAORMX JAORMX commented Nov 14, 2025

Summary

Fixes a critical bug in Virtual MCP Server where backend tool/resource/prompt names were not being translated correctly when forwarding requests to backends after conflict resolution.

Problem

When conflict resolution strategies rename capabilities, the vmcp backend client must translate the client-facing name back to the original backend name when forwarding requests.

Example scenario:

  1. Backend has tool named fetch
  2. Prefix conflict resolution renames it to fetch_fetch for clients
  3. Client calls fetch_fetch
  4. Router looks up fetch_fetch and finds backend target with OriginalCapabilityName="fetch"
  5. BUG: Backend client forwarded request with name fetch_fetch instead of fetch
  6. Backend returns error: unknown tool "fetch_fetch"

This affected:

  • Composite tool workflows referencing prefixed backend tools
  • Any vmcp deployment using conflict resolution strategies
  • All capability types (tools, resources, prompts)

Solution

Centralize capability name translation in the backend client using BackendTarget.GetBackendCapabilityName():

// Before (WRONG):
client.CallTool(ctx, target, "fetch_fetch", args)  // Backend doesn't know this name

// After (CORRECT):
backendName := target.GetBackendCapabilityName("fetch_fetch")  // Returns "fetch"
client.CallTool(ctx, target, backendName, args)  // Backend receives original name

Changes

  • Add name translation in CallTool(), ReadResource(), GetPrompt()
  • Remove redundant translation from handler factory
  • Add comprehensive documentation warning against direct field access
  • Include usage examples for GetBackendCapabilityName() method
  • Update test expectations to match new behavior

Testing

✅ All existing tests pass
TestBackendTarget_GetBackendCapabilityName covers all conflict strategies
✅ Works for tools, resources, and prompts

🤖 Generated with Claude Code

@JAORMX JAORMX force-pushed the fix/vmcp-backend-capability-name-translation branch from e2908bf to 4deb2ca Compare November 14, 2025 14:18
@codecov
Copy link

codecov bot commented Nov 14, 2025

Codecov Report

❌ Patch coverage is 6.66667% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.93%. Comparing base (e6cc263) to head (e397592).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/vmcp/client/client.go 0.00% 12 Missing ⚠️
cmd/vmcp/app/commands.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2587      +/-   ##
==========================================
- Coverage   54.95%   54.93%   -0.03%     
==========================================
  Files         305      305              
  Lines       28732    28739       +7     
==========================================
- Hits        15791    15787       -4     
- Misses      11532    11543      +11     
  Partials     1409     1409              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

When conflict resolution renames capabilities (e.g., prefix strategy
changes "fetch" to "fetch_fetch"), the backend client must translate
the client-facing name back to the original name when forwarding
requests to backends.

This fix centralizes name translation in the backend client by using
the `BackendTarget.GetBackendCapabilityName()` method for all capability
types (tools, resources, prompts).

Changes:
- Add name translation in CallTool(), ReadResource(), GetPrompt()
- Remove redundant translation from handler factory
- Update test expectations to match new behavior
- Add composite tools logging to config loader for visibility
- Document OriginalCapabilityName field with usage warnings
- Add comprehensive examples to GetBackendCapabilityName() method

The routing table already stores original capability names via
`OriginalCapabilityName` field, this fix ensures they're used correctly
when forwarding to backends.

Fixes composite tool execution where workflow steps reference prefixed
tool names but backends expect original names.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@JAORMX JAORMX force-pushed the fix/vmcp-backend-capability-name-translation branch from 4deb2ca to e397592 Compare November 14, 2025 15:15
@JAORMX JAORMX merged commit 1d3316f into main Nov 14, 2025
30 checks passed
@JAORMX JAORMX deleted the fix/vmcp-backend-capability-name-translation branch November 14, 2025 15:54
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.

4 participants