Skip to content

[Server] Provide custom injection functionality #167

Description

@luoyue712

Is your feature request related to a problem? Please describe.
My goal is to apply McpTool annotations to controllers, but the framework uses custom injection, similar to how ClientGateway is injected in the SDK, which prevents it from working in controllers.This type of injection typically does not occur in the Container, as it is associated with the request.

Describe the solution you'd like
Provide custom injection functionality and expose it in Builder.

Describe alternatives you've considered
Rewrite the prepareArguments method and set the ReferenceHandler in the Builder.

Additional context
sample code:

<?php
namespace app\controller;

use Mcp\Capability\Attribute\McpTool;
use support\Request;

class UserController
{
    #[McpTool(name: 'hello')]
    public function hello(Request $request)
    {
        $default_name = 'webman';
        $name = $request->get('name', $default_name);
        return 'hello ' . $name;
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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