Download the PHP package chaoticingenuity/laravel-mcp-server without Composer

On this page you can find all versions of the php package chaoticingenuity/laravel-mcp-server. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-mcp-server

Laravel MCP Server

A Laravel package that implements the Model Context Protocol (MCP) server specification, enabling AI models to interact with your Laravel application through a standardized protocol.

Features

Installation

Install the package via Composer:

Quick Start

1. Publish Configuration

2. Publish Controllers (Optional)

Note: You only need to publish if you want to customize the MCPController. The middleware classes are used directly from the package namespace.

3. Laravel Version-Specific Setup

Laravel 11+ (including Laravel 12) Setup (Recommended Method)

For Laravel 11+, use the static helper method to register middleware in bootstrap/app.php:

Add the MCP route to your routes/api.php:

Laravel 10 Setup

For Laravel 10, middleware is automatically registered by the service provider. Just ensure your routes/api.php includes the MCP route (same as above).

4. Set Environment Variables

Add to your .env file:

5. Configure Authentication

Choose your authentication strategy:

Option A: Static Configuration (Simple)

Edit config/mcp.php:

Option B: Database Authentication (Recommended)

  1. Add MCP support to your User model:

  2. Run migrations:

  3. Enable custom database authenticator:

6. Test the Installation

7. Verification

Check that everything is working:

Advanced Features (v1.1.0+)

Permission Resolution System

The package now includes a flexible permission resolution system that allows custom permission logic:

Enhanced API Key Management

Advanced API key features with audit logging and per-key rate limiting:

Scope-Based Permissions

Implement fine-grained access control with scopes:

Data Filtering & Field Security

Automatically filter response data based on field access permissions:

Performance Monitoring & Analytics

Built-in performance tracking and usage analytics:

Authentication Methods

The package supports multiple authentication strategies that can be used simultaneously:

Static Configuration

Configure static API keys, basic auth, and bearer tokens:

Database Authentication

Store API keys in your database with user relationships:

Custom Authentication

Create your own authentication logic:

Flexible Key Storage Patterns

The package supports multiple API key storage strategies:

Separate Table (Default)

Uses the ApiKey model with foreign key relationships:

User Table Columns

Store hashed keys directly in user table columns:

JSON Column Storage

Store all keys in a single JSON column:

Client Permissions

Configure fine-grained permissions for each client:

Creating Custom Tools

1. Generate Tool Stub

2. Create Your Tool

3. Register Your Tool

Add to config/mcp.php:

Creating Custom Resources

1. Static Resources

2. Template Resources

Resources that accept parameters in the URI:

3. Register Your Resources

Security

Field-Level Access Control

Control which fields clients can access at a granular level:

Middleware Stack

The package includes comprehensive security middleware:

  1. MCPSecurityMiddleware: HTTPS enforcement, IP whitelisting, security headers
  2. MCPAuthMiddleware: Multi-method authentication with custom authenticators
  3. MCPThrottleMiddleware: Rate limiting with per-client and burst controls
  4. MCPLoggingMiddleware: Request/response logging with performance metrics

Environment-Based Security

IP Whitelisting

Support for both individual IPs and CIDR notation:

Rate Limiting

Configure rate limits globally and per-client:

What's New in v1.0.0 🎉

Enhanced Permission Management

New Features

Developer Experience

Quick Setup with Bouncer (Optional)

If you want enhanced permission management with Laravel Bouncer:

Testing

Comprehensive Test Suite (v1.0.0)

The package includes 74 comprehensive tests covering:

Running Tests

Performance Benchmarks

The v1.0.0 test suite includes performance validation:

Running Package Tests

Testing Your Implementation

MCP Protocol Methods

The package implements all standard MCP methods:

Method Description Response
initialize Initialize MCP session Server capabilities and info
tools/list List available tools Array of tool definitions
tools/call Execute a tool Tool execution result
resources/list List available static resources Array of resource definitions
resources/read Read resource content Resource content
resources/templates/list List template resources Array of template definitions

Error Handling

The package provides standardized JSON-RPC 2.0 error responses:

Code Meaning When Used
-32001 Authentication required Invalid/missing credentials
-32002 Access denied Insufficient permissions
-32003 Rate limit exceeded Too many requests
-32602 Invalid params Missing/invalid parameters
-32603 Internal error Server-side errors

Exception Types

The package uses specific exception types for better error handling:

Input Validation

Client IDs are automatically validated and must meet these requirements:

Example error response:

Performance Considerations

Caching Strategies

Implement intelligent caching in your custom tools and resources:

Database Optimization

Authentication Performance

Monitoring

Use the built-in logging to monitor performance:

User Management

Creating API Keys for Users

User Permission Management

Bulk Operations

Deployment

Production Checklist

Environment Variables

Docker

Database Indexes

Create proper indexes for optimal performance:

Load Balancing

MCP servers are stateless and can be load balanced normally. Consider:

Monitoring Setup

Troubleshooting

Common Issues

Middleware Not Found Error

Tool/Resource Not Found

Database Authentication Issues

Client ID Validation Errors

Field Access Issues

Access Denied Errors

Rate Limit Issues

Debug Mode

Enable debug mode for development:

Check logs for detailed information:

Performance Debugging

Monitor and optimize performance:

Testing Authentication

Laravel Version Compatibility

Laravel 11

Laravel 10

Migration from Laravel 10 to 11

If upgrading your Laravel application:

  1. Update middleware registration in bootstrap/app.php
  2. Remove any manual middleware registration from app/Http/Kernel.php
  3. Test all MCP endpoints still work
  4. Update any custom middleware following Laravel 11 patterns

Advanced Configuration

Custom Context Factory

Create custom client context logic:

Multi-Tenant Support

Configure MCP for multi-tenant applications:

Custom Schema Validation

Add JSON Schema validation for tool inputs:

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Add tests for new functionality
  4. Ensure all tests pass (composer test)
  5. Follow PSR-12 coding standards (composer format)
  6. Update documentation as needed
  7. Submit a pull request

Development Setup

Package Structure

License

MIT License - see LICENSE file for details.

Changelog

See CHANGELOG.md for version history.

Support

Credits

Related Packages


All versions of laravel-mcp-server with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/contracts Version ^10.0|^11.0|^12.0
illuminate/support Version ^10.0|^11.0|^12.0
illuminate/http Version ^10.0|^11.0|^12.0
illuminate/database Version ^10.0|^11.0|^12.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package chaoticingenuity/laravel-mcp-server contains the following files

Loading the files please wait ...