mcp-sdk-php  by logiscape

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

created 7 months ago
346 stars

Top 81.3% 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

1 week ago

Responsiveness

Inactive

Pull Requests (30d)
4
Issues (30d)
2
Star History
133 stars in the last 90 days

Explore Similar Projects

Starred by Didier Lopes Didier Lopes(Founder of OpenBB), Chip Huyen Chip Huyen(Author of AI Engineering, Designing Machine Learning Systems), and
2 more.

fastmcp by jlowin

2.1%
15k
Pythonic SDK for building Model Context Protocol (MCP) servers/clients
created 8 months ago
updated 22 hours ago
Feedback? Help us improve.