Skip to content

[Server] (Re-)Implement Manual Registration of Capabilities via ServerBuilder #16

@pronskiy

Description

@pronskiy

Describe the bug
I'm trying to implement the most basic mcp server, but the tools list is empty.

To Reproduce

<?php

require __DIR__ . '/../vendor/autoload.php';

use Mcp\Server;
use Mcp\Server\Transport\StdioTransport;
use Psr\Log\NullLogger;

Server::make()
    ->withLogger(new NullLogger())
    ->withServerInfo('Stdio Calculator', '1.1.0', 'Basic Calculator over STDIO transport.')
    ->withTool(function (float $a, float $b, string $operation = 'add'): float {
        return match ($operation) {
            'add' => $a + $b,
            'subtract' => $a - $b,
            'multiply' => $a * $b,
            'divide' => $a / $b,
            default => throw new InvalidArgumentException('Invalid operation'),
        };
    }, name: 'calculator', description: 'Perform basic math operations (add, subtract, multiply, divide)')
    ->build()
    ->connect(new StdioTransport());
npx @modelcontextprotocol/inspector php calc.php
Image

Expected behavior
There should be calculator tool in the list.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions