PHP SDK #118
Replies: 6 comments 10 replies
-
I've released the second alpha build of the MCP SDK for PHP, focusing mainly on client-side improvements. The biggest update is the introduction of a MCP Web Client capable of running in a standard web hosting environment. It features a web interface capable of connecting to a MCP Server, and running Prompts, Tools, and Resources with full message logging for debugging. Being able to run both a MCP Web Client and MCP Server via stdio in a standard cPanel account opens a wide range of potential applications. A major challenge is that many web hosting environments block long-running processes, so the connection between a MCP client and server wouldn't remain open between operations. To overcome this, I developed a separate wrapper class between the Web Client and the main Client class that initializes and closes the connection for each request. Important information can then be stored in a PHP session, which should meet the needs for the majority of use cases. I've also successfully connected a MCP Client running through PHP-CLI with the "Everything MCP Server" from the official servers repository, and plan to continue testing different types of MCP Servers with PHP-based clients. Other future steps include testing remote servers via SSE, and improving security, error handling, and resource management to prepare the SDK for production environments. |
Beta Was this translation helpful? Give feedback.
-
I've been continuing to improve and complete the functionality of the MCP SDK for PHP. The previous release focused on building PHP-based web clients that can connect to MCP servers. The latest release focuses more on the server side, so now PHP-based MCP servers can be built that successfully connect to other MCP clients, including the MCP Inspector and the Claude desktop app. My next step will be enabling remote MCP connections. I already have some foundational code in place for SSE connections on both the client and server side, but I've been waiting to see how the spec evolves before fully implementing and testing it. With the recent release of the 2025-03-26 spec, I'll start working on a PHP implementation of the authorization framework and the HTTP transport. I believe the HTTP transport will work more seamlessly in a typical web hosting environment than SSE, and was definitely a good choice for the protocol. It's been exciting to see the increased interest in the PHP SDK over the past few weeks, and the evolution of the MCP protocol in general. |
Beta Was this translation helpful? Give feedback.
-
I've made progress on implementing the 2025-03-26 revision of the MCP spec into the PHP SDK. New classes have been created to support the additional features, and I'm planning out a streamable HTTP transport with support for SSE and OAuth 2.1. I saw the note from @dsp-ant about working to make this the official PHP SDK, and that is definitely something that I would be happy to do. Please let me know what I need to do on my end. |
Beta Was this translation helpful? Give feedback.
-
@logiscape any chance this can be updated to work with Laravel 12 ? |
Beta Was this translation helpful? Give feedback.
-
I am pleased to announce the release of v1.1.0 of the PHP SDK. This version implements key changes in the 2025-03-26 revision of the MCP protocol, including the HTTP transport that enables remote MCP servers and clients. It takes a clean approach using cURL and native PHP functions, eliminating the need for other dependencies that were causing conflicts for some developers. The SDK includes an example MCP server that has been successfully tested in a standard cPanel web hosting environment. My next goal is to implement support for the OAuth authorization framework. I also have some framework in place to support SSE, but I believe the current HTTP transport and session management system will be the preferred way to implement MCP in most PHP environments. I'm also happy to work with the MCP community, and make this the official PHP SDK. If @dsp-ant or anyone on the MCP team want to reach me at josh@logiscape.com I'd be happy to discuss any steps I need to take on my end to make this happen. I appreciate the feedback, support, and contributions I've received from the community to make this update possible, and I'm excited to see where MCP goes from here. |
Beta Was this translation helpful? Give feedback.
-
The PHP SDK v1.2.0 release now supports OAuth Authorization for MCP Servers! It needs some more testing before using in production, but I've successfully deployed a MCP test server with authentication in a standard cPanel web hosting environment. It's been tested with both the MCP Inspector as well as OpenAI's Responses API. For step-by-step instructions on how I set this up, I created a MCP Server Authentication Guide for PHP The SDK follows the latest draft of the MCP Spec, where MCP servers have the role of a resource server. The next step will be testing it with a 3rd party OAuth service and then implementing OAuth support into the client side of the SDK. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Pre-submission Checklist
What would you like to share?
I've released an alpha build of a MCP SDK for PHP. I have working examples of both a client and server, tested in PHP 8.3 on both Windows and Linux.
The SDK has been built into a Composer package, making it easy to install. At this stage, my main focus has been laying a solid foundation of classes that fully implement the TypeScript schema of MCP. There should be a class for each feature as defined in the spec, but only the prompts/list demonstrated in my example has been tested. The other features may need minor tweaks and refactoring to get them working on a live server/client.
Currently only the stdio transport is fully implemented, but I have most of the groundwork in place for a SSE transport. It also only uses synchronous calls due to the complexity of implementing async in a way that will work cross-platform, but I hope to look into adding async in the future. Some of the groundwork for that is already in the code, and could probably be easily completed by a developer who is more familiar with PHP transports across different platforms (such as how blocking vs non-blocking is handled).
The PHP SDK was built following the general structure of the official Python SDK. I used Claude 3.5 Sonnet to write a draft version of the PHP code that implements the general functionality of the Python code, while also providing it with the TypeScript schema to ensure that the classes conform to the spec. I then did additional refactoring and debugging with ChatGPT o1 pro mode, along with carefully mapping out the code myself, to ensure all the classes fit together, and run properly in a PHP environment. There is still more work to be done before using the SDK in a production environment, but this should give a good starting point for anyone looking to use MCP in PHP.
Overall, I'm very impressed by what I've seen with the MCP protocol, and some of the use cases demonstrated by the community. PHP powers much of the web, and I believe this SDK can provide an easy and secure way to integrate LLMs with everything from personal blogs to large e-commerce platforms. I'm looking forward to any feedback or improvements the community may be able to add to the SDK, as well as seeing the creative ways it could be integrated with other PHP projects.
Relevant Links
GitHub repository: https://github.com/logiscape/mcp-sdk-php
Beta Was this translation helpful? Give feedback.
All reactions