Skip to content

fix: case-insensitive MCP server name lookup - #63

Merged
rockfordlhotka merged 3 commits into
mainfrom
copilot/fix-case-sensitive-server-lookup
Feb 20, 2026
Merged

fix: case-insensitive MCP server name lookup#63
rockfordlhotka merged 3 commits into
mainfrom
copilot/fix-case-sensitive-server-lookup

Conversation

Copilot AI commented Feb 20, 2026

Copy link
Copy Markdown
Contributor

LLMs frequently capitalize server names (e.g. OpenRouter) that are stored lowercase in config (e.g. openrouter), causing spurious "MCP server is not connected" errors and wasted LLM iterations.

Changes

  • McpBridgeService — initialize _clients, _serverConfigs, and _serverTools with StringComparer.OrdinalIgnoreCase so all bridge-side lookups are case-insensitive regardless of call source
  • McpManagementExecutor — extract TryGetServerName helper that normalizes server_name to lowercase; replaces the inline TryGetString call in mcp_get_service_details, mcp_invoke_tool, and mcp_unregister_server
private static bool TryGetServerName(Dictionary<string, object?> args, out string serverName)
{
    if (!TryGetString(args, "server_name", out serverName))
        return false;
    serverName = serverName.ToLowerInvariant();
    return true;
}

The bridge-side fix is the load-bearing one (handles any caller); the executor-side normalization is defense-in-depth ensuring the name is canonicalized before it leaves the agent process.

Original prompt

This section details on the original issue you should resolve

<issue_title>MCP server name lookup is case-sensitive, causing spurious tool failures</issue_title>
<issue_description>## Problem

When the agent calls mcp_get_service_details or mcp_invoke_tool, the server name lookup is case-sensitive. mcp_list_services returns server names in lowercase (e.g. openrouter), but the LLM frequently passes a capitalized variant (e.g. OpenRouter), which causes the tool to return Error: MCP server 'OpenRouter' is not connected even when the server is connected.

Observed in logs

Executing tool mcp_invoke_tool(... server_name=OpenRouter, tool_name=list_models ...)
Tool mcp_invoke_tool returned in 6ms: Error: MCP server 'OpenRouter' is not connected

Executing tool mcp_get_service_details(... server_name=OpenRouter)
Tool mcp_get_service_details returned in 7ms: Error: Server 'OpenRouter' is not connected

Executing tool mcp_get_service_details(... server_name=openrouter)   ← lowercase works
Tool mcp_get_service_details returned in 6ms: [...]

The agent wasted 2 extra LLM iterations (and context) before discovering the correct casing.

Fix

Normalize server_name to lowercase (or do a case-insensitive lookup) before resolving the MCP server in mcp_get_service_details, mcp_invoke_tool, mcp_unregister_server, and any other tool that accepts a server name parameter.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 20, 2026 11:35
… executor

Co-authored-by: rockfordlhotka <2333134+rockfordlhotka@users.noreply.github.com>
Co-authored-by: rockfordlhotka <2333134+rockfordlhotka@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix case-sensitivity in MCP server name lookup fix: case-insensitive MCP server name lookup Feb 20, 2026
Copilot AI requested a review from rockfordlhotka February 20, 2026 11:39
@rockfordlhotka
rockfordlhotka marked this pull request as ready for review February 20, 2026 21:53
@rockfordlhotka
rockfordlhotka merged commit b421766 into main Feb 20, 2026
2 checks passed
@rockfordlhotka
rockfordlhotka deleted the copilot/fix-case-sensitive-server-lookup branch February 20, 2026 21:56
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.

MCP server name lookup is case-sensitive, causing spurious tool failures

2 participants