PHPackages                             ixc-soft/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. ixc-soft/mcp-sdk-php

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

ixc-soft/mcp-sdk-php
====================

Model Context Protocol SDK for PHP

v1.0.1(10mo ago)0502MITPHPPHP &gt;=7.4

Since Jul 1Pushed 10mo agoCompare

[ Source](https://github.com/IXC-Soft/mcp-sdk-php)[ Packagist](https://packagist.org/packages/ixc-soft/mcp-sdk-php)[ RSS](/packages/ixc-soft-mcp-sdk-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

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

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

English | [中文](README.zh-CN.md)

This package provides a PHP implementation of the [Model Context Protocol](https://modelcontextprotocol.io), allowing applications to provide context for LLMs in a standardized way. It separates the concerns of providing context from the actual LLM interaction.

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
- Handle all MCP protocol messages and lifecycle events

This SDK began as a PHP port of the official [Python SDK](https://github.com/modelcontextprotocol/python-sdk) for the Model Context Protocol. It has since been expanded to fully support MCP using native PHP functions, helping to maximize compatibility with most standard web hosting environments.

This SDK is primarily targeted at developers working on frontier AI integration solutions. Some functionality may be incomplete and implementations should undergo thorough testing and security review by experienced developers prior to production use.

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

[](#installation)

You can install the package 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)

Docker Development Environment
------------------------------

[](#docker-development-environment)

A Docker Compose configuration is included for easy development with PHP 7.4 and all required extensions.

> **Note:** While the package officially requires PHP 8.1+, this Docker configuration uses PHP 7.4 with the required extensions (curl and json) for specific development scenarios. For production use, please ensure you're using PHP 8.1 or higher.

### Starting the Docker Environment

[](#starting-the-docker-environment)

```
docker-compose up -d
```

This will start a PHP 7.4 server with curl and json extensions pre-installed.

### Verifying the Docker Environment

[](#verifying-the-docker-environment)

A test script is included to verify that the Docker environment is properly configured:

```
docker-compose exec php php docker-test.php
```

This will display information about the PHP version, installed extensions, and Composer setup.

### Running PHP Scripts in Docker

[](#running-php-scripts-in-docker)

```
docker-compose exec php php your-script.php
```

### Using Composer in Docker

[](#using-composer-in-docker)

```
docker-compose exec php composer install
docker-compose exec php composer require some/package
```

### Entering the Bash Shell for Manual Execution

[](#entering-the-bash-shell-for-manual-execution)

For manual execution of commands in the Docker environment:

```
docker-compose exec php bash
```

Once inside the container, you can run PHP scripts and Composer commands directly:

```
# Inside the container
php docker-test.php
composer install
php -v
```

### Accessing the Web Server

[](#accessing-the-web-server)

The Docker setup includes a simple web server accessible at:

```
http://localhost:8000

```

### Stopping the Docker Environment

[](#stopping-the-docker-environment)

```
docker-compose down
```

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

[](#basic-usage)

### Creating an MCP Server

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

Here's a complete example of creating an MCP server that provides prompts:

```
