Skip to content
Back to skills

Laravel Mcp

ASecurity

Laravel MCP server development. Use when building MCP servers, tools, prompts, or resources for AI client integration. Triggers on tasks involving laravel/mcp, MCP tools, MCP prompts, MCP resources, or AI client protocols. Not for Laravel for Rust apps (laravel-rust crate).

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 2, 2026
ai-agentsrustgophptestingbackend

Works with

  • cli
  • mcp

Security analysis

A100/100

Pro scans all 11 files and shows the line behind each finding

Scanned December 2, 2026

npx -y skills add airshell/laravel-php-to-rust --skill laravel-mcp --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Laravel Mcp?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Laravel Mcp
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/airshell-laravel-mcp/badge)](https://www.skillsdirectory.com/skills/airshell-laravel-mcp)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: laravel-mcp
description: Laravel MCP server development. Use when building MCP servers, tools, prompts, or resources for AI client integration. Triggers on tasks involving laravel/mcp, MCP tools, MCP prompts, MCP resources, or AI client protocols. Not for Laravel for Rust apps (laravel-rust crate).
license: MIT
metadata:
  author: Laravel Community
  version: "1.1.1"
  laravelVersion: "13.x"
  phpVersion: "8.3+"
---

# Laravel MCP

Comprehensive guide for building MCP (Model Context Protocol) servers with Laravel. Contains 8 rules across 5 categories for exposing tools, prompts, and resources to AI clients.

**Version 1.1.1 (December 2026).** Targets `laravel/mcp` ^1.0, tested on 1.3 (1.3.0), MCP protocol revision `2026-07-28` (`server/discover`, no sessions; legacy `initialize` clients still served).

## When to Apply

Reference these guidelines when:
- Creating MCP servers (web or local)
- Building tools that AI clients can call
- Defining prompts for reusable AI interactions
- Exposing resources for AI context
- Protecting MCP servers with OAuth or Sanctum
- Testing MCP servers, tools, prompts, and resources
- Servers with many tools (searchable catalogs) or long-running tools (progress)

**Not for Laravel for Rust.** If the project is a Laravel for Rust app (its `Cargo.toml` depends on the `laravel-rust` crate), this skill does not apply: it assumes a Laravel PHP backend. Use the agent skills the app ships in `.agents/skills/` and the version-matched docs bundled with the crate.

## Rule Categories by Priority

| Priority | Category | Impact | Prefix |
|----------|----------|--------|--------|
| 1 | Servers | CRITICAL | `server-` |
| 2 | Tools | HIGH | `tool-` |
| 3 | Prompts & Resources | MEDIUM | `prompt-`, `resource-` |
| 4 | Authentication | HIGH | `auth-` |
| 5 | Testing | HIGH | `test-` |

## Quick Reference

### 1. Servers (CRITICAL)

- `server-create-register` - Create and register web or local MCP servers; protocol 2026-07-28, stateless (no `sessionId()`)

### 2. Tools (HIGH)

- `tool-create` - Create tools with input/output schemas, constructor or `handle()` DI, and annotations
- `tool-responses` - Text, error, structured, streaming, and multi-content responses
- `tool-catalog-progress` - `ToolSearch` catalogs (`search_tools` / `execute_tools`) and `Response::progress()`

### 3. Prompts & Resources (MEDIUM)

- `prompt-create` - Create prompts with arguments, validation, and responses
- `resource-create` - Create resources and resource templates with URI patterns

### 4. Authentication (HIGH)

- `auth-protect` - Protect servers with OAuth 2.1, Sanctum, or custom auth; throttle `Mcp::oauthRoutes()`

### 5. Testing (HIGH)

- `test-unit` - MCP Inspector, `Server::tool()` unit tests, structured content and progress assertions (not raw JSON-RPC)

## Essential Patterns

### Creating an MCP Server

```php
<?php

namespace App\Mcp\Servers;

use Laravel\Mcp\Server;
use Laravel\Mcp\Server\Attributes\Instructions;
use Laravel\Mcp\Server\Attributes\Name;
use Laravel\Mcp\Server\Attributes\Version;

#[Name('Weather Server')]
#[Version('1.0.0')]
#[Instructions('This server provides weather information.')]
class WeatherServer extends Server
{
    protected array $tools = [
        CurrentWeatherTool::class,
    ];

    protected array $resources = [];

    protected array $prompts = [];
}
```

### Registering in routes/ai.php

```php
use App\Mcp\Servers\WeatherServer;
use Laravel\Mcp\Facades\Mcp;

Mcp::web('/mcp/weather', WeatherServer::class);
Mcp::local('weather', WeatherServer::class);
```

### Creating a Tool

```php
<?php

namespace App\Mcp\Tools;

use Illuminate\Contracts\JsonSchema\JsonSchema;
use Laravel\Mcp\Request;
use Laravel\Mcp\Response;
use Laravel\Mcp\Server\Attributes\Description;
use Laravel\Mcp\Server\Tool;

#[Description('Fetches the current weather for a location.')]
class CurrentWeatherTool extends Tool
{
    public function handle(Request $request): Response
    {
        $location = $request->get('location');

        return Response::text("The weather in {$location} is sunny, 72°F.");
    }

    public function schema(JsonSchema $schema): array
    {
        return [
            'location' => $schema->string()
                ->description('The location to get the weather for.')
                ->required(),
        ];
    }
}
```

## How to Use

Read individual rule files for detailed explanations and code examples.

Each rule file contains:
- YAML frontmatter with metadata (title, impact, tags)
- Brief explanation of why it matters
- Bad Example with explanation
- Good Example with explanation
- Laravel 13 and PHP 8.3 specific context and references

## Full Compiled Document

For the complete guide with all rules expanded: `AGENTS.md`

Files in this skill

  • AGENTS.md34.9 KB
  • README.md1.7 KB
  • SKILL.md4.6 KB
  • rules/auth-protect.md3.3 KB
  • rules/prompt-create.md3.5 KB
  • rules/resource-create.md3.7 KB
  • rules/server-create-register.md3.4 KB
  • rules/test-unit.md5.4 KB
  • rules/tool-catalog-progress.md4.5 KB
  • rules/tool-create.md4.8 KB
  • rules/tool-responses.md3.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.