Skip to content

Share with a friend shows raw "MCP error -32602: Tool grant_bot_to_friend not found" instead of the unavailable message #563

Closed

Description

@Birfy

Symptom (self-test, latest main 4f6a53d798f0)

Two isolated homes (@selftesta2.home / @selftestb2.home), mutual friends with live grants. After one side revokes its Bot grant, Sharing → Share with a friend fails with the raw MCP error:

flybot/social/share-with-friend: MCP error -32602: Tool grant_bot_to_friend not found

Expected

The handler already intends older Bot Social servers to degrade cleanly: grantBotToFriend should return { unavailable: true } and the UI should say "Bot Social needs an update to share with a friend. Invite links still work." (the #500/#516 contract). The REST fallback (POST /v1/bots/:id/grants/to-friend) should be attempted first; when it also 404s, the unavailable path should win.

Actual

The MCP tool-not-found error is not classified as unknown-tool, so no fallback runs and the raw MCP string is shown. isUnknownTool() matches unknown tool, no tool, method not found, unrecognized tool — but the server says MCP error -32602: Tool <name> not found, which matches none.

Evidence from this round:

  • production tools/list has no grant_bot_to_friend (it has list_bot_grants / revoke_bot_grant);
  • direct REST POST /v1/bots/bot_…/grants/to-friend returns 404 Route … not found;
  • isUnknownTool(new Error("MCP error -32602: Tool grant_bot_to_friend not found")) → false.

Steps to reproduce

  1. Start two isolated homes on latest main; make them friends so both have a grant (invite A→B, then B→A).
  2. Revoke A's Bot grant to B (social/revoke-grant), so B appears in A's share list again.
  3. social/share-friends { botId } → B is listed.
  4. social/share-with-friend { botId, home: "@selftestb2.home" } → raw MCP error above.

Scope / suggested fix

  • plugins/social/src/mcp-client.js: isUnknownTool should also treat Tool <name> not found and -32602 (JSON-RPC invalid params used by the production MCP server for a missing tool) as unknown-tool, so tryTool reaches the REST fallback and { unavailable: true }.
  • plugins/social/src/social.js: mapShareFriendError can map the same wording to the friendly unavailable message as a belt-and-braces guard.
  • Test: the existing Share a Bot with an existing friend without an invite link #500 test for a server without grant_bot_to_friend uses new Error("unknown tool"); add a case with the production wording MCP error -32602: Tool grant_bot_to_friend not found.

Note: the production Bot Social server still lacks the companion capability itself, so the share action cannot succeed until it ships; the FlyBot-side defect is the fallback/error path. No issue opened in the upstream repo.

Activity

  1. added
    bugSomething isn't working
    area:socialFriends, invites, grants, Bot Social
    self-testFiled by the product self-test routine (issues only)
    agent-readyMaintainer-approved spec: an agent may take it. Only maintainers set this; never in a template
    agent-workingAn agent has claimed this issue (the claim comment names the branch)
    on Oct 21, 2026
  2. self-assigned this
    on Oct 21, 2026
  3. Birfy commented on Oct 21, 2026

    @Birfy
    CollaboratorAuthor

    Triaged agent-ready (bug, area:social, from self-test). Reproduced the classification bug at the root: isUnknownTool() knows unknown tool / no tool / method not found / unrecognized tool, but the production server answers a missing tool with MCP error -32602: Tool <name> not found, so tryTool never takes the REST fallback and the raw MCP string reaches the UI.

    Branch: fix/563-share-with-friend-missing-tool (from main 4f6a53d7). Scope:

    • plugins/social/src/mcp-client.js — isUnknownTool also accepts Tool <name> not found, and -32602 only when the text names a missing tool (so an invalid params error that is not a missing tool still surfaces).
    • plugins/social/test/social.test.js — a minimal repro with the production wording: the REST fallback runs, an absent route reports unavailable, and social/share-with-friend shows the "needs an update … Invite links still work" sentence, not the raw error.
    • docs/subsystems/social.md + a changelog.d/563-…fixed.md fragment.

    I am not touching mapShareFriendError: once isUnknownTool recognises the wording, grantBotToFriend returns { unavailable: true } and the handler already maps that to the actionable sentence, so a second mapping would be unreachable code. The production server still lacks the capability itself, so sharing stays unavailable until it ships; this fixes the FlyBot-side fallback and message.

  4. removed
    agent-readyMaintainer-approved spec: an agent may take it. Only maintainers set this; never in a template
    agent-workingAn agent has claimed this issue (the claim comment names the branch)
    on Oct 21, 2026
  5. added a commit that references this issue on Oct 23, 2026
    23ea5e2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:socialFriends, invites, grants, Bot SocialbugSomething isn't workingself-testFiled by the product self-test routine (issues only)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions