PHP SDK #118
logiscape
started this conversation in
Show and tell
PHP SDK
#118
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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