PHPackages                             xp-forge/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. xp-forge/mcp

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

xp-forge/mcp
============

Model Context Protocol

v0.13.1(3mo ago)0188↓33.3%[1 issues](https://github.com/xp-forge/mcp/issues)[2 PRs](https://github.com/xp-forge/mcp/pulls)BSD-3-ClausePHPPHP &gt;=7.4.0CI passing

Since Jun 14Pushed 2mo agoCompare

[ Source](https://github.com/xp-forge/mcp)[ Packagist](https://packagist.org/packages/xp-forge/mcp)[ Docs](http://xp-framework.net/)[ RSS](/packages/xp-forge-mcp/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (21)Used By (0)

Model Context Protocol
======================

[](#model-context-protocol)

[![Build status on GitHub](https://github.com/xp-forge/mcp/workflows/Tests/badge.svg)](https://github.com/xp-forge/mcp/actions)[![XP Framework Module](https://raw.githubusercontent.com/xp-framework/web/master/static/xp-framework-badge.png)](https://github.com/xp-framework/core)[![BSD Licence](https://raw.githubusercontent.com/xp-framework/web/master/static/licence-bsd.png)](https://github.com/xp-framework/core/blob/master/LICENCE.md)[![Requires PHP 7.4+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-7_4plus.svg)](http://php.net/)[![Supports PHP 8.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-8_0plus.svg)](http://php.net/)[![Latest Stable Version](https://camo.githubusercontent.com/f9aa5bdad8e2f696a81b36ba679d4fa5d578dae4afcd28b696588fe7a35c3269/68747470733a2f2f706f7365722e707567782e6f72672f78702d666f7267652f6d63702f76657273696f6e2e737667)](https://packagist.org/packages/xp-forge/mcp)

Implements the [Model Context Protocol](https://modelcontextprotocol.io/) for the XP Framework.

Client
------

[](#client)

Connecting to an MCP server:

```
use io\modelcontextprotocol\McpClient;
use util\cmd\Console;

// Use streamable HTTP
$client= new McpClient('http://localhost:3001');

// Use standard I/O
$client= new McpClient(['docker', 'run', '--rm', '-i', 'mcp/time']);

$response= $client->call('tools/list');
Console::writeLine($response->value());
```

Server
------

[](#server)

Uses the [xp-forge/web](https://github.com/xp-forge/web) library:

```
use io\modelcontextprotocol\McpServer;
use io\modelcontextprotocol\server\{Tool, Param};
use web\Application;

class Test extends Application {

  public function routes() {
    return new McpServer([
      'greeting' => new class() {

        /** Sends a greeting */
        #[Tool]
        public function greet(#[Param('Whom to greet')] $name= null) {
          return 'Hello, '.($name ?? 'unknown user');
        }
      }
    ]);
  }
}
```

Run this via `xp -supervise web Test`.

Organizing code
---------------

[](#organizing-code)

MCP tools, resources and prompts may be organized into classes as follows:

```
namespace com\example\api;

use io\modelcontextprotocol\server\{Resource, Prompt, Tool, Param, Implementation};

#[Implementation]
class Greeting {

  /** Dynamic greeting for a user */
  #[Resource('greeting://user/{name}')]
  public function get($name) {
    return "Hello {$name}";
  }

  /** Greets users */
  #[Prompt]
  public function user(
    #[Param('Whom to greet')] $name,
    #[Param(type: ['type' => 'string', 'enum' => ['casual', 'friendly']])] $style= 'casual'
  ) {
    return "Write a {$style} greeting for {$name}";
  }

  /** Sends a given greeting by email */
  #[Tool]
  public function send(
    #[Param('Recipient email address')] $recipient,
    #[Param('The text to send')] $greeting
  ) {
    // TBI
  }
}}
```

The web application then becomes this:

```
use io\modelcontextprotocol\McpServer;
use web\Application;

class Test extends Application {

  public function routes() {
    return new McpServer('com.example.api');
  }
}
```

Authentication
--------------

[](#authentication)

To add OAuth2 authentication to your server, use the following:

```
use io\modelcontextprotocol\McpServer;
use io\modelcontextprotocol\server\{ImplementationsIn, OAuth2Gateway, Clients, UseSessions};
use web\Application;
use web\session\InFileSystem;

class Test extends Application {

  public function routes() {
    $clients= new class() extends Clients { /* TBI */ };

    $sessions= (new InFileSystem())->named('oauth');
    $gateway= new OAuth2Gateway('/oauth', $clients, new UseSessions($sessions));

    $auth= /* Some class extending web.auth.Authentication */;

    $server= new McpServer(new ImplementationsIn('impl'));
    return [
      '/mcp'   => $gateway->authenticate($server),
      '/oauth' => $gateway->flow($auth, $sessions),
      '/.well-known/oauth-protected-resource'   => $gateway->resource(),
      '/.well-known/oauth-authorization-server' => $gateway->metadata(),
    ];
  }
}
```

See also
--------

[](#see-also)

-
-
-
-
-

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance82

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~14 days

Recently: every ~7 days

Total

17

Last Release

102d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/07d18d882c8b4aaf3466432f64018214f2771eda333202175431ee7233795376?d=identicon)[thekid](/maintainers/thekid)

---

Top Contributors

[![thekid](https://avatars.githubusercontent.com/u/696742?v=4)](https://github.com/thekid "thekid (163 commits)")

---

Tags

annotationsmcp-clientmcp-promptsmcp-resoucesmcp-servermcp-toolsmodelcontextprotocolphp7php8xp-frameworkmodulexp

### Embed Badge

![Health badge](/badges/xp-forge-mcp/health.svg)

```
[![Health](https://phpackages.com/badges/xp-forge-mcp/health.svg)](https://phpackages.com/packages/xp-forge-mcp)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
