Download the PHP package muxtorov98/yii2-mcp without Composer

On this page you can find all versions of the php package muxtorov98/yii2-mcp. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package yii2-mcp

yii2-mcp

MCP server integration for Yii2 applications on PHP 8.1+.

This package exposes Yii2 classes as MCP tools and MCP resources so AI agents can discover and call them through a standard JSON-RPC endpoint.

Package: muxtorov98/yii2-mcp

What This Package Does

What This Package Does Not Do

This package is an MCP server. It is not an LLM provider SDK.

That means:

Typical setup:

If you also want Yii2 itself to call an LLM, add a separate AI client component such as OpenAiClient, AnthropicClient, or your own adapter.

Requirements

Install

How It Works

  1. You create PHP classes and mark them with #[McpTool] or #[McpResource].
  2. The mcp component scans configured folders.
  3. The package builds MCP metadata and input schemas.
  4. AI clients connect to your /mcp endpoint.
  5. The client lists tools/resources and calls them when needed.

Minimal Working Setup

1. Configure the mcp component

Example for common/config/main.php or another shared config:

Notes:

Production-ready config example

If you want to run this package in a more serious environment, enable authentication, rate limiting, cache, and logging explicitly:

This package now includes:

Optional custom controller mapping

If you want your own controller namespace or route, map the package controller explicitly in your app config:

If you want a project-specific controller, extend the package controller:

File: frontend/controllers/McpController.php

Then map it:

2. Create the folder for MCP classes

Example:

3. Create a tool input class

File: common/mcp/SearchBooksInput.php

4. Create the tool handler

File: common/mcp/SearchBooksHandler.php

5. Create a resource

File: common/mcp/ApiDocsResource.php

File: common/mcp/ApiDocsProvider.php

6. Start your Yii2 web app

Your MCP endpoint will be available at:

If you use pretty URLs and route rules, you can map it to /mcp.

Example pretty URL rule:

AI Model Selection

This is the part most people mix up.

You do not set the AI model inside yii2-mcp.

You set the model inside the MCP client:

Example logic:

If You Also Want Yii2 To Call OpenAI

That is separate from MCP. Add your own AI component.

Example config:

In this setup:

These are different responsibilities.

Supported MCP Methods

The HTTP JSON-RPC endpoint currently supports:

JSON-RPC Examples

Initialize

List Tools

Call Tool

List Resources

Read Resource

Testing With curl

List tools

Call a tool

Tool Declaration Rules

#[McpTool(...)] options:

Example:

Resource Declaration Rules

#[McpResource(...)] options:

Example:

Validation

Validation is only applied when:

Example:

If validation fails, the MCP response returns an error payload.

Input Hydration

Tool input is hydrated by:

Example:

This can be mapped to:

Response Shape

Tool responses are normalized into JSON-friendly arrays.

Regular tool result:

Resource result:

Folder Layout Suggestion

Current Scope

This package currently provides:

This package does not yet provide:

Troubleshooting

Tools do not appear in tools/list

Check:

Validation is not running

Check:

Handler is not called

Check:

Resource is not returned

Check:

Unauthorized response

Check:

Rate limit exceeded

Check:

Development Notes

This package is currently an MVP skeleton. It is suitable as a starting point for a real Yii2 MCP package and can be extended with:


All versions of yii2-mcp with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-json Version *
yiisoft/yii2 Version ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package muxtorov98/yii2-mcp contains the following files

Loading the files please wait ...