#6486 [Engine] serve: an mcp__ prefix added to a plain tool, or dropped from an MCP tool, is that tool

open · @Mr-Mungle · 0 commentaires · Sur GitHub

Server & APIAMD / HIPNVIDIA / CUDADocumentationWindowsLinux

Description

**Title:** `[Engine] serve: an mcp__ prefix added to a plain tool, or dropped from an MCP tool, is that tool`

## Problem and result

Some agent harnesses (here, Turnstone) declare their own tools bare (`tasks`, `web_fetch`, `memory`) and MCP tools as `mcp__server__tool`, in the same request. With Qwen3.8-Flash-Next (NVFP4 pack), the model often carries the `mcp__` prefix over to a plain tool and writes `<function=mcp__tasks>` for the declared `tasks`. Less often, it drops the prefix from an MCP tool (`server__tool`), or keeps the prefix and drops the server (`mcp__tool`). None of these is in the alias table, so the call stays text (#3075). The client never gets a call it can reject. It shows the turn as text, and the model has no error to learn from. The text-only call then stays in the conversation history, and the model copies it on later turns.

Observed in one deployment's conversation store (counts of `<function=NAME` occurrences, one Postgres dump):

| Written | Declared | Count |
|---|---|---|
| `mcp__tasks` | `tasks` | 16 |
| `mcp__web_fetch` | `web_fetch` | 15 |
| `mcp__memory` | `memory` | 5 |
| `mcp__close_workstream` | `close_workstream` | 4 |
| `mcp__list_workstreams` | `list_workstreams` | 2 |
| `server__tool` (prefix dropped) | `mcp__server__tool` | 5 |
| `mcp__tool` (server dropped) | `mcp__server__tool` | 2 |

Before: each of these is returned as content text. After: each resolves to the declared name, under the existing rule. An alias counts only when it is unambiguous, and a declared name always wins.

## Related discussion

None opened. This follows the existing spelling aliases: #3556 (namespace forms), #3796 (collapsed `__`), #5281 (bare last segment of an `mcp__` name) and #4751 (`tools.` / `functions.` prefixes). Happy to open an issue first if you'd rather agree the scope there.

## Approach

Three more aliases in `OutputParser.__init__`, built in the same table as the others:

- a plain name (no `__`, no `.`) → `mcp__<name>`
- `mcp__server__tool` → `server__tool`, and `mcp__tool` (the #5281 last segment with its prefix)

All five places that build a call already resolve through `self.aliases`, so nothing else changes. A server name that differs (`mcp__flies__read_file`, a different case) is not guessed. That matches #3796's rule that only a spelling of a declared name counts. A plain tool and an MCP member with the same name make `mcp__<name>` ambiguous, so it stays text. Dotted names are left to the existing namespace aliases. Requests whose calls already match a declared name behave exactly as before.

## Validation

**Passed:** (revision `3142b66b` + this patch, Linux, Python 3.13)
- `python -m unittest serve.test_tool_name_alias -v` (from `terminal/`): 20 tests OK, including 5 new tests in `McpPrefixDrift`. Streamed widths 0/1/3/5 are covered.
- The same command without the `frontend.py` change: the two new positive tests fail (10 subtests), and the negative tests pass. So the tests check the change.
- `serve.test_frontend` (26), `serve.test_server`, `serve.test_native_tool_parser` (11), `serve.test_tool_call_envelope` (11): OK.
- Windows 10, Python 3.14.8, 3142b66b + this patch: `python -m unittest serve.test_tool_name_alias -v` from terminal/ → Ran 20 tests, OK

**Failed:** none observed.

**Not run:** a live serve of this exact revision with a client. The live check was on an older checkout with an equivalent local patch: <!-- describe what you saw, e.g. fresh Turnstone coordinator session, no text-only calls over N turns -->. No engine, CUDA, HIP, SYCL or Metal code is touched, so no backend builds.

## Limits

- Typos in a server name are deliberately not resolved; the client has to declare names the model can copy.
- `mcp__` is the only prefix handled, because it's the convention observed. Other client prefixes would need their own evidence.

Sur le site

Liens install, modèles, releases.