PHPackages                             petstack/roxy-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. petstack/roxy-php

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

petstack/roxy-php
=================

PHP SDK for writing MCP (Model Context Protocol) handlers served by the roxy proxy. Object model, typed builders, elicitation and structured output support.

0.2.0(1mo ago)01BSD-2-ClausePHPPHP &gt;=8.4

Since Apr 8Pushed 1mo agoCompare

[ Source](https://github.com/petstack/roxy-php)[ Packagist](https://packagist.org/packages/petstack/roxy-php)[ Docs](https://github.com/petstack/roxy-php)[ RSS](/packages/petstack-roxy-php/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (2)Dependencies (8)Versions (3)Used By (0)

roxy-php
========

[](#roxy-php)

**PHP SDK for writing [roxy](https://github.com/petstack/roxy) upstream handlers.**

roxy is a high-performance MCP (Model Context Protocol) proxy written in Rust that bridges MCP clients to any backend handler. `roxy-php` is the official PHP library for writing those handlers — it gives you a typed, tested, object-oriented API instead of hand-rolling the internal JSON protocol.

With roxy-php you can stand up a production MCP server in a dozen lines of PHP.

Requires **PHP 8.4+**. Published under [BSD-2-Clause](LICENSE).

Table of contents
-----------------

[](#table-of-contents)

- [Why](#why)
- [Installation](#installation)
- [Quick start](#quick-start)
- [API styles](#api-styles)
    - [Functional style](#functional-style)
    - [Object-oriented style](#object-oriented-style)
- [Building results](#building-results)
- [Elicitation (multi-turn tool input)](#elicitation-multi-turn-tool-input)
- [Error handling](#error-handling)
- [Full API reference](#full-api-reference)
- [Running your handler with roxy](#running-your-handler-with-roxy)
- [Integrating into existing frameworks](#integrating-into-existing-frameworks)
    - [Symfony / Sylius](#symfony--sylius)
    - [Laravel](#laravel)
    - [Slim, Mezzio, Yii, Laminas (PSR-7)](#slim-mezzio-yii-laminas-psr-7)
    - [Magento 2](#magento-2)
    - [WordPress / WooCommerce](#wordpress--woocommerce)
    - [PrestaShop](#prestashop)
    - [Dependency injection into Tool subclasses](#dependency-injection-into-tool-subclasses)
- [Development](#development)
- [License](#license)

Why
---

[](#why)

Writing an MCP server by hand means dealing with JSON-RPC framing, session management, transport negotiation, and MCP-specific nuances like elicitation, structured output, and resource links. You don't actually care about any of that — you just want to expose some tools and resources to Claude, Cursor, or Zed.

roxy handles all of the protocol plumbing in Rust. roxy-php gives you a small, focused SDK on top: you register tools, resources, and prompts with typed builders, and roxy-php takes care of routing, serialization, error conversion, and the upstream JSON envelope.

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

[](#installation)

```
composer require petstack/roxy-php
```

You'll also need [roxy itself](https://github.com/petstack/roxy) installed and configured to point at your PHP handler. See the [main roxy README](https://github.com/petstack/roxy#installation) for installation options (Homebrew, install script, `.deb`, `.rpm`, musl static tarball).

Quick start
-----------

[](#quick-start)

Create `handler.php`:

```
