Skip to content

MCP: a guessed tool name gets the server's real names back; a sign-in page says to sign in again - #506

Merged
HazAT merged 1 commit into
HazAT:mainfrom
joseph-carino:up-mcp-hints
Dec 3, 2026
Merged

HazAT merged 1 commit into
HazAT:mainfrom
joseph-carino:up-mcp-hints

Conversation

@joseph-carino

Copy link
Copy Markdown
Contributor

What and why

Agents often guess MCP tool names. In my logs, 23 of 34 MCP failures were a guessed name, and one conversation made seven guesses in a row. Each guess got back the server's bare refusal ("Tool … is not exposed by this gateway"), so the agent guessed again or listed every tool. A gateway backend whose sign-in had lapsed answered with a parse error of an HTML page (Unexpected token '<'), and that didn't tell the agent what to do.

extensions/mcp/server.ts:

  • Unknown tool (unknownToolHint, toolNames): when a call fails and the server doesn't list that tool, the mcp tool lists the server's tools again (they may have changed since connecting) and adds their names to the error. That covers an error result and an McpError. The names that share the guess's prefix come first (gws_ for gws_docs_get), sorted by most shared words. It adds at most 30, then the match that lists the rest, e.g. and 13 more: mcp {server: "gateway", match: "^gws_"} lists them all. A known tool's bad-arguments error still carries its schema, as before.
  • Web page (returnedPage, pageHint): an error that is a web page, or a parse error of one, now says the gateway returned a web page, usually a sign-in page, and to sign in again (for a gateway backend, reconnect it in the gateway's dashboard), instead of the parse error.

The README's Tool section describes both.

How it was tested

  • New test in extensions/mcp/test/mcp.test.ts: "answers a guessed tool name with the server's real names, and a sign-in page with sign in again". The test server refuses unlisted tools the way Tool Gateway does, answers one tool with a parse error of a page, and another with a real text/html page. The test checks the prefix filtering, the 30-name cap with its match, the fallback to all tools when no prefix matches, and the sign-in hint for both kinds of page.
  • It fails against main's server.ts and passes with the change.
  • pnpm test extensions/mcp/: 2 files, 5 tests passed.
  • vp lint (type-aware, with type check) and vp fmt --check on the changed files: clean.
  • I didn't run the whole pnpm check or pnpm test:affected, or try it against a live gateway.

…a web page in reply says to sign in again

A guessed tool name (gws_docs_get) now gets the server's tool names back, those sharing the guess's prefix first and most shared words first, at most 30, with the match that lists the rest, after relisting in case the server's tools changed. An error that is a web page, or a parse error of one (Unexpected token '<'), says the gateway returned a page and to sign in again instead of the parse error.
@HazAT
HazAT merged commit 777365b into HazAT:main Dec 3, 2026
HazAT added a commit that referenced this pull request Dec 3, 2026
Daniel approved #506 without its sign-in-page detection: remove returnedPage/pageHint, its two test tools and the README sentence.

Ultimate-Conversation: 1377036
HazAT added a commit that referenced this pull request Dec 3, 2026
… abort

Review of the #496/#506 merge: when the tools list refreshed after the call found the tool, the error came back with no hint. toolHint now returns the schema whenever the tool is known, before or after the refresh, and passes the call's abort signal to listTools.

Ultimate-Conversation: 1377036
@HazAT

HazAT commented Dec 3, 2026

Copy link
Copy Markdown
Owner

Thanks! The unknown-tool hint merged: a guessed name relists the server's tools and returns the real names. We left out the sign-in-page hint because it guesses from the error text and replaces the server's own error, and we would rather pass that error through unchanged. @ultimate merged it after #496, with the tests for the page hint removed.

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.

2 participants