Repository navigation
Description
Issue Summary
When opencode invokes downstream MCP tools, it appears not to forward request-scoped _meta metadata received from upstream clients.
This breaks a common Model Context Protocol (MCP) pattern where hidden runtime context is passed through _meta and propagated unchanged across tool calls.
Typical flow:
UI → opencode → downstream MCP server
The UI may attach contextual metadata in _meta, such as:
documentIdcontainerIdworkspaceId- session/auth context
- tracing information
However, when opencode calls a downstream tool, this metadata is not preserved, causing the downstream MCP server to lose important request context.
MCP Design Pattern
MCP intentionally separates tool inputs from runtime metadata:
| Field | Purpose |
|---|---|
arguments |
Inputs the model reasons about |
_meta |
Hidden runtime/application context |
This enables:
- keeping sensitive IDs hidden from the LLM
- preventing the model from inventing internal IDs
- passing workspace/session context
- propagating distributed tracing data
- sending runtime hints to tools
Downstream MCP servers may use or ignore _meta safely.
Expected Behavior
If _meta is included in an incoming request to opencode:
- opencode captures
_meta _metais stored in request-scoped context- all downstream
tools/callrequests forward the same_meta
Key properties:
_metaremains optional- existing behavior unchanged if
_metais absent - tool arguments remain separate from metadata
Example
Incoming request (UI → opencode)
{
"method": "tools/call",
"params": {
"name": "docuai_agent_tool",
"arguments": {
"user_request": {
"user_input": "Translate this document to French"
}
},
"_meta": {
"com.example/documentId": "doc_123",
"com.example/containerId": "cont_456"
}
}
}Expected downstream call (opencode → MCP server)
{
"method": "tools/call",
"params": {
"name": "translate_document_preserving_structure",
"arguments": {
"destinationLanguageThreeLetterCode": "fra"
},
"_meta": {
"com.example/documentId": "doc_123",
"com.example/containerId": "cont_456"
}
}
}FastMCP Compatibility
FastMCP servers already support accessing metadata through:
ctx.request_context.meta
So the missing piece appears to be client-side propagation in opencode, not server support.
Requested Change
Add request-scoped _meta propagation in opencode so that:
_metafrom upstream requests is captured- it persists through the agent execution lifecycle
- it is forwarded in all downstream
tools/callrequests
Why This Matters
Forwarding _meta enables reliable context propagation for:
- document identifiers
- workspace/container context
- session/auth hints
- distributed tracing
while keeping this data hidden from the LLM-visible tool schema.
Activity
github-actions commentedon Mar 10, 2026
This issue doesn't fully meet our contributing guidelines.
What needs to be fixed:
[FEATURE]:and the feature request template should be used.Please edit this issue to address the above within 2 hours, or it will be automatically closed.
If you believe this was flagged incorrectly, please let a maintainer know.
[-]Forward request-scoped MCP _meta from incoming opencode requests to downstream MCP tool calls[/-][+][FEATURE]: Forward request-scoped MCP _meta from incoming opencode requests to downstream MCP tool calls[/+]github-actions commentedon Mar 10, 2026
Thank you for updating the title to use the
[FEATURE]:prefix. However, this issue is still not compliant.What still needs to be fixed:
Please rewrite the issue in your own words, briefly and clearly. A short description (2–5 sentences) explaining what the problem is, what you expected, and what you observed is all that is needed. The ~200-word version you mentioned would be far more appropriate.
github-actions commentedon Mar 10, 2026
Thank you for updating the title to use the
[FEATURE]:prefix. However, this issue is still not compliant.What still needs to be fixed:
Please rewrite the issue body in your own words. A short description of 2–5 sentences explaining what the problem is, what you expected, and what you observed is all that is needed. The ~200-word version you mentioned would be far more appropriate.
Rajmehta123 commentedon Mar 10, 2026
@thdxr @palmamartin @vvarp @ndarilek Thank you for this amazing repo. Recommendation appreciated. I believe the summary of the feature is important to understand why _meta which is a standard in MCP metadata injection and how it can help in opencode
github-actions commentedon Mar 10, 2026
This issue has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.
Feel free to open a new issue that follows our issue templates.