Skip to content

Add support for _meta field in tool calls#68

Merged
ChrisJBurns merged 2 commits intomainfrom
issue-67
Jan 22, 2026
Merged

Add support for _meta field in tool calls#68
ChrisJBurns merged 2 commits intomainfrom
issue-67

Conversation

@yrobla
Copy link
Contributor

@yrobla yrobla commented Jan 22, 2026

Implements support for the optional _meta field in CallToolRequest as specified in the MCP specification (2025-11-25). The echo tool now accepts metadata in requests and echoes it back in responses, enabling validation of metadata propagation through MCP clients, proxies, and routers.

Common metadata use cases include request tracking (progressToken), client context, debugging, and testing metadata propagation through complex MCP architectures.

Fixes #67

Implements support for the optional _meta field in CallToolRequest as
specified in the MCP specification (2025-11-25). The echo tool now
accepts metadata in requests and echoes it back in responses, enabling
validation of metadata propagation through MCP clients, proxies, and
routers.

Common metadata use cases include request tracking (progressToken),
client context, debugging, and testing metadata propagation through
complex MCP architectures.

Fixes #67
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds support for the optional _meta field in tool call requests as specified in the MCP specification. The echo tool has been enhanced to accept metadata in requests and echo it back in responses, enabling validation of metadata propagation through MCP clients, proxies, and routers.

Changes:

  • Enhanced echoHandler to extract and echo back metadata from tool call requests
  • Added comprehensive test coverage for metadata handling including single field, multiple fields, nested metadata, and no metadata scenarios
  • Updated tool description to document metadata echoing capability
  • Added detailed documentation in README explaining metadata support, use cases, and providing JSON examples

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
cmd/yardstick-server/main.go Modified echoHandler to extract metadata from requests and return it in responses; updated tool description to document metadata echoing
cmd/yardstick-server/main_test.go Added three new test functions covering metadata echoing scenarios and updated comments in existing tests to clarify nil result behavior
cmd/yardstick-server/integration_test.go Updated concurrent request test logic to properly handle non-nil results with metadata; added clarifying comments
cmd/yardstick-server/README.md Added comprehensive documentation section explaining metadata support, use cases, standard fields, and included JSON request/response examples
Comments suppressed due to low confidence (1)

cmd/yardstick-server/main.go:71

  • When validation fails and an error result is returned, the metadata from the request is not preserved in the error response. Consider whether metadata should be echoed back in error cases as well, to maintain consistency in metadata propagation even when requests fail. If metadata should be preserved in errors, add the Meta field to the error result at line 68.
	if !validateAlphanumeric(params.Input) {
		return &mcp.CallToolResult{
			Content: []mcp.Content{&mcp.TextContent{Text: "input must be alphanumeric only"}},
			IsError: true,
		}, EchoResponse{}, nil

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@yrobla yrobla requested a review from ChrisJBurns January 22, 2026 11:42
@ChrisJBurns ChrisJBurns merged commit 5e8908e into main Jan 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for _meta field in tool calls according to MCP spec

3 participants