Skip to content

[Server] Provide custom injection functionality #167

@lvluoyue

Description

@lvluoyue

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;
    }
}

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