Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Mcp Laravel Package

laravel/mcp

Build MCP (Model Context Protocol) servers in Laravel so AI clients can securely interact with your app. Expose tools, resources, and prompts using familiar Laravel patterns, with docs and integrations designed for rapid setup and deployment.

View on GitHub
Deep Wiki
Context7

Laravel MCP helps you rapidly build Model Context Protocol (MCP) servers inside your Laravel application, enabling AI clients to securely interact with your app’s capabilities and data through a standard protocol.

Use it to expose well-defined endpoints and tooling for AI integrations while staying within the Laravel ecosystem. Learn more in the official documentation on the Laravel website.

  • Build MCP servers quickly within existing Laravel apps
  • Enable AI clients to interact via the Model Context Protocol
  • Laravel-first developer experience and conventions
  • Clear docs, contribution guidelines, and security policy
  • MIT-licensed and distributed via Packagist
Frequently asked questions about Mcp
What is Laravel MCP and how does it differ from REST APIs for AI integration?
Laravel MCP is a package that lets you expose Laravel models, resources, and logic as tools via the Model Context Protocol (MCP), a standardized way for AI clients to interact with your backend. Unlike REST APIs, MCP uses structured schemas (JSON Schema) for inputs/outputs, supports dynamic tool registration, and integrates natively with AI frameworks like LangChain or CrewAI. It’s ideal for AI agents that need to invoke Laravel logic as tools rather than raw HTTP endpoints.
Which Laravel and PHP versions does Laravel MCP support?
Laravel MCP requires Laravel 10+ and PHP 8.2+. Earlier versions (e.g., Laravel 9 or PHP 8.1) are unsupported due to dropped compatibility in v0.5.4+. Always check the [latest release notes](https://github.com/laravel/mcp/releases) for version-specific requirements before installing.
How do I define a tool in Laravel MCP? Can I use Eloquent models directly?
You define tools using PHP 8.0+ attributes (annotations) like `#[McpTool]` or via XML/JSON schemas. For Eloquent models, you can convert them into tools with minimal boilerplate by implementing the `schema()` and `handle()` methods. The package provides helpers to map Laravel validation rules to JSON Schema automatically, reducing duplication.
Does Laravel MCP support OAuth2 for AI client authentication?
Yes, Laravel MCP includes built-in OAuth2 support with dynamic client registration via the `/oauth/register` endpoint. You configure authorization servers in `config/mcp.php` and ensure CORS/CSRF protections are in place. This allows AI agents to authenticate securely without manual client setup, though you’ll need to handle PKCE flows for public clients.
Can I use Laravel MCP with existing Laravel auth systems like Sanctum or Passport?
Laravel MCP’s OAuth2 integration is designed to work alongside Sanctum or Passport, but it requires explicit configuration to avoid conflicts. For example, you may need to merge authorization servers or customize the `issuer` path. The package prioritizes MCP’s OAuth2 spec, so existing auth systems should be adapted to align with its requirements.
How do I handle schema changes in tools without breaking AI clients?
Schema changes can break AI clients if not managed carefully. Laravel MCP recommends versioning tool schemas (e.g., by including a `version` field in the schema) and using backward-compatible updates. You can also implement migration logic in your `handle()` method to transform inputs/outputs between versions. Always test with your AI client’s schema validation before deploying updates.
What’s the performance impact of using Laravel MCP in production?
Laravel MCP adds minimal overhead—typically 10–30ms per request due to JSON-RPC processing and OAuth2 validation. Benchmark your tools under load, especially if they involve complex business logic. For high-throughput scenarios, consider caching tool schemas or using Laravel Octane to offload MCP requests to a queue.
Are there alternatives to Laravel MCP for AI-Laravel integration?
Alternatives include building custom REST/gRPC APIs or using packages like Laravel’s built-in API resources with AI-specific wrappers (e.g., LangChain’s HTTP connectors). However, MCP is unique in providing a standardized protocol for tool-based interactions, which simplifies AI client integration and reduces boilerplate for common patterns like RAG pipelines or agent workflows.
How do I test MCP tools in Laravel?
Testing MCP tools requires asserting structured content (e.g., JSON Schema validation) and OAuth2 flows. Laravel MCP provides helpers like `assertStructuredContent()` for schema validation, while you can use Laravel’s HTTP tests to simulate AI client requests. Mock OAuth2 clients with tools like `laravel/oauth-server-provider` to test authentication scenarios.
Can I use Laravel MCP for non-AI use cases, like internal microservices?
While Laravel MCP is optimized for AI agents, you can repurpose it for internal microservices by treating tools as RPC endpoints. However, the package adds complexity (e.g., OAuth2, JSON Schema) that may be overkill for simple internal APIs. For non-AI use cases, consider lighter alternatives like Laravel’s built-in API resources or custom HTTP middleware.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport