TGViewer
Пых Пых @phpyh · 7.85K subscribers
Post #834 16K
Официальный PHP SDK для MCP

PHP Foundation, Anthropic и Symfony вместе работают над фреймворк-независимым PHP-SDK для MCP протокола!

1. Ставим: composer require mcp/sdk.

2. Размечаем код:

use Mcp\Capability\Attribute\McpTool;

final readonly class Calculator
{
#[McpTool(name: 'add_numbers')]
public function add(int $a, int $b): int
{
return $a + $b;
}
}


3. Готовим скрипт mcp-server.php:

#!/usr/bin/env php
<?php

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

use Mcp\Server;
use Mcp\Server\Transport\StdioTransport;

Server::make()
->withServerInfo('Calculator', '1.1.0', 'Basic Calculator over STDIO transport.')
->withDiscovery(__DIR__, ['.'])
->build()
->connect(new StdioTransport());


4. Прописываем сервер:

{
"mcpServers": {
"php-calculator": {
"command": "php",
"args": ["/absolute/path/to/your/mcp-server.php"]
}
}
}


Профит!

https://thephp.foundation/blog/2025/09/05/php-mcp-sdk/
https://github.com/modelcontextprotocol/php-sdk
thephp.foundation Announcing the Official PHP SDK for MCP The PHP Foundation — Supporting, Advancing, and Developing the PHP Language
  • 🔥 52
  • ❤ 18
  • 👍 10
  • 🤔 9
More from @phpyh
  1. Sep 15, 2026Сейчас один человек с AI может выполнять работу целого IT-отдела. Только хуёво
  2. Sep 12, 2026Спасибо за заявки! Всем напишу в понедельник. Осталось 1 место.
  3. Sep 11, 2026Хардкорный курс асинхронного PHP https://hardcourse.ru/php/async
  4. Sep 11, 2026Ещё полчасика надо — сайт готов, расписываю программу! 🙏
  5. Sep 10, 2026Краткое содержание: завтра в 12:00 открываю набор на Хардкорный курс асинхронного PHP с уч…
  6. Sep 10, 2026Post #1011
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →