Skip to main content
skill CX Codex

laravel-mcp — Claude Code skill: build MCP servers in Laravel

A skill for building MCP servers on Laravel: tools, prompts, resources, and auth via OAuth or Sanctum.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add AsyrafHussin/agent-skills --skill laravel-mcp -a claude-code
Open on GitHub

What laravel-mcp does

laravel-mcp is a rule set for building MCP servers with Laravel. It ships 7 rules across 5 categories: creating and registering servers, tools with input/output schemas, prompts and resources, authentication, and testing. Every rule comes with a bad example, a good example, and references written for Laravel 13 and PHP 8.3.

Rules carry priorities. Servers are CRITICAL, tools and auth are HIGH, prompts and resources are MEDIUM. The prefixes (server-, tool-, prompt-, resource-, auth-, test-) let the agent jump straight to the right section when you ask for a server or a tool schema.

You need Laravel 13 and PHP 8.3 or newer — on older versions the code in the rules won't run. The full compiled guide lives in AGENTS.md; individual rule files are meant to be read one at a time.

What it helps with

  • create an MCP server and register it in routes/ai.php
  • define a tool with an input schema and DI
  • set up a prompt with arguments and validation
  • protect an MCP server with OAuth 2.1 or Sanctum
  • test tools in MCP Inspector and with unit tests

Example prompts for the agent

  • create a Laravel MCP server with a weather tool
  • define the schema for a tool with a required location field
  • protect the MCP server with Sanctum and write a unit test

How to install laravel-mcp

1Skills CLI (Vercel)

npx skills add AsyrafHussin/agent-skills --skill laravel-mcp -a claude-code

2Manually: put the files in place

~/.claude/skills/laravel-mcp/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/laravel-mcp/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about laravel-mcp

How do I install laravel-mcp in Claude?

Run npx skills add AsyrafHussin/agent-skills --skill laravel-mcp -a claude-code. The skill lands in ~/.claude/skills/laravel-mcp/SKILL.md.

What does laravel-mcp do?

It gives the agent rules for Laravel MCP server development: servers, tools, prompts, resources, authentication, and testing.

Which Laravel and PHP versions are required?

Laravel 13 and PHP 8.3 or newer. The rules and examples target those versions.

Source text

SKILL.md · MIT
---
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.
license: MIT
metadata:
  author: Laravel Community
  version: "1.0.0"
  laravelVersion: "13.x"
  phpVersion: "8.3+"
---

# Laravel MCP

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

## 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

## 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

### 2. Tools (HIGH)

- `tool-create` - Create tools with input/output schemas, DI, and annotations
- `tool-responses` - Text, error, structured, streaming, and multi-content responses

### 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

### 5. Testing (HIGH)

- `test-unit` - Test with MCP Inspector and unit tests

## 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`

© Laravel Community · MIT · AsyrafHussin/agent-skills

Similar skills

Everything for Backend and APIs →

From the same set12

laravel-inertia-react A skill that hands your agent ready rules for Inertia pages, useForm handling and shared data across Laravel and React. CX Codex +1 1,900installs clean-code-principles A skill for architecture review and code quality: SOLID, DRY, KISS, design patterns. Useful when refactoring or weighing design decisions. CX Codex +1 1,800installs typescript-react-patterns A skill with 33 TypeScript rules for React: props, hooks, events, refs, generics and context. Useful when the agent writes components and fights type errors. CX Codex +1 1,100installs api-design-patterns A skill with 38 REST API rules covering resources, errors, security, pagination and versioning. Useful when an agent writes or reviews endpoints. CX Codex +1 929installs laravel-testing Guides AI agents in writing Laravel 13 feature and unit tests with Pest 4 or PHPUnit 12, covering model factories and service mocks. CX Codex +1 907installs testing-best-practices A rule set for unit and integration tests and TDD: 34 rules in 7 categories, TypeScript with Jest and Vitest. Useful while writing tests or reviewing someone else's. CX Codex +1 899installs e2e-playwright-testing A skill that guides the agent through writing Playwright E2E tests: locators, auth reuse, forms, assertions and CI config. CX Codex +1 796installs state-management A skill that hands your agent ready patterns for TanStack Query v5 and Zustand v5: fetching, caching, mutations, optimistic updates and client stores. CX Codex +1 783installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor