Skip to content

Conversation

@bb-c24
Copy link
Contributor

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

Summary

Fix Tool constructor call in ArrayLoader where the meta parameter was incorrectly passed to the icons position due to missing icons argument. Also adds icons support to Builder::addTool() for consistency with the Tool schema.

Motivation and Context

The Tool class constructor expects 6 parameters: name, inputSchema, description, annotations, icons, and meta. However, ArrayLoader was only passing 5 arguments, causing the meta value to be assigned to the icons parameter instead. This bug would prevent metadata from being properly attached to manually registered tools.

Additionally, the Builder::addTool() method didn't support the icons parameter, even though the Tool schema includes it. This inconsistency meant users couldn't specify icons when manually registering tools.

How Has This Been Tested?

  • Verified that all parameters are now correctly mapped to their intended positions
  • Confirmed that the compact() call in Builder includes all necessary keys
  • Checked that null coalescing operators are used consistently for optional parameters

Breaking Changes

Potentially breaking: The Builder::addTool() method signature has changed. A new icons parameter has been added between inputSchema and meta.

Impact: If users were calling addTool() with positional arguments and passing meta, they will need to add null for the icons parameter or switch to named arguments.

Before:
->addTool($handler, 'name', 'desc', $annotations, $schema, $meta)After (positional):
->addTool($handler, 'name', 'desc', $annotations, $schema, null, $meta)After (named - recommended):
->addTool($handler, name: 'name', meta: $meta)## 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

Changes made:

  1. Fixed ArrayLoader::load() to pass all 6 parameters to Tool constructor using named arguments
  2. Added null coalescing operator for annotations parameter to prevent undefined key warnings
  3. Added icons parameter to Builder::addTool() method signature
  4. Updated PHPDoc type definitions in both Builder and ArrayLoader to include icons
  5. Used named arguments in Tool instantiation for better clarity and maintainability

The use of named arguments makes the code more maintainable and prevents similar parameter ordering bugs in the future.

Previously, the meta parameter was incorrectly passed to the icons position
due to missing icons argument. Also adds icons support to Builder::addTool()
for consistency with the Tool schema.
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.

Thanks @bb-c24!

@chr-hertel chr-hertel merged commit 63ffeed 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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants