Skip to content

Surface MCP tool-result _meta to the model, minus protocol-reserved keys (port from kimi-code) - #80712

Merged
teknium1 merged 1 commit into
mainfrom
kimi-code-port/mcp-meta-passthrough
Aug 17, 2026
Merged

teknium1 merged 1 commit into
mainfrom
kimi-code-port/mcp-meta-passthrough

Conversation

@teknium1

@teknium1 teknium1 commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

MCP tool results now surface the server _meta mapping to the model, with protocol-reserved keys filtered out. Previously the field was dropped entirely, so servers returning namespaced machine-readable contracts (validated payloads, browser-handoff URLs) in _meta were invisible to the agent.

Ported from MoonshotAI/kimi-code#2596 + #2600 (their <mcp-structured-result> block), adapted to Hermes' existing JSON tool-output shape in tools/mcp_tool.py.

Changes

  • tools/mcp_tool.py: _make_tool_handler result assembly includes _meta (SDK exposes wire _meta as .meta); new _is_reserved_mcp_meta_key() / _strip_reserved_meta_keys() helpers implement the MCP spec key-name rules — a prefix is reserved when a modelcontextprotocol or mcp label is followed by at least one more label (modelcontextprotocol.io/..., tools.mcp.com/...); vendor namespaces with a trailing reserved word (com.example.mcp/...) and unprefixed keys pass through. Non-serializable metadata drops the extras rather than failing the call.
  • tests/tools/test_mcp_structured_content.py: 8 new tests (passthrough, reserved-key filtering, all-reserved omission, combination with structuredContent, non-serializable, non-dict, predicate unit tests).

Validation

Before After
_meta in tool output dropped included, reserved keys filtered
tests/tools/test_mcp_structured_content.py 3 passed 11 passed
Real SDK check CallToolResult.model_validate({..., "_meta": {...}}).meta present, filter verified

Infographic

MCP _meta passthrough

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

૮ >ﻌ< ა ci review

ran on bba748f — Port from MoonshotAI/kimi-code#2596/#2600: surface MCP tool-

⚠️ Warnings

CI timings · View report · View job

Wall time 35m14s vs 8m (+340.4%). 13 job(s) slower, 7 faster, 4 unchanged.

  • Python tests / Run tests slice 12/12: +72.0s
  • Python tests / Run tests slice 7/12: -45.0s
  • Python tests / Run tests slice 1/12: +39.0s
  • Python tests / Run tests slice 4/12: -27.0s
  • Python tests / Run tests slice 5/12: +20.0s

OSV vulnerability scan · View job

5 known vulnerabilities found in pinned dependencies.

How to fix:

Review the findings in the Security tab. Update the affected dependencies if a patched version is available.

@alt-glitch alt-glitch added type/feature New feature or request tool/mcp MCP client and OAuth P3 Low — cosmetic, nice to have labels Aug 7, 2026
…eta to the model, minus protocol-reserved keys

MCP tool results carry a server _meta mapping (exposed as .meta by the
Python SDK) alongside structuredContent. Servers return namespaced
machine-readable contracts there (validated payloads, browser-handoff
URLs); Hermes previously dropped the field entirely, so that data was
invisible to the agent.

Now _meta is included in the JSON tool output, after filtering
protocol-reserved keys per the MCP spec's key-name rules: a prefix is
reserved when a modelcontextprotocol or mcp label is followed by at
least one more label (modelcontextprotocol.io/..., tools.mcp.com/...).
Vendor namespaces with a trailing reserved word (com.example.mcp/...)
and unprefixed keys pass through. Non-serializable metadata drops the
extras rather than failing the call.
@teknium1
teknium1 force-pushed the kimi-code-port/mcp-meta-passthrough branch from 295d701 to bba748f Compare August 17, 2026 02:58
@teknium1
teknium1 merged commit c031fec into main Aug 17, 2026
45 checks passed
@teknium1
teknium1 deleted the kimi-code-port/mcp-meta-passthrough branch August 17, 2026 05:08
teknium1 added a commit that referenced this pull request Aug 17, 2026
…scout-slate wave

Post-merge docs sweep for the Aug 16 scout slate. Two pages:

- mcp.md: tool-result sanitization section — invisible Unicode TAG chars
  (U+E0000-E007F) stripped from results/resources/descriptions (#80689);
  vendor _meta surfaced to the model minus protocol-reserved
  modelcontextprotocol/mcp prefixes (#80712)
- tools.md: tool result annotations section — signal-death exit notes
  (subprocess -signum definite, shell 128+signum hedged) (#78074); UTF-16
  read_file transcoding with disclosure hint and 10MB cap (#80717)

Security-policy docs (approvals/allowlist) intentionally untouched.
teknium1 added a commit that referenced this pull request Aug 17, 2026
…scout-slate wave

Post-merge docs sweep for the Aug 16 scout slate. Two pages:

- mcp.md: tool-result sanitization section — invisible Unicode TAG chars
  (U+E0000-E007F) stripped from results/resources/descriptions (#80689);
  vendor _meta surfaced to the model minus protocol-reserved
  modelcontextprotocol/mcp prefixes (#80712)
- tools.md: tool result annotations section — signal-death exit notes
  (subprocess -signum definite, shell 128+signum hedged) (#78074); UTF-16
  read_file transcoding with disclosure hint and 10MB cap (#80717)

Security-policy docs (approvals/allowlist) intentionally untouched.
lisajlau pushed a commit to lisajlau/hermes-agent that referenced this pull request Aug 20, 2026
…scout-slate wave

Post-merge docs sweep for the Aug 16 scout slate. Two pages:

- mcp.md: tool-result sanitization section — invisible Unicode TAG chars
  (U+E0000-E007F) stripped from results/resources/descriptions (NousResearch#80689);
  vendor _meta surfaced to the model minus protocol-reserved
  modelcontextprotocol/mcp prefixes (NousResearch#80712)
- tools.md: tool result annotations section — signal-death exit notes
  (subprocess -signum definite, shell 128+signum hedged) (NousResearch#78074); UTF-16
  read_file transcoding with disclosure hint and 10MB cap (NousResearch#80717)

Security-policy docs (approvals/allowlist) intentionally untouched.
bobaba76 pushed a commit to bobaba76/hermes-agent that referenced this pull request Aug 27, 2026
…scout-slate wave

Post-merge docs sweep for the Aug 16 scout slate. Two pages:

- mcp.md: tool-result sanitization section — invisible Unicode TAG chars
  (U+E0000-E007F) stripped from results/resources/descriptions (NousResearch#80689);
  vendor _meta surfaced to the model minus protocol-reserved
  modelcontextprotocol/mcp prefixes (NousResearch#80712)
- tools.md: tool result annotations section — signal-death exit notes
  (subprocess -signum definite, shell 128+signum hedged) (NousResearch#78074); UTF-16
  read_file transcoding with disclosure hint and 10MB cap (NousResearch#80717)

Security-policy docs (approvals/allowlist) intentionally untouched.
melon-xf added a commit to melon-xf/hermes-agent that referenced this pull request Sep 3, 2026
…scout-slate wave

Post-merge docs sweep for the Aug 16 scout slate. Two pages:

- mcp.md: tool-result sanitization section — invisible Unicode TAG chars
  (U+E0000-E007F) stripped from results/resources/descriptions (NousResearch#80689);
  vendor _meta surfaced to the model minus protocol-reserved
  modelcontextprotocol/mcp prefixes (NousResearch#80712)
- tools.md: tool result annotations section — signal-death exit notes
  (subprocess -signum definite, shell 128+signum hedged) (NousResearch#78074); UTF-16
  read_file transcoding with disclosure hint and 10MB cap (NousResearch#80717)

Security-policy docs (approvals/allowlist) intentionally untouched.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low — cosmetic, nice to have tool/mcp MCP client and OAuth type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants