> ## Documentation Index
> Fetch the complete documentation index at: https://geni.masiting.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Model Context Protocol (MCP)

> Turn your Laravel API into tools for AI agents like Claude Desktop, Cursor, and Claude Code.

## What is MCP?

The [Model Context Protocol (MCP)](https://modelcontextprotocol.io) 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 automatically transforms your Laravel OpenAPI specification into an MCP tool server:

* **Tool Discovery**: Every documented route becomes an AI tool with typed parameter schemas derived from your Form Requests and migrations.
* **Live Tool Execution**: AI agents can execute real API requests against your application with automated authentication.

## Running the Live MCP Server

Geni includes a built-in stdio MCP server command:

```bash theme={null}
php artisan geni:mcp:serve
```

This starts a JSON-RPC server listening on standard input and output, responding to MCP protocol messages:

* `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 your `claude_desktop_config.json`:

```json claude_desktop_config.json theme={null}
{
  "mcpServers": {
    "my-laravel-api": {
      "command": "php",
      "args": [
        "/path/to/your/laravel/artisan",
        "geni:mcp:serve",
        "--base-url=http://localhost:8000"
      ]
    }
  }
}
```

Restart Claude Desktop, and your AI assistant can now search, inspect, and call your Laravel API endpoints directly!

## Generating Static Manifests

You can also export an MCP tool manifest or client configuration to a file:

```bash theme={null}
# Export MCP tool manifest
php artisan geni:mcp --path=mcp-tools.json

# Export Claude Desktop configuration snippet
php artisan geni:mcp --format=claude-desktop
```

## HTTP MCP Endpoint

Geni also serves an HTTP MCP discovery endpoint at `/docs/api/mcp`:

* `GET /docs/api/mcp`: Returns tool definitions as JSON.
* `POST /docs/api/mcp`: Executes tools calls via HTTP JSON-RPC.

This route inherits any authentication configured for your documentation portal.

## Security & Authentication

Configure token injection in `config/geni.php`:

```php config/geni.php theme={null}
'mcp' => [
    'enabled' => true,
    'execution' => [
        'base_url' => env('GENI_MCP_BASE_URL', 'http://localhost:8000'),
        'timeout' => 15,
        'verify_ssl' => true,
        'auth' => [
            'default_bearer_token' => env('GENI_MCP_BEARER_TOKEN'),
            'default_api_key' => env('GENI_MCP_API_KEY'),
        ],
    ],
],
```

<Warning>
  Authentication credentials configured in `execution.auth` are injected into HTTP requests during tool execution and are never leaked in tool schemas or manifest exports.
</Warning>
