Skip to content

Laravel package that auto-generates MCP server documentation by extracting metadata from server classes. Includes tools, resources, prompts, installation commands, and customizable Blade views.

License

Notifications You must be signed in to change notification settings

fabianbartsch/mcp-docs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel MCP Documentation Generator

Latest Version Packagist License: MIT

Automatically generate beautiful documentation pages for your Laravel MCP (Model Context Protocol) servers. This package extracts metadata from your MCP server classes and generates comprehensive documentation with tools, resources, prompts, and installation instructions.

Features

  • 🚀 Automatic Documentation: Automatically extracts tools, resources, and prompts from your MCP server class
  • 🎨 Beautiful UI: Modern, responsive documentation pages built with Tailwind CSS
  • ⚙️ Highly Configurable: Customize server URLs, installation commands, and messages
  • 📦 Easy Integration: Works out of the box with Laravel MCP servers
  • 🔧 Extensible: Publish and customize views to match your brand

Installation

Install the package via Composer:

composer require fabianbartsch/mcp-docs

Configuration

Publish the configuration file:

php artisan vendor:publish --tag=mcp-docs-config

This will create config/mcp-docs.php. Configure your MCP server class:

'server_class' => env('MCP_DOCS_SERVER_CLASS', App\Mcp\Servers\YourServer::class),
'server_name' => env('MCP_DOCS_SERVER_NAME', 'your-server'),
'server_url_pattern' => env('MCP_DOCS_SERVER_URL', '{base_url}/mcp/{server}'),

Or set it in your .env file:

MCP_DOCS_SERVER_CLASS=App\Mcp\Servers\YourServer
MCP_DOCS_SERVER_NAME=your-server
MCP_DOCS_SERVER_URL=https://yourdomain.com/mcp/{server}

Usage

Automatic Route Registration

By default, the package registers a route at /docs/mcp. You can customize this in the config file or disable it:

'route' => [
    'enabled' => true,
    'path' => '/docs/mcp',
    'name' => 'mcp.docs',
    'middleware' => 'web',
],

Manual Route Registration

If you prefer to register the route manually, disable automatic registration and add it to your routes/web.php:

use FabianBartsch\McpDocs\Controllers\McpDocumentationController;

Route::get('/docs/mcp', [McpDocumentationController::class, 'index'])
    ->name('mcp.docs');

Customizing Views

Publish the views to customize them:

php artisan vendor:publish --tag=mcp-docs-views

Views will be published to resources/views/vendor/mcp-docs/. You can now customize:

  • index.blade.php - Main documentation page
  • mcp-docs.blade.php - Layout template
  • partials/ - Reusable components

Customizing Messages

You can customize authentication and support messages in the config file:

'auth_message' => 'This MCP server requires authentication. Include your Sanctum token in the Authorization header:',
'support_message' => 'For questions or issues, please contact support@example.com.',

Set to null to hide a section entirely.

Custom Installation Commands

Customize installation commands for different platforms:

'installation_commands' => [
    'cursor' => 'cursor://install-mcp?url={url}',
    'vscode' => 'vscode://install-mcp?url={url}',
    'claude code' => 'claude mcp add {url}',
    'custom' => 'your-custom-command {url}',
],

Requirements

  • PHP >= 8.1
  • Laravel >= 10.0 (supports Laravel 10, 11, and 12)
  • laravel/mcp >= 0.1.0

Note: This package matches the same Laravel and PHP version requirements as laravel/mcp for maximum compatibility.

MCP Server Structure

Your MCP server class should extend Laravel\Mcp\Server and define:

<?php

namespace App\Mcp\Servers;

use Laravel\Mcp\Server;

class YourServer extends Server
{
    protected string $name = 'Your Server Name';
    protected string $version = '1.0.0';
    protected string $instructions = 'Server description';
    
    protected array $tools = [
        YourTool::class,
    ];
    
    protected array $resources = [
        YourResource::class,
    ];
    
    protected array $prompts = [
        YourPrompt::class,
    ];
}

How It Works

The package uses PHP reflection to:

  1. Extract server metadata (name, version, instructions)
  2. Discover all registered tools, resources, and prompts
  3. Extract metadata from each component (name, title, description, parameters)
  4. Generate a comprehensive documentation page

Examples

Basic Usage

After installation and configuration, visit /docs/mcp to see your documentation.

Extending the Controller

You can extend the controller to add custom logic:

<?php

namespace App\Http\Controllers;

use FabianBartsch\McpDocs\Controllers\McpDocumentationController as BaseController;

class McpDocumentationController extends BaseController
{
    protected function generateServerUrl(): string
    {
        // Custom URL generation logic
        return 'https://custom-url.com/mcp/server';
    }
}

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

The MIT License (MIT). Please see License File for more information.

Credits

About

Laravel package that auto-generates MCP server documentation by extracting metadata from server classes. Includes tools, resources, prompts, installation commands, and customizable Blade views.

Resources

License

Stars

Watchers

Forks

Packages

No packages published