SDK PHP

Agent frameworks and SDKs

Model Context Protocol SDK for PHP.

Your AI app calls the SDK PHP MCP server, which does the agent frameworks and SDKs work and sends the result back to the chat.

About SDK PHP

SDK PHP is a community MCP server from logiscape, filed in our directory under agent frameworks and sdks. Model Context Protocol SDK for PHP.

At a glance

Publisher
logiscape (community)
Runs
See the README for setup
Written in
PHP
License
MIT
GitHub stars
371

How to set up SDK PHP

  1. Follow the install steps in the SDK PHP README; it is written in PHP, so have that toolchain ready.
  2. Check the SDK PHP README for keys or settings; the registry lists none that SDK PHP requires.
  3. Add SDK PHP to Claude Code, Claude Desktop, VS Code or Cursor with the config in the setup box on this page.
  4. Restart the app or reload its MCP servers, then ask it to list the SDK PHP tools to confirm the connection.
  5. Run one read-only task with SDK PHP first, and keep your app asking before each tool call until the results look right.

SDK PHP compared with similar servers

  • Mcpsnoop by kerlenton has fewer GitHub stars than SDK PHP (369 against 371); both are community servers, and both run locally.
  • Everything Search by mamertofabian has more GitHub stars than SDK PHP (372 against 371); both are community servers, and both run locally.
  • Mikrotik by wiresage has fewer GitHub stars than SDK PHP (367 against 371); both are community servers, and both run locally.

Before you connect SDK PHP

  • Give SDK PHP its own API key or account with the smallest permissions the job needs, never an admin key.
  • Keep your AI app asking before each SDK PHP tool call until you trust what it does with them.
  • Treat text that SDK PHP fetches as data. Pages, files and messages can hold instructions written to steer an AI.
  • Read the open issues for SDK PHP on GitHub to see what breaks and how fast the maintainers reply.

Marketing use cases for SDK PHP

How marketing and sales teams put SDK PHP to work, by company size. Pick the size closest to yours and start SDK PHP on one use case.

Small business

  • A small business with a developer can use SDK PHP to build one focused agent, such as lead follow-up, without a big platform.
  • Technical founders can prototype marketing agents with SDK PHP and keep what works as a small, owned tool.
  • SDK PHP runs on your own computer, which keeps data local; it needs a little setup, so a small team should plan an hour for it.

Mid-market

  • Growth engineering teams can use SDK PHP to build agents that combine CRM, analytics and content tools behind one workflow.
  • Marketing ops can standardize on SDK PHP so every agent they ship has the same logging, approvals and error handling.
  • Start SDK PHP on one workflow with one owner, measure the time it saves, then roll it out to the wider team.

Enterprise

  • Enterprises can build on SDK PHP with their own identity, policy and evaluation layers, so agents meet the same bar as other software.
  • Platform teams can use SDK PHP to give business units a governed way to ship agents without each one starting from scratch.
  • SDK PHP is a community server, so have security review the code and pin a version before SDK PHP touches company data.

Need help becoming an AI-forward company?

We connect MCP servers and AI agents to your CRM, content and data, with the guardrails your team needs.

Contact us

SDK PHP README

From logiscape/mcp-sdk-php on GitHub, shared under its MIT license. Images are left out; the original has them.

README.md

Model Context Protocol SDK for PHP

This package provides a PHP SDK for the Model Context Protocol. 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

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, the stable-track baseline is empty, and additionally runs the draft-track suite validating the 2026-07-28 spec update. See Conformance Testing.

  • The SDK can demonstrate both a functional MCP client and MCP server with a single Composer command. See the Webclient Example.

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.
  • MCP Apps extension (SEP-1865), attach a host-rendered HTML UI to a tool with one ->ui(...) call. See the Apps guide.

The complete inventory, including OAuth 2.1 hardening, typed errors, and the feature-lifecycle deprecation registry, is in the CHANGELOG; API differences from v1 are covered in the Migration Guide.

Installation

You can install the v2 SDK via composer:

composer require logiscape/mcp-sdk-php
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

Creating an MCP Server

For detailed documentation and examples of MCP servers, see the Server Development Guide.

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

<?php

// An example server with a basic addition tool

require 'vendor/autoload.php';

use Mcp\Server\McpServer;

$server = new McpServer('example-mcp-server');

$server
    // Define a tool
    ->tool('add-numbers', 'Adds two numbers together', function (float $a, float $b): string {
        return 'Sum: ' . ($a + $b);
    })

    // Start the server
    ->run();

Save this as example_server.php

Creating an MCP Client

For detailed documentation and examples of MCP clients, see the Client Development Guide.

Here's how to create a client that connects to the example server and calls the addition tool:

<?php

// A basic example client that connects to example_server.php and calls a tool

require 'vendor/autoload.php';

use Mcp\Client\Client;

$client = new Client();

try {
    // Connect to the server over stdio
    $session = $client->connect('php', ['example_server.php']);

    // Call the add-numbers tool with two arguments
    $result = $session->callTool('add-numbers', ['a' => 5, 'b' => 25]);

    // Output the result
    echo $result->content[0]->text . "\n";

} catch (\Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
    exit(1);
} finally {
    $client->close();
}

Save this as example_client.php and run it:

php example_client.php

Examples

The examples/ directory contains a runnable example for every major SDK feature, stateless servers, dual-era client negotiation, Tasks, Apps, elicitation, HTTP clients, and OAuth, each designed to run from the directory where you installed the SDK. Its README doubles as a feature map of the SDK.

Some examples use monolog for logging, which can be installed via composer:

composer require monolog/monolog

MCP Web Client

The "webclient" directory includes a web-based application for testing MCP servers. It was designed to demonstrate an MCP client capable of running in a typical web hosting environment.

Setting Up The Web Client

To setup the web client, upload the contents of "webclient" to a web directory, such as public_html on a cPanel server. Ensure that the MCP SDK for PHP is installed in that same directory by running the Composer command found in the Installation section of this README.

Using The Web Client

Once the web client has been uploaded to a web directory, navigate to index.php to open the interface. To connect to the included MCP test server, enter php in the Command field and test_server.php in the Arguments field and click Connect to Server. The interface allows you to test Prompts, Tools, and Resources. There is also a Debug Panel allowing you to view the JSON-RPC messages being sent between the Client and Server.

Web Client Notes And Limitations

This MCP Web Client is intended for developers to test MCP servers, and it is not recommended to be made publicly accessible as a web interface without additional testing for security, error handling, and resource management.

OAuth Authorization

The HTTP server transport includes optional OAuth 2.1 support. For more details see the OAuth Authentication Example.

Documentation

For detailed information about the Model Context Protocol itself, visit the official documentation.

Project-specific documentation lives in this repository (see the documentation index for the full annotated list):

Document Purpose
Server Development Guide Building MCP servers with McpServer.
Client Development Guide Building MCP clients with Client / ClientSession.
Migration Guide Upgrading a project from v1 to v2.
Tasks Extension Guide Long-running tool calls (SEP-2663), server and client side.
Apps Extension Guide Host-rendered tool UIs (SEP-1865).
Examples Index A runnable example per major feature.
Testing Guide Unit tests, PHPStan, conformance, MCP Inspector, Claude Code, OpenAI.
Compatibility Guide cPanel / Apache / PHP-FPM notes and graceful-degradation rules.
Dependency Policy How dependencies are declared, bumped, and retired.
Label Scheme Issue labels aligned with the MCP SDK Working Group conventions.
Conformance Testing How the dual-track conformance harness works and the no-shortcut rule.

Project governance and process:

Document Purpose
CONTRIBUTING Local development setup, test stack, coding standards, versioning policy.
ROADMAP Direction, tier self-assessment against SEP-1730, and what we're working on.
CHANGELOG Structured release history.
SECURITY How to report vulnerabilities.
GOVERNANCE How decisions are made and how to become a trusted contributor.
SUPPORT Where to ask questions.
CODE_OF_CONDUCT Adopts Contributor Covenant 2.1 by reference; summarises the key sections.

Project Status

This SDK supports the latest MCP specification revision (2026-07-28, the "stateless core") from day one, alongside every earlier revision back to 2024-11-05, version negotiation and per-request era detection let one server or client interoperate across all of them.

See MCP SDK Tier Audit for an assessment against the SDK tier criteria and GOVERNANCE.md for how the project is maintained.

Release history is captured in CHANGELOG.md; what is shipping next is tracked under its [Unreleased] heading. See ROADMAP.md for the future goals and outlook of the project.

Credits

This PHP SDK was developed by:

  • Josh Abbott
  • Claude 3.5 Sonnet
  • Claude Opus 4.5
  • Claude Fable 5

Code reviews and refactoring done by Josh Abbott originally using OpenAI ChatGPT o1 pro mode, and later by OpenAI Codex using GPT-5.5 and GPT-5.6 Sol.

Special acknowledgement to Roman Pronskiy for simplifying the server building process with his convenience wrapper project: https://github.com/pronskiy/mcp

  • Mcp\Server\McpServer, adapted from Pronskiy\Mcp\Server
  • Mcp\Server\McpServerException, adapted from Pronskiy\Mcp\McpServerException

License

The MIT License (MIT). Please see License File for more information.

Questions about SDK PHP

What is the SDK PHP MCP server?

Model Context Protocol SDK for PHP. SDK PHP is maintained by logiscape on GitHub at logiscape/mcp-sdk-php, and works with AI apps that support the Model Context Protocol, such as Claude, Cursor and VS Code.

How do I install the SDK PHP MCP server?

SDK PHP doesn't publish a one-line install in the MCP registry, so follow the setup steps in its README on GitHub (logiscape/mcp-sdk-php). Like most servers, SDK PHP ends with a command or URL you paste into your AI app's MCP config.

Does SDK PHP need an API key?

The registry lists no required keys for SDK PHP. Check the SDK PHP README for optional settings, and expect a remote server to ask you to sign in the first time you connect.

Is SDK PHP an official MCP server?

No. SDK PHP is a community server maintained by logiscape. Community servers can be excellent; read the code and the open issues before you give SDK PHP access to company data.

What license is SDK PHP under?

SDK PHP is released under the MIT license, according to its GitHub repository. The license covers the code of SDK PHP; the service it connects to has its own terms.