PHPackages                             mwstake/mediawiki-component-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. mwstake/mediawiki-component-mcp

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

mwstake/mediawiki-component-mcp
===============================

Tool provider and executor for MCP server

11PHP

Since Feb 9Pushed 3mo agoCompare

[ Source](https://github.com/hallowelt/mwstake-mediawiki-component-mcp)[ Packagist](https://packagist.org/packages/mwstake/mediawiki-component-mcp)[ RSS](/packages/mwstake-mediawiki-component-mcp/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

MCP server companion
====================

[](#mcp-server-companion)

This component provides tool definitions and execution ability to the MCP server. It is used by the MCP server to retrieve tool definitions and execute them, allowing tools to be defined in MediaWiki extensions and used by the MCP server (which is very hard and inconvenient to do in the MCP server itself, as it is a Node.js application).

Setup on wiki side
------------------

[](#setup-on-wiki-side)

To set up the component, add the following to your `LocalSettings.php` file:

```
$GLOBALS['mwsgTokenAuthenticatorServiceAllowedRestPaths'] = $GLOBALS['mwsgTokenAuthenticatorServiceAllowedRestPaths'] ?? [];

$GLOBALS['mwsgTokenAuthenticatorServiceAllowedRestPaths'][] = '/mws/v1/mcp/get_wiki_map';
$GLOBALS['mwsgTokenAuthenticatorServiceAllowedRestPaths'][] = '/mws/v1/app-token/generate';
$GLOBALS['mwsgTokenAuthenticatorServiceAllowedRestPaths'][] = '/mws/v1/app-token/verify';
$GLOBALS['mwsgTokenAuthenticatorServiceAllowedRestPaths'][] = '/mws/v1/mcp/list_tools';
$GLOBALS['mwsgTokenAuthenticatorServiceAllowedRestPaths'][] = '/mws/v1/mcp/get_wiki_map';
```

Adding tools
------------

[](#adding-tools)

Create a class defining your tool

```
use MWStake\MediaWiki\Component\MCP\ExecutionHandler\RestApiHandler;
use MWStake\MediaWiki\Component\MCP\FieldSchema;
use MWStake\MediaWiki\Component\MCP\IMcpTool;
use MWStake\MediaWiki\Component\MCP\IMcpToolExecutionHandler;
use MWStake\MediaWiki\Component\MCP\ToolDefinition;

class CreatePage implements IMcpTool {

	public function getKey(): string {
		return 'createPage';
	}

	/**
	 * @return ToolDefinition
	 */
	public function getDefinition(): ToolDefinition {
		$inputSchema = ( new FieldSchema() )
			->addString( 'source', 'Text, content of the page' )
			->addString( 'title', 'Title of the page' )
			->addString( 'comment', 'Summary of the edit. Can be null' )
			->setNullable( 'comment' )
			->setRequired( [ 'source', 'title', 'comment' ] );

		$outputSchema = ( new FieldSchema() )
			->addInteger( 'id', 'ID of the page that was just created' )
			->addString( 'title', 'Title of the page that was just created' )
			->addString( 'key', 'DB-key of the page that was just created' );

		return new ToolDefinition(
			'Create a wiki page',
			'Create aage with given content',
			$inputSchema,
			$outputSchema
		);
	}

	/**
	 * @return IMcpToolExecutionHandler
	 */
	public function getExecutionMethod(): IMcpToolExecutionHandler {
		return new RestApiHandler( '/v1/page/', 'POST' );
	}
}
```

Or, specify is as a generic tool (no custom class)

```
$inputSchema = ( new FieldSchema() )
    ->addString( 'source', 'Text, content of the page' )
    ->addString( 'title', 'Title of the page' )
    ->addString( 'comment', 'Summary of the edit. Can be null' )
    ->setNullable( 'comment' )
    ->setRequired( [ 'source', 'title', 'comment' ] );

$outputSchema = ( new FieldSchema() )
    ->addInteger( 'id', 'ID of the page that was just created' )
    ->addString( 'title', 'Title of the page that was just created' )
    ->addString( 'key', 'DB-key of the page that was just created' );

$definition = new ToolDefinition(
    'Create a wiki page',
    'Create aage with given content',
    $inputSchema,
    $outputSchema
);

$tool = new MWStake\MediaWiki\Component\MCP\Tool\GenericTool(
    'createPage',
    $definition,
    new RestApiHandler( '/v1/page/', 'POST' )
);
```

Then, register the tool in the DI container:

```
function onMediaWikiServices( $services ) {
    $registry = $services->getService( 'MWStake.MCP.ToolRegistry' );
    $registry->registerTool( $tool );
}
```

### Execution methods

[](#execution-methods)

As seen above, tool returns `IMcpToolExecutionHandler`. This defines how this tool should be executed. Tools can execute a regular, already existing API

```
return new RestApiHandler( '/v1/page/', 'POST' );
return new ActionApiHandler( 'edit' )
```

Or they can define a custom handler for the tool

```
class MyCustomToolExecutor implement IMcpToolExecutor {
    public function execute( IMcpTool $tool, array $input ): array {
        // Process $input (which will be in format as specified by tool's input schema) and execute the tool's action
        // Return output in format specified by tool's output schema
    }
}
```

in which case, provide ObjectFactory spec for your custom executor in the `getExecutionMethod` method of the tool

```
return new DirectExecution( [
    'class' => MyCustomToolExecutor::class,
    'args' => ...
] );
```

See `examples/Examples.MD` for more examples of tools and execution methods.

Notes
-----

[](#notes)

- Avoid implementing tools that run `POST` requests against ActionAPI. It requires the CSRF token to be retrieved, increasing the traffic and latency. Use REST counterparts wherever possible
- Tool list is always retrieved from `w`. So it is always same for all instances, and all tools retrieved need to be available for all intances (which is the case anyways, but just to mention :))

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance55

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity12

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/161c38b5448b71865cf0652b6974ed489dd3683b5d6e1814973cea6cb66c8f1d?d=identicon)[dsavuljesku](/maintainers/dsavuljesku)

---

Top Contributors

[![it-spiderman](https://avatars.githubusercontent.com/u/13665198?v=4)](https://github.com/it-spiderman "it-spiderman (4 commits)")

### Embed Badge

![Health badge](/badges/mwstake-mediawiki-component-mcp/health.svg)

```
[![Health](https://phpackages.com/badges/mwstake-mediawiki-component-mcp/health.svg)](https://phpackages.com/packages/mwstake-mediawiki-component-mcp)
```

###  Alternatives

[dnoegel/php-xdg-base-dir

implementation of xdg base directory specification for php

6.3k239.4M16](/packages/dnoegel-php-xdg-base-dir)[thiagoalessio/tesseract_ocr

A wrapper to work with Tesseract OCR inside PHP.

3.0k3.3M25](/packages/thiagoalessio-tesseract-ocr)[pyrech/composer-changelogs

Display changelogs after each composer update

5904.0M25](/packages/pyrech-composer-changelogs)[mark-gerarts/auto-mapper-plus

An AutoMapper for PHP

5623.2M21](/packages/mark-gerarts-auto-mapper-plus)[wamania/php-stemmer

Native PHP Stemmer

1434.0M33](/packages/wamania-php-stemmer)[geocoder-php/plugin

Plugins to Geocoder providers

705.1M2](/packages/geocoder-php-plugin)

PHPackages © 2026

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