PHPackages                             phpnl/mcp - 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. [CLI &amp; Console](/categories/cli)
4. /
5. phpnl/mcp

ActiveLibrary[CLI &amp; Console](/categories/cli)

phpnl/mcp
=========

A framework-agnostic PHP SDK for the Model Context Protocol (MCP). Connect your PHP application to AI models like Claude in minutes.

v0.1.1(1mo ago)12MITPHPPHP ^8.3CI passing

Since Apr 17Pushed 1mo agoCompare

[ Source](https://github.com/Php-nl/mcp)[ Packagist](https://packagist.org/packages/phpnl/mcp)[ Docs](https://php.nl)[ RSS](/packages/phpnl-mcp/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (2)Dependencies (3)Versions (4)Used By (0)

phpnl/mcp
=========

[](#phpnlmcp)

[![CI](https://github.com/Php-nl/mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/Php-nl/mcp/actions/workflows/ci.yml)[![codecov](https://camo.githubusercontent.com/13c214b8d49766114ca23f386103616e839d0f9d09071141f35c52cacf23b1c1/68747470733a2f2f636f6465636f762e696f2f67682f5068702d6e6c2f6d63702f6272616e63682f6d61696e2f67726170682f62616467652e737667)](https://codecov.io/gh/Php-nl/mcp)[![Latest Version](https://camo.githubusercontent.com/0b6fcaf983a541f75b746a898041d35a5f78b145522fca23349a30a9b92fa01f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068706e6c2f6d63702e737667)](https://packagist.org/packages/phpnl/mcp)[![License](https://camo.githubusercontent.com/246d6d66be18dfa5f381b193a3a814be176314da5ce58774f6129cb0e43ea2e7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7068706e6c2f6d63702e737667)](LICENSE)

A framework-agnostic PHP SDK for the [Model Context Protocol (MCP)](https://modelcontextprotocol.io). Connect your PHP application to AI models like Claude in minutes — zero runtime dependencies.

```
composer require phpnl/mcp
```

---

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

[](#table-of-contents)

- [What is MCP?](#what-is-mcp)
- [Quick Start](#quick-start)
- [Tools](#tools)
    - [Registering a tool](#registering-a-tool)
    - [Type-safe parameters](#type-safe-parameters)
    - [Parameter descriptions](#parameter-descriptions)
    - [Optional parameters](#optional-parameters)
    - [Input validation](#input-validation)
    - [Rich tool results](#rich-tool-results)
    - [Progress notifications](#progress-notifications)
- [Resources](#resources)
- [Prompts](#prompts)
- [Middleware](#middleware)
- [Exception handling](#exception-handling)
- [Transports](#transports)
    - [STDIN/STDOUT (default)](#stdinstdout-default)
    - [HTTP + SSE](#http--sse)
- [Developer CLI](#developer-cli)
- [API reference](#api-reference)
- [Requirements](#requirements)
- [Testing](#testing)
- [License](#license)

---

What is MCP?
------------

[](#what-is-mcp)

The Model Context Protocol is an open standard that lets AI models interact with external tools, data sources, and services. An MCP server exposes:

- **Tools** — functions the AI can call (e.g. query a database, send an email)
- **Resources** — read-only data the AI can reference (e.g. config files, documentation)
- **Prompts** — reusable prompt templates the AI can retrieve and use

This library implements the MCP server side in PHP.

---

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

[](#quick-start)

Create `server.php`:

```
