Get the FREE Ultimate OpenClaw Setup Guide →

mcp-sdk

Model Context Protocol SDK for Client and Server applications in PHP

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio symfony-mcp-sdk composer require symfony/mcp-sdk

How to use

The Symfony MCP SDK provides a PHP library that implements the Model Context Protocol (MCP) to empower PHP applications (clients and servers) to expose and consume contextual data for plugins and AI interactions. This SDK helps you integrate MCP data models, serialize contextual information, and participate in the MCP ecosystem so that large language models can query a user’s context in a controlled, predictable way. Use it to build server-side endpoints or to embed MCP capabilities into your PHP services so that you can share user-related context like the latest orders, preferences, or session data.

To use the SDK in your project, install it via Composer and then instantiate the relevant MCP components per the documentation. You can define contexts, permissions, and serialization strategies, and then expose these contexts to clients or plugins that rely on MCP for enriched interactions. The library focuses on providing low-level MCP primitives, so you can tailor data access, caching, and security around your specific application needs.

How to install

Prerequisites:

  • PHP 7.4 or higher (or as required by your Symfony version)
  • Composer (composer.phar or global install)

Install the MCP PHP SDK:

composer require symfony/mcp-sdk

Optional (if you want to contribute or run tests):

  • PHPUnit for tests
  • Docker if you want an isolated environment

Usage example (basic):

<?php
require __DIR__ . '/vendor/autoload.php';

use Symfony\MCP\Context\ContextProvider;
use Symfony\MCP\Model\Context;

$provider = new ContextProvider();
$context = new Context(['user_id' => 42, 'latest_order' => 'order_123']);
$provider->registerContext($context);

// Expose or serialize context as MCP-compatible data when communicating with an LLM or plugin
$payload = $provider->toMcpPayload();

See the repository's documentation for detailed integration steps and advanced usage.

Additional notes

Notes:

  • This SDK is experimental; use in non-production environments with caution.
  • Check compatibility with your PHP version and Symfony components.
  • MCP data exposure should respect user permissions and privacy considerations.
  • If you plan to contribute, look for guidance in the main Symfony AI repository linked in the README.

Environment variables (if you adapt the example into a service):

  • MCP_BASE_URL: base URL for MCP interactions
  • MCP_API_TOKEN: authentication token for MCP endpoints

Common issues:

  • Composer installation problems can arise if your PHP extension set is incomplete.
  • Ensure autoloading is configured when integrating with legacy PHP codebases.

Related MCP Servers

Sponsor this space

Reach thousands of developers