Skip to content

Conversation

@bb-c24
Copy link
Contributor

@bb-c24 bb-c24 commented Nov 11, 2025

Summary

Added meta parameter to addTool() and addResource() methods in the Server Builder to allow passing arbitrary metadata when manually registering tools and resources.

Motivation and Context

The internal array definitions for $tools and $resources already included meta: ?array<string, mixed> in their type definitions, but the corresponding addTool() and addResource() methods did not expose this parameter. This inconsistency meant that users could not pass metadata when manually registering tools and resources, even though the infrastructure to support it was already in place.

This change brings the public API in line with the internal data structures and provides feature parity with the discovery-based registration system.

How Has This Been Tested?

  • Verified that the parameter is properly added to both methods
  • Confirmed that the compact() calls include the new meta parameter
  • Checked that PHPDoc annotations are correctly updated

Breaking Changes

None. This is a backward-compatible change as the meta parameter is optional and defaults to null.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

This change only affects the addTool() and addResource() methods. The addResourceTemplate() and addPrompt() methods also have meta in their array definitions but were not modified in this PR. These could be addressed in a follow-up PR if needed for consistency.

@bb-c24 bb-c24 force-pushed the add_meta_to_add_tool branch from 8867289 to 54b5f8e Compare November 11, 2025 15:06
@bb-c24 bb-c24 changed the title 00000: Add meta parameter to addTool and addResource methods [Server] Add meta parameter to addTool and addResource methods Nov 11, 2025
Copy link
Member

@chr-hertel chr-hertel left a comment

Choose a reason for hiding this comment

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

Thank you @bb-c24!

@chr-hertel
Copy link
Member

Can you please sign your commit @bb-c24 - thanks already!

@bb-c24 bb-c24 force-pushed the add_meta_to_add_tool branch 2 times, most recently from a476c2e to c79115a Compare November 12, 2025 08:12
@bb-c24 bb-c24 force-pushed the add_meta_to_add_tool branch from c79115a to 824a31f Compare November 12, 2025 08:14
@bb-c24
Copy link
Contributor Author

bb-c24 commented Nov 12, 2025

@chr-hertel done, commit is now signed. Thank you.

@chr-hertel chr-hertel merged commit 8daca81 into modelcontextprotocol:main Nov 12, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants