Skip to content

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

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.

Activity

  1. added theissue type on Sep 1, 2025
  2. chr-hertel commented on Sep 1, 2025

    @chr-hertel
    Member

    Yup, true, that's know atm - focused on discovery first. I wanted to level up example for example in #5. So you can see there what makes sense to test :)

  3. changed the title [-]Basic example empty tools list[/-] [+][Server] (Re-)Implement Manual Registration of Capabilities via ServerBuilder[/+] on Sep 1, 2025
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

    bugSomething isn't working

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions