Skip to content

fix(mcp): split invoke_tool into read/write/destructive dispatchers - #665

Merged
pcfreak30 merged 2 commits into
developfrom
feat/mcp-typed-invoke-dispatchers
Sep 2, 2026
Merged

fix(mcp): split invoke_tool into read/write/destructive dispatchers#665
pcfreak30 merged 2 commits into
developfrom
feat/mcp-typed-invoke-dispatchers

Conversation

@pcfreak30

@pcfreak30 pcfreak30 commented Sep 2, 2026

Copy link
Copy Markdown
Member

Replaces the single invoke_tool meta-tool with three typed invokers — invoke_read_tool, invoke_write_tool, invoke_destructive_tool — each admitting exactly one safety class and carrying matching tool annotations (read-only; mutating/open-world; destructive/open-world).

search_tools and describe_tool are unchanged, and describe_tool now names the dispatcher for each tool (invokeTool field); server instructions and guides direct agents to route by it. Each dispatcher enforces its safety class server-side and refuses out-of-class tools with a pointer to the right one.

The split satisfies directory rules that reject one dispatcher mixing safe and unsafe operations and require annotations to match real capabilities.


Summary

This PR replaces the single invoke_tool MCP meta-tool with three typed invoke dispatchers split by safety class: invoke_read_tool, invoke_write_tool, and invoke_destructive_tool.

Key changes

Typed invoke dispatchers

  • Replaced invoke_tool with three safety-class-specific tools:
    • invoke_read_tool — for read-only operations (marks readOnlyHint=true)
    • invoke_write_tool — for state-mutating operations (marks openWorldHint=true)
    • invoke_destructive_tool — for destructive/irreversible operations (marks destructiveHint=true, openWorldHint=true)
  • Each dispatcher rejects out-of-class tools with an error message pointing to the correct dispatcher, ensuring no single MCP tool straddles the safe/unsafe boundary that platform directory validators reject.

Routing improvements

  • describe_tool now returns an invokeTool field in ToolDetail naming the correct dispatcher for each tool, so agents never guess which dispatcher to call.
  • Added classifyEntry() to map a catalog entry's platform hints (destructive/readOnly/openWorld) to a safety class. Entries that are read-only but also declare openWorld are conservatively routed to the write dispatcher since the read contract would be contradictory.

Documentation & test updates

  • Updated all documentation (README, AGENTS.md, architecture docs, adapter instructions) to reference the new typed dispatchers.
  • Updated E2E test helpers to resolve the correct dispatcher via describe_tool's invokeTool field, with a cache to avoid repeated lookups.
  • Added TestOfficialInvokeClassGate to lock the split: each dispatcher admits only its own class and refuses the rest.
  • Updated server card metadata, MCP instructions, and wire annotation tests to reflect the new tool names and truthfully split safety hints.

This change makes the MCP tool surface's safety annotations truthful for platform directory validation while preserving the progressive-disclosure discovery workflow.

Replaces the single invoke_tool meta-tool with three typed invokers
(invoke_read_tool, invoke_write_tool, invoke_destructive_tool), each
admitting exactly one safety class with matching tool annotations.
describe_tool names each tool's dispatcher via a new invokeTool field
and the dispatchers enforce the class server-side.
@kody-ai

This comment has been minimized.

Comment thread internal/mcp/sdk_official.go
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

Code Coverage Report

Total Coverage: 50.1%

Generated from commit: 1fc557e
Repository: LumeWeb/pinner-cli

@kody-ai

kody-ai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug
Performance
Security
Business Logic

Access your configuration settings here.

@pcfreak30
pcfreak30 marked this pull request as ready for review September 2, 2026 07:00
@pcfreak30
pcfreak30 merged commit c757f15 into develop Sep 2, 2026
13 checks passed
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.

1 participant