PHPackages                             spiral/mcp-server - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. spiral/mcp-server

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

spiral/mcp-server
=================

Spiral bridge for MCP server

541.1k11PHPCI passing

Since Sep 27Pushed 7mo agoCompare

[ Source](https://github.com/spiral-packages/mcp-server)[ Packagist](https://packagist.org/packages/spiral/mcp-server)[ RSS](/packages/spiral-mcp-server/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (1)

Spiral MCP Server
=================

[](#spiral-mcp-server)

A powerful and flexible **Model Context Protocol (MCP) Server** implementation for the Spiral Framework. This package provides a complete MCP server solution with automatic tool discovery, attribute-based configuration, and seamless integration with Spiral's dependency injection container.

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Quick Start](#quick-start)
- [Configuration](#configuration)
- [Creating Tools](#creating-tools)
- [Tool Attributes](#tool-attributes)
- [Middleware](#middleware)
- [Contributing](#contributing)
- [License](#license)

Features
--------

[](#features)

✨ **Automatic Tool Discovery** - Automatically discovers and registers MCP tools using PHP attributes
🔧 **Multiple Transport Options** - Supports HTTP, streaming HTTP, and STDIO transports
🎯 **Attribute-Based Configuration** - Define tool behavior with simple PHP attributes
🛡️ **Schema Validation** - Automatic JSON schema generation using spiral/json-schema-generator
⚡ **Middleware Support** - Extensible middleware system for request/response processing
🔌 **Spiral Integration** - First-class integration with Spiral Framework's IoC container
📊 **Session Management** - Built-in session handling with configurable TTL
🚀 **Production Ready** - Designed for high-performance production environments

Requirements
------------

[](#requirements)

- PHP 8.3 or higher
- Spiral Framework 3.15+
- Composer

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require spiral/mcp-server
```

Add the bootloader to your Spiral application:

```
// app/src/Application/Kernel.php
use Spiral\McpServer\Bootloader\McpServerBootloader;

protected const LOAD = [
    // ... other bootloaders
    McpServerBootloader::class,
];
```

Quick Start
-----------

[](#quick-start)

### 1. Create Your First Tool

[](#1-create-your-first-tool)

Create a simple calculator tool:

```
