Surface MCP tool-result _meta to the model, minus protocol-reserved keys (port from kimi-code) - #80712
Merged
Conversation
Contributor
૮ >ﻌ< ა ci reviewran on bba748f — Port from MoonshotAI/kimi-code#2596/#2600: surface MCP tool-
|
…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
force-pushed
the
kimi-code-port/mcp-meta-passthrough
branch
from
August 17, 2026 02:58
295d701 to
bba748f
Compare
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MCP tool results now surface the server
_metamapping 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_metawere invisible to the agent.Ported from MoonshotAI/kimi-code#2596 + #2600 (their
<mcp-structured-result>block), adapted to Hermes' existing JSON tool-output shape intools/mcp_tool.py.Changes
tools/mcp_tool.py:_make_tool_handlerresult assembly includes_meta(SDK exposes wire_metaas.meta); new_is_reserved_mcp_meta_key()/_strip_reserved_meta_keys()helpers implement the MCP spec key-name rules — a prefix is reserved when amodelcontextprotocolormcplabel 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
_metain tool outputCallToolResult.model_validate({..., "_meta": {...}})→.metapresent, filter verifiedInfographic