WM

wizcoders/mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

0 stars 0 forks 质量 68 趋势 8MIT

A Model Context Protocol server for Laravel. Expose your application to MCP clients — Claude Code, Claude Desktop, or anything else that speaks MCP — as a set of tools that respect your existing...

概览

A Model Context Protocol server for Laravel. Expose your application to MCP clients — Claude Code, Claude Desktop, or anything else that speaks MCP — as a set of tools that respect your existing permission model. logiscape/mcp-sdk-php and php-mcp/server both require PHP ≥ 8.1. MCP is JSON-RPC 2.0 over a byte stream, so the protocol layer here is a few hundred lines with no runtime dependency beyond illuminate/* and psr/log — which is cheaper than blocking on a platform upgrade. The source deliberately avoids everything added after PHP 7.3, so one codebase serves every supported version: no arrow functions, typed properties, ??=, match, enums, constructor promotion, named arguments, or union types. Public interfaces declare no parameter or return types, so adding them later would be the breaking change — not the absence. composer.json accepts illuminate/* ^8|^9|^10|^11|^12, and Composer picks the set your PHP version allows. The provider is auto-discovered.

README

以下为原文 README 节选,完整内容请查看原文。

wizcoders/mcp

A Model Context Protocol server for Laravel. Expose your application to MCP clients — Claude Code, Claude Desktop, or anything else that speaks MCP — as a set of tools that respect your existing permission model.

Runs on PHP 7.3 / Laravel 8 and on PHP 8.x / Laravel 9–12 from the same source.

Why not an existing MCP SDK

logiscape/mcp-sdk-php and php-mcp/server both require PHP ≥ 8.1. MCP is JSON-RPC 2.0 over a byte stream, so the protocol layer here is a few hundred lines with no runtime dependency beyond illuminate/* and psr/log — which is cheaper than blocking on a platform upgrade.

Compatibility

The source deliberately avoids everything added after PHP 7.3, so one codebase serves every supported version: no arrow functions, typed properties, ??=, match, enums, constructor promotion, named arguments, or union types. Public interfaces declare no parameter or return types, so adding them later would be the breaking change — not the absence.

composer.json accepts illuminate/* ^8|^9|^10|^11|^12, and Composer picks the set your PHP version allows.

Install

composer require wizcoders/mcp
php artisan vendor:publish --tag=mcp-config

The provider is auto-discovered. Nothing is registered on the HTTP path, so a web request pays nothing for having this installed.

Configure

// config/mcp.php
'server_name' => 'my-app',
'authorizer'  => \App\Mcp\MyAuthorizer::class,
'tools'       => [
    \Wizcoders\Mcp\Tools\WhoAmITool::class,
    \App\Mcp\Tools\SalesSummaryTool::class,
],

mergeConfigFrom is a shallow merge, so tools replaces the package default rather than adding to it — re-list WhoAmITool unless you mean to drop it.

Packages can also contribute tools at runtime, without touching app config:

$this->app->make(\Wizcoders\Mcp\ToolRegistry::class)->register(new MyTool);

Authorization

Tools declare a permission string; an Authorizer decides what it means.

Authorizer Behaviour
NullAuthorizer (default) Denies everything gated — fails closed
GateAuthorizer Resolves through Laravel’s Gate; works with policies and spatie/laravel-permission
your own Implement Wizcoders\Mcp\Contracts\Authorizer

The default denies rather than allows on purpose: an app that installs this and forgets to configure an authorizer gets a server exposing only ungated tools, not one that quietly hands an assistant the keys.

The check runs before a tool is listed, not just before it runs — a user without the permission never learns the tool exists, and tools/call returns the same “unknown tool” message for forbidden and nonexistent alike so the set cannot be enumerated by probing.

Bundled tools

Tool Purpose
whoami Acting user, app-supplied context, and which tools they can see
db_schema Table list, or one table’s columns / indexes / foreign keys
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "my-app": { "command": "/usr/bin/php", "args": ["/path/to/artisan", "mcp:serve", "--user=1"] } } }