stacklok / stacklok/toolhive

Preserve per-item ResourceContents._meta in vMCP

Open
#6,190 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs-triage
Dominant language
Go
Stars
2.2k
Forks
300
Avg merge
1d 15h
Merged PRs (30d)
184

Description

Part of #5743. Surfaced in jhrozek's review of #6180.

Problem

The spec puts _meta on ResourceContents items too (it's the MCP-UI carrier), and mcpcompat models it (mcpcompat/mcp/resources.go), but vMCP drops it: vmcp.ResourceContent has no Meta field, so both the Legacy conversion (pkg/vmcp/conversion/content.go, ToMCPResourceContents/ConvertMCPResourceContents) and the Modern rebuild (pkg/vmcp/client/client.go modernReadResource) lose it. Legacy and Modern are equally blind, so there's no revision fork — but a backend that sets per-item meta (e.g. MCP-UI payloads) has it silently stripped.

Work

  1. Add Meta map[string]any to vmcp.ResourceContent (pkg/vmcp/types.go).
  2. Populate it in both client paths (Legacy legacyReadResource via conversion.FromMCPMeta on each item; Modern rebuild similarly).
  3. Forward it in the Serve-path conversion, with the same reserved-key strip every other egress gets (mcpparser.StripReservedMeta via conversion.ToMCPMeta) — a backend can smuggle reserved io.modelcontextprotocol/* keys at the item level too.
  4. Extend the meta-preservation tests to cover per-item meta on both revisions.

Related: #6027 (result-level resource _meta, shipped in toolhive-core v0.0.38 + #6180).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with vmcp.ResourceContent in pkg/vmcp/types.go, then trace legacy conversion in pkg/vmcp/conversion/content.go and modernReadResource in pkg/vmcp/client/client.go. Check legacyReadResource and the existing meta-preservation tests first. Done means per-item metadata survives both client revisions and Serve conversion, with reserved keys stripped on egress.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.