Skip to content

feature: add _meta field to resource content types #585

@rabbah

Description

@rabbah

Problem Statement

The _meta field https://modelcontextprotocol.io/specification/2025-06-18/basic/index#meta is part of every resource type but has an incompatible type in the mcp-go struct definitions, and is not parsed for resource contents.

For example spec.

interface BlobResourceContents {
  _meta?: { [key: string]: unknown };
  blob: string;
  mimeType?: string;
  uri: string;
}

The type of _meta is a essentially a JSON dictionary.

This meta field is used by MCP-UI extensions, which allows servers to return interactive UI components (UIResources) to clients in addition to text or markdown, for example.

Proposed Solution

Updating the _meta field to the resource content types should be sufficient. This field is currently not parsed in ParseResourceContents which only extracts the standard MCP fields uri, mimeType, text, and blob. It ignores any optional field _meta.

There are currently two implementation so of the interface method isResourceContents:

func (TextResourceContents) isResourceContents() {}
func (BlobResourceContents) isResourceContents() {}

So handling the _meta field for these two is necessary.

MCP Spec Reference

Spec https://modelcontextprotocol.io/specification/2025-06-18/schema#resource

iinterface Resource {
  _meta?: { [key: string]: unknown };
  annotations?: Annotations;
  description?: string;
  mimeType?: string;
  name: string;
  size?: number;
  title?: string;
  uri: string;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions