Add support for the MCP Skills extension

Merged
PU
4d ago
+1147-11

This lets a Laravel MCP server serve Agent Skills through the MCP Skills extension (io.modelcontextprotocol/skills). An agent discovers a skill with skills/list and skills/get, and reads its files with resources/read.

Usage

resources/skills/release-checklist/
├── SKILL.md                 skill://release-checklist/SKILL.md
└── references/checklist.md  skill://release-checklist/references/checklist.md
---
name: release-checklist
description: Prepare a release using the bundled checklist.
---

# Release checklist

Read [the checklist](references/checklist.md) before preparing a release.

Register the folder by its path:

use Laravel\Mcp\Server;

class ProjectServer extends Server
{
    protected array $skills = [
        'skills/release-checklist',
    ];
}

Use a Skill class when the skill needs shouldRegister() or a custom URI:

use Laravel\Mcp\Request;
use Laravel\Mcp\Server;
use Laravel\Mcp\Server\Skill;

class ReleaseChecklist extends Skill
{
    public function path(): string
    {
        return 'skills/release-checklist';
    }

    public function shouldRegister(Request $request): bool
    {
        return $request->user()?->can('prepare-releases') ?? false;
    }
}

class ProjectServer extends Server
{
    protected array $skills = [ReleaseChecklist::class];
}
  • A folder path or path() names the skill folder. A relative path resolves from resource_path().
  • shouldRegister() is optional and container-called. When it returns false, the skill is hidden from skills/list, skills/get, resources/list, and resources/read.
  • $skills accepts folder paths, Skill class names, and Skill instances. Any string that is not a Skill class is a folder path. Setting $skills declares the extension and the resources capability.
  • Only SKILL.md appears in resources/list. Every file in the skill is readable through resources/read.

Custom URI

The default URI is skill://{name}/SKILL.md, with name from the frontmatter. #[Uri] sets another URI, and the file URIs follow it.

use Laravel\Mcp\Server\Attributes\Uri;

#[Uri('skill://engineering/release-checklist/SKILL.md')]
class ReleaseChecklist extends Skill
{
    public function path(): string
    {
        return 'skills/release-checklist';
    }
}
skill://engineering/release-checklist/SKILL.md
skill://engineering/release-checklist/references/checklist.md

Result

skills/list returns each skill with its frontmatter and a manifest of every file. skills/get returns the same entry for one URI, and an unknown URI returns -32602.

{
  "uri": "skill://release-checklist/SKILL.md",
  "frontmatter": {
    "name": "release-checklist",
    "description": "Prepare a release using the bundled checklist."
  },
  "resources": [
    { "uri": "skill://release-checklist/SKILL.md", "digest": "sha256:…", "size": 214 },
    { "uri": "skill://release-checklist/references/checklist.md", "digest": "sha256:…", "size": 58 }
  ]
}

Generating a Skill

php artisan make:mcp-skill ReleaseChecklist

This creates app/Mcp/Skills/ReleaseChecklist.php and resources/skills/release-checklist/SKILL.md. An existing SKILL.md stays unless you pass --force. Both stubs publish under the mcp-stubs tag.

File Safety

  • The server serves only regular files inside the skill folder. It skips dotfiles and symbolic links, and reads cannot leave the folder.
  • The server refuses a skill over 512 files or 16 MiB, as the spec recommends.
  • The frontmatter must have a description, and a name of at most 64 lowercase letters, numbers, and single hyphens.

Not Supported

  • The optional directoryRead capability.
  • Client behavior: digest checks, approval, activation, and execution.