Skip to content

[Server] Schema not removed after injecting SessionInterface #168

@luoyue712

Description

@luoyue712

Describe the bug
I noticed that $_session can be injected in tools, but it requires entering a session in the inspector. However, after entering it, it doesn't get overridden, but rather becomes SessionInterface.

To Reproduce

<?php

namespace app\mcp;

use Mcp\Capability\Attribute\McpTool;
use Mcp\Server\Session\SessionInterface;

class example
{
    #[McpTool(name: 'example_tool')]
    public function exampleTool(SessionInterface $_session): array
    {
        return [
            'status' => 'ok',
            'session_id' => $_session->getId()->toRfc4122(),
        ];
    }
}

Expected behavior
Support SessionInterface injection and remove related schema

Additional context

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    ServerIssues & PRs related to the Server componentbugSomething isn't working

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions