PHPackages                             logiscape/mcp-sdk-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. logiscape/mcp-sdk-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

logiscape/mcp-sdk-php
=====================

Model Context Protocol SDK for PHP

v2.0.0(3w ago)367137.2k—9.4%516MITPHPPHP &gt;=8.1CI passing

Since Dec 22Pushed 3w ago10 watchersCompare

[ Source](https://github.com/logiscape/mcp-sdk-php)[ Packagist](https://packagist.org/packages/logiscape/mcp-sdk-php)[ RSS](/packages/logiscape-mcp-sdk-php/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (10)Dependencies (17)Versions (41)Used By (6)

Model Context Protocol SDK for PHP
==================================

[](#model-context-protocol-sdk-for-php)

[![CI](https://github.com/logiscape/mcp-sdk-php/actions/workflows/ci.yml/badge.svg)](https://github.com/logiscape/mcp-sdk-php/actions/workflows/ci.yml)[![MCP Conformance](https://github.com/logiscape/mcp-sdk-php/actions/workflows/conformance.yml/badge.svg)](https://github.com/logiscape/mcp-sdk-php/actions/workflows/conformance.yml)

Note

**This `main` branch contains v2 of the logiscape/mcp-sdk-php SDK.**

v2 adds day-one support for the MCP `2026-07-28` spec revision; upgrading from v1 is covered by the [Migration Guide](docs/migration-v2.md). For v1 code and documentation, see the [`1.x` branch](https://github.com/logiscape/mcp-sdk-php/tree/1.x).

This package provides a PHP implementation of the [Model Context Protocol](https://modelcontextprotocol.io). The primary goal of this project is to provide both an MCP server and an MCP client using pure PHP, making it easy to use in PHP/Apache/cPanel hosting environments with typical server configurations.

Overview
--------

[](#overview)

This PHP SDK implements the full MCP specification, making it easy to:

- Build MCP clients that can connect to any MCP server
- Create MCP servers that expose resources, prompts and tools
- Use standard transports like stdio and HTTP
- Interoperate with peers on any spec revision from `2024-11-05` through `2026-07-28` — version negotiation is built in

This SDK offers two major advantages for the MCP and PHP developer communities:

- This SDK features a 100% pass rate on the applicable required [MCP Conformance Tests](https://github.com/modelcontextprotocol/conformance) — the stable-track baseline is empty — and additionally runs the draft-track suite validating the `2026-07-28` spec update. See [Conformance Testing](conformance/README.md).
- The SDK can demonstrate both a functional MCP client and MCP server with a single Composer command. See the [Webclient Example](webclient/README.md).

New in v2
---------

[](#new-in-v2)

v2 is built around two headline features — day-one support for the MCP `2026-07-28` "stateless core" spec revision, and full support for the MCP Apps extension — delivered without giving up compatibility with any earlier revision:

- **`2026-07-28` stateless core** — no `initialize` handshake, no session ids: every request is self-contained, which is exactly the model that fits typical PHP web hosting (a fresh process per request). Includes `server/discover`, caching hints, request-metadata headers, `subscriptions/listen` streams, and multi-round-trip input gathering.
- **Dual-era negotiation** — servers detect each request's era and clients probe-then-fall-back automatically, so one codebase serves both modern (`2026-07-28`) and legacy (`2024-11-05` … `2025-11-25`) peers concurrently.
- **Tasks extension (SEP-2663)** — long-running tool calls return a task handle that clients poll, cancel, and feed input to; backed by a file-based store that works on shared hosting. See the [Tasks guide](docs/tasks.md).
- **MCP Apps extension (SEP-1865)** — attach a host-rendered HTML UI to a tool with one `->ui(...)` call. See the [Apps guide](docs/apps.md).

The complete inventory — including OAuth 2.1 hardening, typed errors, and the feature-lifecycle deprecation registry — is in the [CHANGELOG](CHANGELOG.md); API differences from v1 are covered in the [Migration Guide](docs/migration-v2.md).

Installation
------------

[](#installation)

You can install the v2 SDK via composer:

```
composer require logiscape/mcp-sdk-php
```

### Requirements

[](#requirements)

- PHP 8.1 or higher
- ext-curl
- ext-json
- ext-pcntl (optional, recommended for CLI environments)
- monolog/monolog (optional, used by example clients/servers for logging)

Basic Usage
-----------

[](#basic-usage)

### Creating an MCP Server

[](#creating-an-mcp-server)

For detailed documentation and examples of MCP servers, see the [Server Development Guide](docs/server-dev.md).

Here's a complete example of an MCP server that provides a simple tool:

```
