Skip to content

Conversation

@EdibleTuber
Copy link

This commit fixes three critical bugs in the MCP (Model Context Protocol) integration that prevented MCP tools from being available to the LLM:

Bug #1: MCP server not added to internal list when toggled ON

  • Fixed in mcpChannel.ts line 283
  • When toggling an MCP server ON, the client connection was created but never stored in this.infoOfClientId[serverName]
  • This caused tool calls to fail silently because the client reference was missing
  • Solution: Added this.infoOfClientId[serverName] = clientInfo after creating the client

Bug #2: Tool naming system used random prefixes

  • Fixed in mcpService.ts line 202 and mcpChannel.ts (removed lines 232-234)
  • Original implementation used random 6-character prefixes (e.g., a1b2c3_read_file)
  • This made tools unpredictable and harder to debug
  • Solution: Replaced with consistent server name prefix using __ separator (e.g., filesystem__read_file)
  • Updated removeMCPToolNamePrefix() in mcpServiceTypes.ts to handle new format
  • Updated Settings.tsx to use centralized removeMCPToolNamePrefix() helper

Bug #3: Improved error handling in MCP channel

  • Fixed in mcpChannel.ts lines 109-122
  • Errors in call() method returned undefined instead of proper error responses
  • Solution: Return proper MCPToolErrorResponse for callTool command failures

Additional improvements:

  • Added comprehensive debug logging in mcpChannel.ts, mcpService.ts, prompts.ts, and chatThreadService.ts
  • Logging helps diagnose MCP integration issues and confirms tools are properly registered

Testing:
✅ MCP servers connect and show green status
✅ Tools are registered with predictable names
✅ Tools are callable and work correctly
✅ Tool calls route to the correct MCP server

🤖 Generated with Claude Code

This commit fixes three critical bugs in the MCP (Model Context Protocol)
integration that prevented MCP tools from being available to the LLM:

**Bug voideditor#1: MCP server not added to internal list when toggled ON**
- Fixed in mcpChannel.ts line 283
- When toggling an MCP server ON, the client connection was created but
  never stored in this.infoOfClientId[serverName]
- This caused tool calls to fail silently because the client reference
  was missing
- Solution: Added this.infoOfClientId[serverName] = clientInfo after
  creating the client

**Bug voideditor#2: Tool naming system used random prefixes**
- Fixed in mcpService.ts line 202 and mcpChannel.ts (removed lines 232-234)
- Original implementation used random 6-character prefixes (e.g.,
  a1b2c3_read_file)
- This made tools unpredictable and harder to debug
- Solution: Replaced with consistent server name prefix using __ separator
  (e.g., filesystem__read_file)
- Updated removeMCPToolNamePrefix() in mcpServiceTypes.ts to handle new
  format
- Updated Settings.tsx to use centralized removeMCPToolNamePrefix() helper

**Bug voideditor#3: Improved error handling in MCP channel**
- Fixed in mcpChannel.ts lines 109-122
- Errors in call() method returned undefined instead of proper error responses
- Solution: Return proper MCPToolErrorResponse for callTool command failures

**Additional improvements:**
- Added comprehensive debug logging in mcpChannel.ts, mcpService.ts,
  prompts.ts, and chatThreadService.ts
- Logging helps diagnose MCP integration issues and confirms tools are
  properly registered

**Testing:**
✅ MCP servers connect and show green status
✅ Tools are registered with predictable names
✅ Tools are callable and work correctly
✅ Tool calls route to the correct MCP server

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

Co-Authored-By: Claude <[email protected]>
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.

1 participant