mcp-sdk-php  by logiscape

PHP SDK for Model Context Protocol, enabling context provision for LLMs

Created 9 months ago
359 stars

Top 77.9% on SourcePulse

GitHubView on GitHub
Project Summary

This PHP SDK implements the Model Context Protocol (MCP) for integrating Large Language Models (LLMs) by standardizing context provision. It targets developers building AI integration solutions, enabling them to create MCP clients and servers using transports like stdio and HTTP, thereby separating context management from LLM interaction.

How It Works

The SDK provides a PHP implementation of the MCP specification, mirroring the design of the official Python SDK. It facilitates building MCP clients to connect to any MCP server and creating MCP servers to expose resources, prompts, and tools. The implementation handles MCP protocol messages and lifecycle events, supporting standard transports like stdio and HTTP for communication.

Quick Start & Requirements

  • Installation: composer require logiscape/mcp-sdk-php
  • Requirements: PHP 8.1+, ext-curl, ext-json, ext-pcntl (optional, recommended for CLI). monolog/monolog is optional for logging in examples.
  • Setup: Basic setup involves installing via Composer and running provided PHP examples.
  • Links: Official Documentation

Highlighted Details

  • Implements the 2025-03-26 revision of the MCP Specification.
  • Supports protocol version negotiation, JSON-RPC batching, and HTTP transport.
  • Includes a basic web client for testing MCP servers in web hosting environments.
  • Offers examples for both STDIO and HTTP transports.

Maintenance & Community

  • Developed by Josh Abbott, with additional debugging by Josh Abbott using ChatGPT.
  • Based on the original Python SDK for the Model Context Protocol.
  • No specific community links (Discord/Slack) or roadmap are provided in the README.

Licensing & Compatibility

  • License: MIT License (MIT).
  • Compatibility: Permissive MIT license allows for commercial use and integration with closed-source projects.

Limitations & Caveats

Some functionality may be incomplete, and implementations require thorough testing and security review before production use. The web client's connection strategy (re-establishing connections per request) is a workaround for typical PHP hosting limitations and may not be suitable for all use cases. An authorization framework based on OAuth 2.1 is planned but not yet implemented.

Health Check
Last Commit

3 weeks ago

Responsiveness

1 week

Pull Requests (30d)
2
Issues (30d)
3
Star History
9 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.