Search by

dresscode / upgrade-mcp

david@grudl.com

👔 DressCode Upgrade for the MCP PHP SDK: rewrites code written for older versions of mcp/sdk to its current API, and reports the rest with what to write instead.

Package info

github.com/dg/dresscode-upgrade-mcp

Homepage

Type:dresscode-plugin

pkg:composer/dresscode/upgrade-mcp

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-master / 1.0.x-dev 2026-11-30 00:21 UTC

This package is auto-updated.

Last update: 2026-11-30 00:21:16 UTC


README

Latest Stable Version License

 

✅ Upgrades code for the MCP PHP SDK from 0.2 to today
✅ Moves every class of the namespace split of 0.10 to its new home
✅ Reports what needs a human, with what to write instead
✅ Checked against the code of every release

 

Upgrade an MCP server or client written in PHP without hunting for renames. Install this package, run dresscode upgrade, and code written for older versions of the MCP PHP SDK (mcp/sdk) is rewritten to the API of the version your project stands on:

- use Mcp\Capability\Attribute\McpTool;
- use Mcp\Server;
+ use Mcp\Server\Capability\Attribute\McpTool;
+ use Mcp\Server\Server;

- #[CompletionProvider(providerClass: CityProvider::class)]
+ #[CompletionProvider(provider: CityProvider::class)]

- ->addLoaders($loader)
+ ->addLoaders([$loader])

The package holds the data, what each version of the SDK renamed, moved or retired; the rewriting is done by DressCode, the PHP coding standard and upgrade tool, which comes with it.

 

Installation and first run

1️⃣ Install it: composer require --dev dresscode/upgrade-mcp
2️⃣ Upgrade the code: vendor/bin/dresscode upgrade
3️⃣ Read the diff, run your tests and PHPStan, and commit

The package brings DressCode along, and dresscode upgrade takes it as it finds it, with no configuration. Most of the rewrites need to know what a variable is, which DressCode asks your PHPStan, so the project needs phpstan/phpstan installed. The style of the code stays as it is: with a dresscode.neon, the upgrade keeps of its coding standard what the code already follows, and without one it changes nothing but the old API. Where it rewrote something, run it again, as the new code may hold more to upgrade.

To have every dresscode check and dresscode fix watch for the old API too, in CI or in a Git hook, turn the upgrade on in dresscode.neon; the upgrade is the set deprecations, with the types of the code:

typeAnalysis: phpstan

use:
	- deprecations

 

What gets upgraded

None of it is search and replace. DressCode asks PHPStan what each variable is, so registerTool() is rewritten where it is called on the registry of the SDK and nowhere else. What the package rewrites:

  • the namespace split of 0.10: Mcp\Server to Mcp\Server\Server, Mcp\Client to Mcp\Client\Client, Mcp\Capability\* and Mcp\Event\* under Mcp\Server, Mcp\JsonRpc\MessageFactory to Mcp\Schema\MessageFactory and the exceptions to the package that throws them, in imports, type declarations, attributes and doc comments,
  • renamed classes: Resource to ResourceDefinition, ArrayLoader to ReflectedElementLoader, Psr16StoreSession to Psr16SessionStore,
  • arguments that changed: providerClass: of #[CompletionProvider] to provider:, $payload of ScopePolicy::requiredFor() to $message, factories passed by name where 0.9 inserted a parameter before them, the dropped $isManual of the registry and the batch size of MessageFactory.

The rewritten code takes the shape of the file around it, or of your coding standard, if the configuration names one.

 

What is left to you

Where there is no replacement, DressCode does not guess. It reports the place and says what to do:

Class `Mcp\Exception\RuntimeException` is removed: use `RuntimeException` of `Mcp\Server\Exception`, `Mcp\Client\Exception` or `Mcp\Schema\Exception`, by the package the code calls, since mcp/sdk 0.10.
Method `Mcp\Server\ClientGateway::sample()` is deprecated: there is no replacement; protocol revision 2026-07-28 drops sampling; call the API of an LLM provider directly, since mcp/sdk 0.8.

An upgrade is a rewrite plus a list of what remains. Every such sentence is written as an instruction, so the list can be worked through by you or handed to an AI coding agent as it is.

 

Where the data come from

The SDK has no upgrade guide, so the data come from the items of its changelog marked as BC breaks and from the deprecations in its code, each checked against the code of the release that made the change. The data are also checked against the installed SDK, so a replacement that does not exist cannot get in, and a sample of old code must turn into the expected new code.

 

Versions covered

The SDK from its version 0.2 to the current one. The data apply only when your project has mcp/sdk, and only the sections of the versions it stands on: the lowest version the constraint in composer.json allows, or the version the key targets of the configuration names.

 

Limits

  • Most rewrites need PHPStan. dresscode upgrade does not run without it, and check and fix without typeAnalysis: phpstan rewrite only classes, functions and annotations.
  • DressCode runs on PHP 8.4 to 8.6. The package is installed into the project, so the project has to install on PHP 8.4 or newer.
  • The data fix the code, not its meaning. The SDK is not at 1.0 yet and most of its breaks change behavior: HTTP status codes, sessions, validation of arguments. The changelog of the SDK describes them. Run your tests after a fix.

 

Other ecosystems

package upgrades
dresscode/upgrade-nette every Nette library, most from 3.0
dresscode/upgrade-symfony the components and bridges of Symfony, from 6.0
dresscode/upgrade-laravel the Laravel framework from 6, and the attributes of Laravel 13
dresscode/upgrade-deegee Dibi and Texy
dresscode/upgrade-mcp the MCP PHP SDK

A package like these can be written for any library; the manual says how.

 

Development

The SDK is in require-dev, so the data are checked against its installed version:

  • php tests/check.php sdk lints upgrading/sdk.neon and runs its sample, tests/samples/sdk.code, comparing the result with .expected and .violations,
  • php tests/check.php sdk --update writes those two from the run; read the diff, it is what the data do,
  • vendor/bin/tester tests runs all of it.