Skip to content

[Bug] FastMCPApp treats hash-shaped tool names as pre-addressed, breaking Prefab callbacks after composition #5866

Closed

Description

@BlueX888

Summary

A FastMCPApp backend tool whose user-chosen name looks like a hashed backend name (<12 lowercase hex>_<name>, e.g. abcdef012345_save) is treated as already identity-addressed. When the app is composed with a namespaced mount() or a provider namespace, the emitted Prefab payload keeps the bare name instead of the listed namespaced name, so the UI callback fails:

listed: ['ns_abcdef012345_save', 'ns_form']
refs:   ['abcdef012345_save']
failed: NotFoundError Unknown tool: 'abcdef012345_save'

The payload identity map even self-identifies: {"abcdef012345_save": "abcdef012345_save"}. The no-namespace provider variant fails the same way, while ordinary tool names work.

Reproduction (current main adf90b6, offline)

app = FastMCPApp("contacts")
@app.tool(name="abcdef012345_save")
def save(name: str) -> str: ...          # ordinary backend tool, hash-shaped name
@app.ui
def contacts_form() -> ...: ...          # references save via CallTool

server = FastMCP("host")
server.mount(app, namespace="ns")
# list tools -> ['ns_abcdef012345_save', ...]
# Prefab payload refs -> ['abcdef012345_save'] (should be ns_abcdef012345_save)
# call_tool('abcdef012345_save') -> NotFoundError

Root cause

fastmcp_slim/fastmcp/apps/app.py:77-85 (_prefix): any name matching parse_hashed_backend_name() is assumed pre-addressed without verifying that the digest is actually hash_tool(app_name, local_name). annotate_payload_identities then records a false self-identity, and rewrite_payload_tool_names (server/providers/prefab_payload.py:115-158) resolves get_tool_by_hash("abcdef012345", "save") to nothing and restores the stale bare name. After a mount/provider rename, that name is not callable.

Suggested fix

Treat a name as pre-addressed only when it equals hashed_backend_name(app_name, parsed_local_name); otherwise prefix it normally. Genuine pre-addressed names remain unchanged.

Tests

A fix with unit and integration tests is ready: the resolver maps a hash-shaped user name to the app address, a genuinely pre-addressed name stays unchanged, and a namespaced mount/provider emits the listed ref and executes the tool. I'll open the linked PR with red/green evidence.

Activity

  1. added
    bugSomething isn't working. Reports of errors, unexpected behavior, or broken functionality.
    serverRelated to FastMCP server implementation or server-side functionality.
    too-longExcessively verbose or unedited LLM output. Condense before triage.
    on Oct 19, 2026
  2. marvin-context-protocol commented on Oct 19, 2026

    @marvin-context-protocol
    Contributor

    Thanks for the report. This issue goes beyond what our contributor guidelines ask for — we just need a short problem description and an MRE. Please see our contributing guidelines and condense this issue. We'll triage it once it's trimmed down.

  3. Wilson0511 commented on Oct 20, 2026

    @Wilson0511
    Contributor

    Reproduced on current main with the issue's scenario, and verified the suggested direction: a name is treated as pre-addressed solely because it matches parse_hashed_backend_name(), without checking the digest is actually hash_tool(app_name, local_name).

    Branch ready with the fix + tests (carried forward from the author-closed #5867):

    • _prefix now passes a name through only when it equals hashed_backend_name(app_name, parsed_local_name); hash-shaped user names get a normal identity.
    • Red/green evidence: 3 tests fail on main (test_hash_shaped_name_is_still_given_an_identity + both TestHashShapedToolNames compose variants); 103 pass across tests/test_fastmcp_app.py and tests/server/providers/test_prefab_roundtrip.py with the fix.

    Happy to open the PR once assigned.

    🤖 Prepared with ZCode (AI agent) on behalf of Wilson0511

  4. added a commit that references this issue on Oct 27, 2026
    e54bc65
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working. Reports of errors, unexpected behavior, or broken functionality.serverRelated to FastMCP server implementation or server-side functionality.too-longExcessively verbose or unedited LLM output. Condense before triage.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions