Summary
McpPool::parse_prefixed_name in crates/tui/src/mcp.rs uses split_once('_')
to decompose mcp_{server}_{tool} names. When a server name itself contains
underscores — e.g. my_db — the parser splits at the wrong boundary, routing
the call to a non-existent server.
Steps to reproduce
- Configure two MCP servers in
~/.codewhale/mcp.json:
{
"servers": {
"db": { "command": "npx", "args": ["-y", "mcp-db-server"] },
"my_db": { "command": "npx", "args": ["-y", "mcp-db-server"] }
}
}
- Start codewhale and invoke the tools:
mcp_db_execute_sql → works correctly (server=db, tool=execute_sql)
mcp_my_db_execute_sql → fails with "MCP server 'my' not available"
Expected behavior
mcp_my_db_execute_sql should route to server my_db, tool execute_sql.
Actual behavior
parse_prefixed_name strips mcp_ then calls split_once('_'), yielding:
| Tool name |
Server (parsed) |
Tool (parsed) |
Correct? |
mcp_db_execute_sql |
db |
execute_sql |
✅ |
mcp_my_db_execute_sql |
my |
db_execute_sql |
❌ |
The first _ inside the server name is mistaken for the server/tool delimiter.
Root cause
In crates/tui/src/mcp.rs, line 2248:
let Some((server, tool)) = rest.split_once('_') else { ... };
The naming convention mcp_{server}_{tool} uses a single underscore _ as
both the delimiter and a legal character in sanitized server names. There
is no way for split_once to distinguish the two.
Impact
- Any MCP server whose name contains
_ (e.g. my_db, prod_pg, data_warehouse)
produces tools that cannot be called.
- This is a silent failure: the error says "server not available", not "name
parsed incorrectly".
- The sibling
crates/mcp/src/lib.rs does not have this bug — it uses
mcp__{server}__{tool} with double-underscore delimiters and
splitn(2, "__"), which handles embedded underscores correctly.
Affected files
crates/tui/src/mcp.rs — all_tools (line 2096), parse_prefixed_name
(line 2243), all_resources, all_resource_templates
crates/tui/src/core/engine/dispatch.rs — mcp_tool_is_read_only,
mcp_tool_is_parallel_safe
crates/tui/src/core/engine/turn_loop.rs — MCP tool identification
Related
crates/mcp/src/lib.rs uses qualify_tool_name / parse_qualified_tool_name
with mcp__server__tool double-underscore format — no bug there.
Environment
- OS: Windows 11
- codewhale version: codewhale 0.8.53 (8dff2f7)
- Install method: release binary
- Model/provider: deepseek-v4-pro / deepseek
- Terminal app: Windows Terminal
- Shell: PowerShell
Summary
McpPool::parse_prefixed_nameincrates/tui/src/mcp.rsusessplit_once('_')to decompose
mcp_{server}_{tool}names. When a server name itself containsunderscores — e.g.
my_db— the parser splits at the wrong boundary, routingthe call to a non-existent server.
Steps to reproduce
~/.codewhale/mcp.json:{ "servers": { "db": { "command": "npx", "args": ["-y", "mcp-db-server"] }, "my_db": { "command": "npx", "args": ["-y", "mcp-db-server"] } } }mcp_db_execute_sql→ works correctly (server=db, tool=execute_sql)mcp_my_db_execute_sql→ fails with "MCP server 'my' not available"Expected behavior
mcp_my_db_execute_sqlshould route to servermy_db, toolexecute_sql.Actual behavior
parse_prefixed_namestripsmcp_then callssplit_once('_'), yielding:mcp_db_execute_sqldbexecute_sqlmcp_my_db_execute_sqlmydb_execute_sqlThe first
_inside the server name is mistaken for the server/tool delimiter.Root cause
In
crates/tui/src/mcp.rs, line 2248:The naming convention
mcp_{server}_{tool}uses a single underscore_asboth the delimiter and a legal character in sanitized server names. There
is no way for
split_onceto distinguish the two.Impact
_(e.g.my_db,prod_pg,data_warehouse)produces tools that cannot be called.
parsed incorrectly".
crates/mcp/src/lib.rsdoes not have this bug — it usesmcp__{server}__{tool}with double-underscore delimiters andsplitn(2, "__"), which handles embedded underscores correctly.Affected files
crates/tui/src/mcp.rs—all_tools(line 2096),parse_prefixed_name(line 2243),
all_resources,all_resource_templatescrates/tui/src/core/engine/dispatch.rs—mcp_tool_is_read_only,mcp_tool_is_parallel_safecrates/tui/src/core/engine/turn_loop.rs— MCP tool identificationRelated
crates/mcp/src/lib.rsusesqualify_tool_name/parse_qualified_tool_namewith
mcp__server__tooldouble-underscore format — no bug there.Environment