Download the PHP package ldkafka/yii3-mcp-server without Composer

On this page you can find all versions of the php package ldkafka/yii3-mcp-server. 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 yii3-mcp-server

Yii3 MCP Server

Build AI-powered tools for your Yii3 application with Model Context Protocol

PHP Version Yii Version

A framework for building Model Context Protocol (MCP) servers in Yii3 applications. Enable AI assistants like GitHub Copilot, Claude Code and Claude Desktop to interact with your application through custom tools, over stdio (a local process) or Streamable HTTP (a remote endpoint).


What is MCP?

Model Context Protocol is an open protocol that enables AI assistants to interact with external tools and data sources. Think of it as an API for AI - instead of REST endpoints for humans, MCP provides a standardized way for AI to:


Features

Quick Start

1. Install via Composer

The stdio command (mcp:serve) needs symfony/console, and yiisoft/yii-console to run it in a Yii3 console application. Yii3 application templates already include both; otherwise:

2. Copy Configuration Templates

Configure based on your Yii3 app structure:

Note: The standard yiisoft/app template uses config/console/ for console commands and config/common/di/ for DI configuration.

Or manually edit config/console/commands.php (for yiisoft/app template):

3. Configure DI Container

Create config/common/di/mcp.php (for yiisoft/app template):

For custom tool registration, optionally create config/di-console.php to define tool dependencies.

4. Install Optional Dependencies (If Using Database Tools)

5. Configure Database (Optional - For MySQL Query Tool)

Create config/environments/dev/params.local.php:

Then edit config/environments/dev/params.php to load it:

Add to .gitignore:

6. Set APP_ENV (Yii3 Framework Requirement)

Create .env in project root:

Or for Docker environments, add fallback to yii entry point (before autoload):

7. Rebuild Config Cache

8. Verify Installation

You should see mcp:serve in the command list.

9. Run the Server

10. Create Your Own Tools

The power of this framework is in creating custom tools by implementing McpToolInterface:

Then register your tool in config/common/di/mcp.php:

See docs/CREATING_TOOLS.md for detailed guide.

11. Integrate with Your Editor

Add to VS Code settings.json:

Or, for Claude Code, add to the project's .mcp.json:

That's it! Your AI assistant can now use your tools.

12. Optional: Serve Over HTTP

The same server can be exposed as a remote endpoint (POST /mcp) protected by a bearer token, so assistants on other machines can use your tools without a local PHP process. See docs/HTTP_TRANSPORT.md. It also shows how to call the core from a framework without PSR-7 (a Yii2 controller) and how to answer OAuth-protected requests with BearerChallenge.


Example: Database Query Tool

The package includes MysqlQueryTool as a reference implementation:

Ask Copilot: "What tables are in the database?" and it will use this tool automatically!


Creating Custom Tools

Implement McpToolInterface:

Register in DI:


Documentation

📖 Editor Integration - VS Code, Claude Code, Docker, WSL, SSH setup
📖 Creating Tools - Build custom tools guide
📖 Installation - Detailed setup instructions
📖 HTTP Transport - Remote endpoint, authentication, reverse proxy, client config
📖 Changelog - Release notes


Deployment Scenarios

Local Development

Docker

WSL (Windows)

Remote (HTTP)

See HTTP_TRANSPORT.md for serving the endpoint.


Security

Read-Only by Default: The example MysqlQueryTool enforces read-only operations:

Recommendations:


Requirements


Protocol versions

Version How a client uses it What the server answers
2026-07-28 (modern) No handshake. Every request carries params._meta["io.modelcontextprotocol/protocolVersion"] and .../clientCapabilities; over HTTP also the MCP-Protocol-Version, Mcp-Method and (for tools/call) Mcp-Name headers, which must match the body server/discover, tools/list, tools/call. Every result has resultType: "complete" and the server's identity in _meta["io.modelcontextprotocol/serverInfo"]; server/discover and tools/list carry ttlMs and cacheScope. ping, logging/setLevel and initialize are unknown methods (-32601, HTTP 404)
2025-11-25, 2025-06-18, 2025-03-26, 2024-11-05 (legacy) initialize first, then MCP-Protocol-Version on later HTTP requests Exactly as in 1.5.0: initialize, ping, tools/list, tools/call

How a version is chosen: per request. A request whose params._meta names a modern version is served in it; any other request is legacy and served in the version agreed on initialize (the client's, when it is a legacy version this server speaks, otherwise 2025-11-25). A version the server does not speak, in the header or in _meta, is refused with -32022 (UnsupportedProtocolVersion, HTTP 400) listing ProtocolVersion::SUPPORTED; a modern request without its client capabilities gets -32602. Header rules and HTTP statuses: docs/HTTP_TRANSPORT.md.

Cache hints: new McpServer(..., cacheTtlMs: 0, cacheScope: McpServer::CACHE_PRIVATE) are the defaults: clients re-fetch whenever needed and never share a tool list across callers, which is right when tools vary per caller (scopes, caller-aware tools). A server whose list is the same for everyone may set a TTL and McpServer::CACHE_PUBLIC.


Architecture


Testing

The suite covers the JSON-RPC dispatcher, both transports and the authentication middleware; CI runs it on PHP 8.1 to 8.4.


Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new features
  4. Submit a pull request

License

This project is licensed under the BSD-3-Clause License.


Support


Credits

Built with ❤️ for the Yii3 community.


Ready to empower your AI assistant? Install now and start building custom tools!


All versions of yii3-mcp-server with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-json Version *
psr/http-factory Version ^1.0
psr/http-message Version ^1.1 || ^2.0
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0
psr/log Version ^1.1 || ^2.0 || ^3.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 ldkafka/yii3-mcp-server contains the following files

Loading the files please wait ...