TGViewer
PHP Digest PHP Digest @phpdigest · 8.18K subscribers
Post #345 8.9K

Forwarded from Пых (Валентин Удальцов)

Официальный 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
  • 🔥 48
  • 🤯 10
  • ❤ 9
  • 💩 4
  • 👍 3
More from @phpdigest
  1. Jul 8, 2026Первый официальный State of PHP опрос открыт: https://jb.gg/php-survey-2026 В сообществе у…
  2. Jun 16, 2026Swoole AOT переименовали в TypePHP https://mp.weixin.qq.com/s/eGrSd2g-88I4jm6KIdecSw Пока…
  3. Jun 9, 2026PHPverse 2026 🎉🐘 Трансляция из офиса JetBrains в Амстердаме в прямом эфире прямо сейчас…
  4. Jun 5, 2026🎙 PHPverse возвращается – 9 июня, 14:00 (11:00 UTC) https://lp.jetbrains.com/phpverse-202…
  5. Apr 23, 2026Команда Swoole работает над компилятором для PHP https://mp.weixin.qq.com/s/05I3xe4pgRJufS…
  6. Apr 1, 2026Дайджест PHP – Февраль-Март 2026 Подборка свежих новостей, инструментов, видео и материало…
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 →