Download the PHP package prism-php/relay without Composer
On this page you can find all versions of the php package prism-php/relay. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download prism-php/relay
More information about prism-php/relay
Files in prism-php/relay
Package relay
Short Description A Prism tool for interacting with MCP servers
License MIT
Informations about the package relay
Relay
A seamless integration between Prism and Model Context Protocol (MCP) servers that empowers your AI applications with powerful, external tool capabilities.
Installation
You can install the package via Composer:
After installation, publish the configuration file:
Configuration
The published config file (config/relay.php) is where you'll define your MCP server connections.
Configuring Servers
You must define each MCP server explicitly in the config file. Each server needs a unique name and the appropriate configuration parameters:
Basic Usage
Here's how you can integrate MCP tools into your Prism agent:
The agent can now use any tools provided by the Puppeteer MCP server, such as navigating to webpages, taking screenshots, clicking buttons, and more.
Real-World Example
Here's a practical example of creating a Laravel command that uses MCP tools with Prism:
This command creates an interactive CLI that lets you input prompts that will be sent to Claude. The agent can use Puppeteer tools to browse the web, complete tasks, and return the results.
Transport Types
Relay supports multiple transport mechanisms:
HTTP Transport
For MCP servers that communicate over HTTP:
OAuth / Bearer Token Authentication
The MCP 2025-11-25 authorization spec defines an OAuth 2.1 flow for HTTP-based transports. Relay handles only the last step — attaching the token to every request. Your application is responsible for running the full OAuth flow and supplying the resulting access token at runtime.
What your application must handle
Before calling withToken(), your code must:
- Discover the authorization server — make an unauthenticated request to the MCP server and read the
WWW-Authenticateheader from the401response, or probe/.well-known/oauth-protected-resource. The response contains the authorization server URL. - Run the OAuth 2.1 authorization code flow — including PKCE (
S256code challenge is required by the spec) and theresourceparameter (RFC 8707) identifying the MCP server. - Exchange the code for a token and store/refresh it as needed. Tokens are short-lived; implement refresh token rotation.
[!NOTE] The spec covers this in detail: MCP Authorization — 2025-11-25.
Passing the token to Relay
Once you have a valid Bearer token, pass it to Relay at request time. The runtime token takes priority over any static api_key set in config.
When the MCP server rejects the token with HTTP 401, Relay throws AuthorizationException. Use this to trigger a re-authorization flow in your app:
[!NOTE] OAuth tokens are only supported with HTTP transport. Passing a token to a Stdio-configured server throws a
ServerConfigurationException. For Stdio servers, provide credentials via theenvconfig key instead.
STDIO Transport
For locally running MCP servers that communicate via standard I/O:
[!NOTE] The STDIO transport launches a subprocess and communicates with it through standard input/output. This is perfect for running tools directly on your application server.
[!TIP] The
envoption allows you to pass environment variables to the MCP server process. This is useful for configuring server behavior, enabling debugging, or setting authentication details.
Advanced Usage
Using Multiple MCP Servers
You can combine tools from multiple MCP servers in a single Prism agent:
Error Handling
The package uses specific exception types for better error handling:
License
The MIT License (MIT). Please see the License File for more information.
All versions of relay with dependencies
prism-php/prism Version >=0.93 ^0
laravel/framework Version ^11.0|^12.0|^13.0