What is MCP?
The Model Context Protocol (MCP) is an open standard that allows AI assistants (such as Claude Desktop, Cursor, and Claude Code) to securely discover and invoke tools in external applications. Geni turns your Laravel application into a fully autonomous, AI-ready toolkit:- Zero-Effort Tool Discovery (
tools/list): Every documented route becomes an AI tool with strictly typed parameter schemas derived directly from your Form Requests, Data DTOs, and migrations. - Autonomous Action Execution (
tools/call): AI agents can execute real actions against your app. You can ask an agent: “Find user alex@example.com and update their role to admin”, and the agent will discoverGET /api/usersand dispatchPATCH /api/users/{id}on its own. Available through the stdio server; over HTTP it is opt-in. - Isolated Authentication: Bearer tokens and API keys are injected at the HTTP layer and never exposed in the OpenAPI document or prompt context.
Live Stdio Server
Run
php artisan geni:mcp:serve for local AI clients like Claude Desktop or Claude Code.HTTP Remote Endpoint
Access
GET / POST on /docs/api/mcp for tool discovery from remote AI agents. Execution over HTTP is opt-in.Running the Live MCP Server
Geni includes a built-in stdio MCP server command:tools/list: Returns all available endpoints formatted as tool definitions.tools/call: Dispatches HTTP requests to your application and returns structured responses.
Connecting to Claude Desktop
Add Geni to yourclaude_desktop_config.json:
claude_desktop_config.json
Generating Static Manifests
You can also export an MCP tool manifest or client configuration to a file:HTTP MCP Endpoint
Geni also serves an HTTP MCP endpoint at/docs/api/mcp (and /docs/api/{name}/mcp for each named API):
GET /docs/api/mcp: Returns tool definitions as JSON.POST /docs/api/mcp: Handles JSON-RPC 2.0 requests:initialize,ping,tools/listand, when enabled,tools/call.
restrict_to_local, the viewApiDocs gate and docs_auth). See Documentation Authentication.
Enabling HTTP Execution
.env
config/geni.php
tools/call request receives a JSON-RPC error (-32601) explaining how to enable it. The stdio server (php artisan geni:mcp:serve) is not affected by this flag.
Protocol Details
- JSON only:
POSTrequests must be sent withContent-Type: application/json; anything else returns415 Unsupported Media Type. This keeps cross-site forms andtext/plainrequests out. - No CSRF: the MCP routes skip CSRF verification in every auth mode, so adding
webtogeni.middleware(or using form auth) does not break JSON-RPC clients. - Notifications: JSON-RPC notifications (requests without an
id, such asnotifications/initialized) never receive a JSON-RPC response; the HTTP endpoint answers them with204 No Content. - Version negotiation:
initializeanswers with the protocol version the client requested when it is supported (2025-06-18,2025-03-26or2024-11-05), and with2025-06-18otherwise. - Errors: internal exceptions are reported to your application’s exception handler; clients only receive a generic
Internal error.
Tool Naming
geni.mcp.tool_naming controls tool names:
snake(default): tools are named from the method and path (for exampleget_api_posts). An explicitoperationId(@operationIdor#[Endpoint(operationId: ...)]) is converted to snake case and used instead. TheoperationIds that Geni generates automatically since 3.0 do not rename tools in this mode, so existing tool names stay stable.operation_id: tools use the operation’soperationId, including generated ones. See Operation IDs.
Security & Authentication
Configure token injection inconfig/geni.php:
config/geni.php