Back to Blogs

πŸš€ Laravel MCP API Docs

dhurgham oday Backend Developer
February 17, 2026
2 Likes

Laravel MCP API Docs, a package that exposes your OpenAPI specification directly to AI tools via Laravel MCP. Instead of letting AI guess endpoints and payloads, it allows structured querying of your real API contract β€” enabling more accurate code generation, safer integrations, and AI-native workflows.

Make AI Use Your Real API β€” Not Guess It

If you're building Laravel applications in 2026 and using AI tools like Cursor, autonomous agents, or code assistants, you've probably seen this happen:

  • AI guesses your endpoints

  • It invents request fields

  • It assumes wrong payload structures

And suddenly your β€œAI productivity boost” turns into debugging sessions.

Laravel MCP API Docs fixes that.

πŸ‘‰ Available on Packagist:
https://packagist.org/packages/dhur-gham/laravel-mcp-api-docs

It exposes your real OpenAPI specification directly to Laravel MCP, allowing AI tools to consume the canonical API contract β€” not reverse-engineered assumptions from your controllers.


⚑ What It Actually Does

Instead of forcing AI to parse a massive Swagger JSON file, this package provides:

Structured, queryable tools:

  • search_endpoints(query)

  • get_endpoint(method, path)

  • list_tags()

Plus:

  • A browsable API catalog resource

  • Optional feature documentation via DocsForMcp/*.md

So instead of reading everything, AI can simply ask:

β€œGive me the POST /shipments schema.”

And it receives:

  • Exact request structure

  • Validation rules

  • Required fields

  • Response schema

  • Status codes

No hallucination. No guessing. Just structured truth.


🧠 Why It’s Powerful

1️⃣ AI Generates Correct Code the First Time

Imagine a frontend developer asking:

β€œGenerate a form for creating shipments.”

With MCP API Docs:

  • AI reads the real request schema

  • Uses correct field names

  • Applies correct data types

  • Handles enums properly

  • Marks required fields accurately

No Slack threads.
No β€œIs this field required?” questions.
No mismatched payload bugs.


2️⃣ It’s Built for AI, Not Just Humans

Swagger JSON was designed for:

  • Humans

  • Swagger UI

  • Postman

  • Frontend and mobile teams

Laravel MCP API Docs is designed for:

  • AI IDEs

  • Code agents

  • Autonomous refactoring systems

  • Intelligent integration builders

That distinction matters.

Swagger is documentation.
MCP API Docs is machine-consumable infrastructure.


πŸ†š Swagger JSON vs MCP API Docs

Swagger JSON

Laravel MCP API Docs

Static JSON file

Interactive MCP server

Entire spec loaded at once

Query specific endpoints on demand

Human-focused documentation

AI-native interface

No policy enforcement

Full Laravel middleware + policy support

Passive

Agent-ready

With Swagger, AI must parse everything.

With MCP API Docs, AI queries only what it needs.


πŸ” Security Is First-Class

You’re not exposing random API knowledge publicly.

You can protect the MCP route using:

  • auth:sanctum

  • Custom middleware

  • Policy ability checks (useMcpApiDocs)

Authentication runs first.
Policy authorization runs next.

This makes it safe for internal tooling, enterprise APIs, and large teams.


🎯 When You Should Use It

Laravel MCP API Docs makes sense if:

  • You use AI IDEs like Cursor

  • You have frontend or mobile teams

  • You maintain a growing API surface

  • You want AI to build integrations correctly

  • You care about reducing communication friction

If AI is part of your workflow, your API should be structured for AI consumption.


πŸ’‘ The Core Idea

Sharing Swagger helps humans read your API.

Laravel MCP API Docs helps AI understand your API.

And in an AI-first development world, that difference changes everything.


πŸ“¦ Install It

composer require dhur-gham/laravel-mcp-api-docs

πŸ”— Packagist:
https://packagist.org/packages/dhur-gham/laravel-mcp-api-docs

dhurgham oday

Backend Developer

I'm a dedicated backend web developer with a passion for creating efficient and scalable web applications. With experience in PHP and Laravel, I speci...

View Profile

Comments (2)

  • ht3aa Feb 18, 2026 at 3:33 AM

    Great Package. Thank you dhurgham

    • dhurgham oday Feb 18, 2026 at 6:23 AM

      β€οΈπŸ™

Leave a comment