Skip to content

Conversation

camilleislasse
Copy link

@camilleislasse camilleislasse commented Oct 8, 2025

Q A
Bug fix? yes
New feature? no
Docs? yes
Issues #755
License MIT

[MCP Bundle] Fix dependency injection and standardize invokable pattern

This commit fixes critical issues preventing MCP tools with constructor
dependencies from working and aligns the codebase with the official MCP SDK.

Changes:

  • Fix McpPass to use Reference objects for ServiceLocator registration Previously passed tag arrays directly, causing crashes when tools had constructor dependencies

  • Fix services.php to use Server::make() instead of Server::builder() The official mcp/sdk uses Server::make() returning ServerBuilder, not Builder class with builder() method

  • Migrate all demo MCP capabilities to invokable pattern The Bundle's registerAttributeForAutoconfiguration() only detects class-level attributes, not method-level. Changed to:

    • Tool: #[McpTool] on class + __invoke() method
    • Prompt: #[McpPrompt] on class + __invoke() method
    • Resource: #[McpResource] on class + __invoke() method
    • ResourceTemplate: #[McpResourceTemplate] on class + __invoke() method
  • Add LoggerInterface to CurrentTimeTool to demonstrate DI works

  • Update documentation examples to show invokable pattern

  • Improve McpPassTest to verify ServiceLocator uses References Previous tests only checked presence, not type of values

  This commit fixes critical issues preventing MCP tools with constructor
  dependencies from working and aligns the codebase with the official MCP SDK.

  Changes:
  - Fix McpPass to use Reference objects for ServiceLocator registration
    Previously passed tag arrays directly, causing crashes when tools had
    constructor dependencies

  - Fix services.php to use Server::make() instead of Server::builder()
    The official mcp/sdk uses Server::make() returning ServerBuilder,
    not Builder class with builder() method

  - Migrate all demo MCP capabilities to invokable pattern
    The Bundle's registerAttributeForAutoconfiguration() only detects
    class-level attributes, not method-level. Changed to:
    * Tool: #[McpTool] on class + __invoke() method
    * Prompt: #[McpPrompt] on class + __invoke() method
    * Resource: #[McpResource] on class + __invoke() method
    * ResourceTemplate: #[McpResourceTemplate] on class + __invoke() method

  - Add LoggerInterface to CurrentTimeTool to demonstrate DI works

  - Update documentation examples to show invokable pattern

  - Improve McpPassTest to verify ServiceLocator uses References
    Previous tests only checked presence, not type of values
@carsonbot carsonbot added Bug Something isn't working MCP Bundle Issues & PRs about the MCP SDK integration bundle Status: Needs Review labels Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working MCP Bundle Issues & PRs about the MCP SDK integration bundle Status: Needs Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants