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.
Download ldkafka/yii3-mcp-server
More information about ldkafka/yii3-mcp-server
Files in ldkafka/yii3-mcp-server
Package yii3-mcp-server
Short Description Model Context Protocol (MCP) server framework for Yii3 applications - enables AI assistants to interact with your app via custom tools
License BSD-3-Clause
Homepage https://github.com/ldkafka/yii3-mcp-server
Informations about the package yii3-mcp-server
Yii3 MCP Server
Build AI-powered tools for your Yii3 application with Model Context Protocol
A framework for building Model Context Protocol (MCP) servers in Yii3 applications. Enable AI assistants like GitHub Copilot to interact with your application through custom tools.
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:
- Query your database
- Read project files
- Execute commands
- Analyze data
- Interact with your application
Features
- Framework, not an app - Integrate into any Yii3 project
- Tool-based architecture - Build custom tools by implementing
McpToolInterface - Simple API - One interface (
McpToolInterface) is all you need to create powerful AI tools - Type-safe - Full PHP 8.1+ type declarations and PHPDoc
- Production-ready - Security patterns, error handling, validation
- Easy integration - Works with VS Code, Cursor, and other MCP clients
- Well-documented - Comprehensive guides and examples
Quick Start
1. Install via Composer
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:
That's it! Your AI assistant can now use your tools.
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, Docker, WSL, SSH setup
📖 Creating Tools - Build custom tools guide
📖 Installation - Detailed setup instructions
📖 Deployment - Production deployment strategies
📖 Examples - Complete working examples
Deployment Scenarios
Local Development
Docker
WSL (Windows)
See EDITOR_INTEGRATION.md for more scenarios.
Security
Read-Only by Default: The example MysqlQueryTool enforces read-only operations:
Recommendations:
- Use dedicated read-only database users
- Store credentials in params-local.php (gitignored)
- Validate all tool inputs
- Log tool usage for auditing
Requirements
- PHP: 8.1 or higher
- Yii3: yiisoft/yii-console ^2.0
- Optional: Database extensions for DB tools
Architecture
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new features
- Submit a pull request
License
This project is licensed under the BSD-3-Clause License.
Support
- Issues: GitHub Issues
- Documentation: docs/
- MCP Specification: modelcontextprotocol.io
Credits
Built with ❤️ for the Yii3 community.
- MCP Protocol: Anthropic
- Yii Framework: Yii Software
Ready to empower your AI assistant? Install now and start building custom tools!