Download the PHP package dv-team/mcp-server without Composer
On this page you can find all versions of the php package dv-team/mcp-server. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dv-team/mcp-server
More information about dv-team/mcp-server
Files in dv-team/mcp-server
Package mcp-server
Short Description Basic and easy to use PHP based MCP Server
License MIT
Homepage https://github.com/dv-team/php-mcp-server
Informations about the package mcp-server
PHP MCP Server
This project demonstrates a simple PHP-based MCP Server (JSON-RPC) for handling requests that can respond immediately. It is designed for flexibility and can be adapted to various environments, such as database schema retrieval, prompt output, filesystem tasks, and more.
High-Level Goals
- Simple PHP and PHP-esque MCP Server for processes that can respond (near) immediately.
- STDIO sample for quick testing; no streaming support.
- Versatile usage: Suitable for a wide range of environments, including database, prompt handling, and filesystem operations.
Requirements
- PHP 8.2 or higher
- Composer
Installation
Usage
Implemented JSON-RPC methods
initialize(returnsprotocolVersion: 2025-03-26)notifications/initialized(accepted; no response)prompts/list,prompts/gettools/list,tools/callresources/list,resources/readresources/templates/list
STDIO server (main)
Logs are written to stdio–mcp.log (note the filename contains an en dash –).
Streamable-HTTP via supergateway (optional)
This server speaks STDIO only. If you need Streamable-HTTP, use the supergateway tool to bridge STDIO to HTTP while keeping the PHP server unchanged.
Short example (stdio → Streamable-HTTP):
The Streamable-HTTP endpoint defaults to http://localhost:8000/mcp. See the supergateway README for more options.
Streamable-HTTP bridge via src-http (Bun)
If you prefer a Bun-based Streamable-HTTP bridge (chunked HTTP), use the project in src-http/ to connect the PHP MCP CLI to an HTTP endpoint:
The Bun server exposes POST /mcp and forwards each request to the PHP CLI over STDIO. Configure OAuth2 and other options via .env (see src-http/.env.example). OAuth is enforced by default; set MCP_REQUIRE_AUTH=false to disable.
Optional tracing: set MCP_CLI_TRACE_STDOUT=true to echo MCP request/response lines to stdout.
Example servers
The examples/ folder is a separate Composer project. Install its dependencies first:
STDIO sample that logs requests/responses to examples/src/stdio–mcp.log:
Example: Registering Prompts
The server uses YAML front-matter to parse Markdown files and register them as prompts, as shown in examples/src/prompts-and-tools-cli.php:
Example: Registering Tools
Here are three simple tools you might register:
Example: Attribute-Based Tools
You can mark methods with attributes and let the AttributeToolRegistrar build the MCP tool definitions for you:
Descriptions on parameters are copied into the generated schema; when a property is not supplied in parametersSchema, the registrar infers the JSON Schema type and required flag from the method signature.
Tool Annotations
Tools may carry an optional annotations object whose properties are hints about the tool's behavior. The MCP spec defines the keys below; all are optional. Clients use them to render UI hints (e.g. a "destructive" badge) or to decide which tools to expose without user confirmation.
| Key | Type | Meaning |
|---|---|---|
title |
string | Human-readable title for the tool. |
readOnlyHint |
bool | If true, the tool does not modify its environment. Default: false. |
destructiveHint |
bool | If true, the tool may perform destructive updates. Only meaningful when readOnlyHint == false. Default: true. |
idempotentHint |
bool | If true, repeated calls with the same arguments have no additional effect. Only meaningful when readOnlyHint == false. Default: false. |
openWorldHint |
bool | If true, the tool may interact with an open world of external entities (e.g. web search). If false, its domain is closed (e.g. an in-memory tool). Default: true. |
Annotations are hints, not guarantees — never make trust decisions based on annotations received from an untrusted server. See the MCP specification for the canonical definition.
Pass annotations as a stdClass to MCPServer::registerTool() (cast an array with (object) [...] as shown in the examples) or as an associative array to #[MCPTool]. registerTool() also accepts an optional outputSchema parameter — a JSON-Schema object describing the tool's structured result — which is forwarded to the client alongside inputSchema.
The shipped JSON schema at schema/2025-11-25/schema.json is used by the test suite to validate that registered tools conform to the spec, annotations included.
Notes
- This server is intended for environments where immediate responses are required (no streaming support).
- For broader protocol coverage, including streaming, see
logiscape/mcp-sdk-php.
License
MIT License