phpclaw / phpclaw-mcp
MCP (Model Context Protocol) server adapter for phpClaw. Expose any PHP app's tools to Claude Desktop, Claude Code, Cursor, and other MCP clients.
Requires
- php: ^8.1
- phpclaw/phpclaw: ^0.1
Requires (Dev)
- laravel/pint: ^1.0
- phpstan/phpstan: ^1.0
- phpunit/phpunit: ^10.0|^11.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
This is a read-only mirror, auto-published from
phpclaw-monorepo. Please open issues and pull requests there, not here.
Expose any phpClaw app as an MCP server.
Your existing ToolRegistry, over JSON-RPC 2.0, zero changes to your tools.
Connect Claude Desktop, Claude Code, Cursor, Windsurf, or Zed directly to your PHP tools. phpClaw MCP wraps whatever ToolRegistry you've already built and speaks the Model Context Protocol on top of it.
Writing a raw MCP server from scratch means implementing JSON-RPC framing, transports, auth, and rate limiting yourself, on top of re-solving the exact prompt-injection problem phpClaw's guards already solve. This package is that work, done once.
Quick start
composer require phpclaw/phpclaw-mcp
Create a stdio server entry script (mcp-server.php): register your tools, then hand the registry to CliRunner:
<?php require 'vendor/autoload.php'; use PhpClaw\Mcp\Generic\CliRunner; use PhpClaw\Tools\ToolRegistry; $registry = new ToolRegistry(); $registry->register([/* your tools */]); CliRunner::run($registry);
Run php mcp-server.php, or add it to your client's MCP config (Claude Code, Cursor, Windsurf):
{
"mcpServers": {
"phpclaw": {
"command": "php",
"args": ["mcp-server.php"]
}
}
}
Key features
✅ 2 transports: stdio (Claude Code, Cursor, Windsurf, Zed) and StreamableHttpTransport (the current MCP HTTP spec)
✅ Full guard chain applies: every call runs through the same default guard chain as any other phpClaw agent (prompt-injection, Unicode, homoglyph, role-switch, code-injection, destructive-SQL, PII and length checks), via GuardRegistry::registerDefaults()
✅ ShellTool allowlist and FileReadTool / FileWriteTool sandbox: unchanged from core, enforced on every MCP call exactly as they would be on a direct call
✅ Bearer-token auth: PHPCLAW_MCP_TOKEN gates the HTTP transport with a timing-safe comparison, and the transport refuses to start when it is unset
✅ Built-in rate limiting: 60 requests/minute by default, shared across processes via APCu when available
✅ Zero framework dependencies: pure PHP, same php ^8.1 floor as core
How it fits together
MCP client (Claude Desktop / Code / Cursor) → phpclaw-mcp server → your ToolRegistry → the same guards and tools as any other phpClaw agent
Documentation
This README gets you installed. Everything else (the full transport reference, security model, self-hosting, code examples) lives at:
Contributing
Contributions are welcome. See the contributing guide.
Security
Please review our security policy for reporting vulnerabilities.
