codeigniter-mcp
You can scaffold, validate, and lint CodeIgniter 4 code, and run migrations.
Generate full CRUD resources: controller, service, repository, entity, migration, tests.
Generate individual PHP controllers, services, and repositories.
Validate routes against Routes.php for collisions and CI4 syntax.
Run migrations up/down with explicit confirmation.
Lint PHP files against framework conventions (strict types, naming, no SQL in controllers, etc.).
Generates and maintains idiomatic CodeIgniter framework code, including scaffolding full CRUD resources, controllers, services, repositories, migrations, and route validation.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@codeigniter-mcp Generate a Product resource CRUD with title, price, and description fields."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
codeigniter-mcp
πΌ Enterprise Modernization & Custom AI Tooling: Migrating monolithic CodeIgniter 3 systems to CI4? Need custom MCP servers, architecture audits, or dedicated team support? Message Cristofher on Agensi →
Model Context Protocol (MCP) server built for high-velocity AI development on CodeIgniter 4 and modern PHP architectures (MVC + Services/Repository layer).
Eliminates LLM hallucinations, scaffolds complete production-ready modules in <15 milliseconds, and unlocks real-time live database and route introspection directly inside your AI IDE (Claude Code, Cursor, Windsurf, Trae, OpenAI Codex, and Google Project Astra).
Architecture: The "Top 1%" Dual-Engine Design
Most MCP servers are either purely external (blind to running application state) or heavy PHP extensions. codeigniter-mcp uses a Dual-Engine Architecture bridging the best of both worlds:
flowchart TB
subgraph AI["AI Coding Assistant"]
Client["Claude Code / Cursor / Windsurf / Trae / Codex / Astra"]
end
subgraph Outer["Engine 1: Outer Server (Node/TypeScript)"]
MCPNode["codeigniter-mcp (stdio / HTTP)"]
Scaffold["Lightning Scaffolding (<15 ms)\nCRUD, Controllers, Services, Entities"]
Linter["AST Linter & Conventions\nStrict types, PascalCase, Zero-SQL Controllers"]
RouteVal["Route Collision Analyzer\nCI4 placeholders, (:segment), $routes->resource()"]
Migrator["Safe Migration Runner\nExplicit confirmation, interpreted PHP errors"]
end
subgraph Inner["Engine 2: Inner In-App Server (PHP Spark Command)"]
SparkCmd["php spark mcp:serve\n(Generated via scaffold_ci4_mcp_server)"]
LiveDB["Live DB Introspection\nReal tables, columns, nullability, keys"]
SafeQuery["Safe SELECT Query Engine\nCapped row limit, mutation blocking"]
ActiveRoutes["Live Route Reflector\nReads compiled Services::routes()"]
MigStatus["Migration Version Status\nReads active batch history"]
end
Client -->|Local stdio or Streamable HTTP| MCPNode
MCPNode --> Scaffold
MCPNode --> Linter
MCPNode --> RouteVal
MCPNode --> Migrator
MCPNode -.->|Generates app/Commands/McpServer.php| SparkCmd
Client -.->|Direct live introspection| SparkCmd
SparkCmd --> LiveDB
SparkCmd --> SafeQuery
SparkCmd --> ActiveRoutes
SparkCmd --> MigStatusOuter Engine (
codeigniter-mcp): Runs in Node/TypeScript overstdioorhttp. Handles sub-millisecond code scaffolding, static syntax validation, and route collision checks without touching PHP runtime dependencies.Inner Engine (
php spark mcp:serve): Scaffolds a zero-dependency, native CodeIgniter 4 Spark command (app/Commands/McpServer.php) that runs a pure JSON-RPC 2.0 MCP server over stdio for real-time live schema reflection, safe read-only SQL queries, and compiled route inspection.
Related MCP server: MySQL MCP Server
Highlights
8 Production Tools: Complete CRUD scaffolding, modular controllers, services, repositories, route validation, migration runner, AST convention linter, and native CI4 MCP server generator.
Vibecoding Ready (Zero Hallucinations): The AI assistant never confuses CI3, Laravel, and CI4 syntax. Generates clean
BaseController, dependency-injected Services, Query Builder Models, and CSRF-protected forms.Enterprise-Grade Security:
Symlink Traversal Mitigation: Canonical
realpathSyncresolution prevents reading or writing outsideAPP_ROOT.DNS Rebinding Protection: Enforces strict
Hostheader matching (returns 403 Forbidden).HTTP API Key Authentication: Supports
Authorization: Bearer <key>orX-API-Keyheaders.Safe PDO Mutations: Prevents false 404s on unchanged MySQL row updates (
rowCount() > 0 || $this->findById($id)).Destructive Operations Guarded: Requires explicit
confirm: trueoroverwrite: true.
4 Convention Resources + 3 Token-Saving Prompts: Compact prompt templates save token context and speed up LLM responses.
AI Agent Skill (Agensi.io Marketplace)
Prefer installing as a ready-to-use AI Agent Skill?
Get the CodeIgniter 4 Master skill directly from Agensi.io:
Plug-and-play workflow instructions (
SKILL.md) for Claude Code, Cursor, Trae, Copilot, and Windsurf.Architectural Guardrails: Guarantees zero SQL in controllers, CSRF-protected forms, and type safety.
Automated MCP Triggers: Configures your agent to automatically invoke
codeigniter-mcptools when creating modules or inspecting databases.
Quickstart
Run with npx (No installation needed)
npx -y codeigniter-mcpInstall globally
npm install -g codeigniter-mcpFrom source (Contributors)
git clone https://github.com/X-Gunner/codeigniter-mcp.git
cd codeigniter-mcp
npm install
npm run build
npm test
npm run verifyIDE & AI Agent Configuration
1. Claude Code / Claude Desktop
Add to claude_desktop_config.json or run claude mcp add codeigniter-mcp:
{
"mcpServers": {
"codeigniter-mcp": {
"command": "npx",
"args": ["-y", "codeigniter-mcp"],
"env": {
"APP_ROOT": "/absolute/path/to/your/codeigniter4_project",
"RATE_LIMIT_PER_MINUTE": "30"
}
}
}
}2. Cursor / Windsurf / Trae
In your project root or global settings (.cursor/mcp.json or settings UI):
{
"mcpServers": {
"codeigniter-mcp": {
"command": "npx",
"args": ["-y", "codeigniter-mcp"],
"env": {
"APP_ROOT": "/absolute/path/to/your/codeigniter4_project"
}
}
}
}3. Remote Agents / OpenAI Codex / Google Project Astra (Streamable HTTP)
For cloud agents that connect over HTTP instead of spawning local sub-processes:
# Start server in HTTP mode
MCP_TRANSPORT=http MCP_PORT=3000 MCP_BIND_HOST=127.0.0.1 MCP_API_KEY=secret_token APP_ROOT=/path/to/project npx codeigniter-mcpConfigure your remote AI agent:
{
"mcpServers": {
"codeigniter-mcp": {
"url": "http://127.0.0.1:3000/mcp",
"headers": {
"Authorization": "Bearer secret_token"
}
}
}
}Available Tools (8 Tools)
Tool | Purpose | Key Parameters |
| Generates full CRUD in ~15 ms: Controller + Service + Model/Repository + Migration + View + Tests (8 files). |
|
| Generates standalone Controller with strict validation; enforces zero SQL in controllers. |
|
| Generates business logic Service with contract-first DI (injects Model in CI4). |
|
| Generates Repository interface + PDO implementation (no-op in CI4, data lives in Models). |
|
| Analyzes |
|
| Executes native migrations ( |
|
| Lints PHP source code against framework conventions and AST security rules. |
|
| Scaffolds native CI4 in-app MCP command ( |
|
In-App Live Introspection (php spark mcp:serve)
Once you run scaffold_ci4_mcp_server, your CodeIgniter 4 application gains its own native MCP server:
php spark mcp:serveThis exposes live runtime tools to your AI assistant:
ci4_db_tables: Reflects active database schema, columns, data types, and primary keys.ci4_db_query: Runs safe, read-onlySELECTqueries (capped at 50 rows, destructive keywords blocked).ci4_routes_list: Reads dynamically compiled routes directly fromServices::routes().ci4_migration_status: QueriesServices::migrations()for active and pending migration batches.
Token-Saving Prompts (3 Prompts)
Compact input templates that minimize token consumption:
Prompt | Description |
| Converts compact definitions (e.g. |
| Prepares migration direction while enforcing safety confirmation. |
| Directs the model to inspect and repair a specific file against framework standards. |
Convention Resources (4 Resources)
Read-only context injected into the LLM context window:
convention://naming: Rules for PascalCase, camelCase, kebab-case, and mandatory suffixes.convention://architecture: Explains MVC + Service + Repository separation.convention://folder-structure: CodeIgniter 4 directory tree mapping.convention://security-rules: Guidelines for CSRF tokens, PDO parameterized statements, and strict typing.
Configuration Variables
Variable | Default | Description |
| β | Required. Absolute path to the PHP application root directory. |
|
| Maximum write/scaffold operations permitted per minute per session. |
|
| Communication protocol ( |
|
| Port for Streamable HTTP transport mode. |
|
| Local IP binding to guard against DNS rebinding attacks. |
| β | Optional Bearer token or X-API-Key required for HTTP transport. |
|
| Path or name of the PHP CLI binary to execute. |
Testing & Quality Assurance
# Run complete test suite (165 tests across 17 files)
npm test
# Typecheck with zero warnings
npm run typecheck
# Acceptance checklist against real stdio MCP transport
npm run verifycodeigniter-mcp β acceptance checklist
β
Handshake: serverInfo.name = codeigniter-mcp
β
Exposes 8 tools (found 8)
β
Exposes 4 convention resources (found 4)
β
Exposes 3 token-saving prompts (found 3)
β
scaffold_full_resource creates 8 files on disk (7 ms)
β
php -l passes on all generated files (8 files OK)
β
lint_against_framework_rules β compliant
β
validate_route POST /orders β valid
β
run_migration without confirm β blocked (zero executions)
β
run_migration with confirm=true executes via bin/migrate
β
scaffold again β no overwrite, 8 files skipped
β
Path traversal outside APP_ROOT β ValidationError
β
Runner failure β actionable MigrationFailedError
Result: 13 passed Β· 0 failed Β· 0 skippedDocumentation
docs/tools.md β Comprehensive parameter references for all 8 tools.
docs/profiles.md β Profiles, auto-detection (
ci4vsspec), and configuration.docs/security.md β Deep dive into the security architecture and guardrails.
docs/testing.md β Testing strategy, E2E fixtures, and CI automation.
πΌ Enterprise Support, Migration & Consulting Services
Need dedicated support, custom tool development, or legacy modernization for your engineering team?
We offer professional architecture and migration services tailored for enterprise CodeIgniter ecosystems:
Legacy Migration (CI3 β CI4): Safe, phased migration of legacy monolithic CodeIgniter 3 systems to modern CodeIgniter 4 + PHP 8.2+ with clean MVC, Service layer, and typed entities.
Custom MCP & AI Tooling: Custom-tailored Model Context Protocol servers and specialized IDE prompts tailored to your proprietary schema, internal libraries, and coding standards.
Architecture & Security Audits: Comprehensive review of existing repositories to eliminate controller SQL leakage, harden PDO parameters, implement CSRF/Auth safeguards, and modernize routing.
Monthly Retainer / Dedicated Support: Direct SLA-backed architecture advisory, prompt engineering support, and framework maintenance for engineering teams.
π Inquire or Request a Consultation:
Direct Chat & Messages: Message Cristofher Robles on Agensi
Marketplace Skill: Available on Agensi.io (
CodeIgniter 4 Master)
Contributing
Contributions are welcome! Please read CONTRIBUTING.md before submitting pull requests.
License
Distributed under the MIT License. Copyright (c) 2026 Cristofher Robles. See LICENSE for more information.
Available Tools
7 toolslint_against_framework_rulesLint against the framework conventionsA
Validates a PHP file of the project against the framework conventions: strict_types, naming, no queries in controllers, input validation and repositories behind an interface. Returns structured violations; compliant=false when there is any error.
Inputs: filePath (required).
run_migrationRun migrations (DESTRUCTIVE)A
Runs framework migrations (up/down) through the project's native migration runner (spec: php bin/migrate; ci4: php spark migrate). DESTRUCTIVE OPERATION: requires an explicit confirm: true. Without that flag nothing is executed.
Inputs: confirm (required), direction (required), migrationName.
scaffold_controllerGenerate PHP ControllerA
Generates a PHP Controller for a resource (presentation layer only). The controller only calls the corresponding Service: zero queries and zero inline validation. Does not overwrite existing files unless overwrite=true.
Inputs: resourceName (required), methods, overwrite.
scaffold_full_resourceGenerate a complete CRUD resourceA
Generates the full CRUD of a PHP resource: Controller, Service, Repository (interface + implementation), Entity, Migration and tests (unit & integration). Requires overwrite=true to overwrite existing files.
Inputs: fields (required), resourceName (required), overwrite, withTests, +1 more.
scaffold_repositoryGenerate PHP Repository (interface + implementation)A
Generates the Repository of a resource: ALWAYS the interface (contract) and the implementation (PDO adapter with prepared statements) together. Does not overwrite existing files unless overwrite=true.
Inputs: fields (required), resourceName (required), overwrite.
scaffold_serviceGenerate PHP ServiceA
Generates a PHP Service for a resource (business logic + input validation). Receives the Repository through dependency injection via interface (contract first). Does not overwrite existing files unless overwrite=true.
Inputs: resourceName (required), overwrite, withRepository.
validate_routeValidate a route against Routes.phpA
Verifies (read-only) that a route does not collide with the routes registered in app/Config/Routes.php and follows the framework's kebab-case {param} syntax. Never modifies files.
Inputs: path (required), method (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
TDQS
Scored across 7 tools
Each tool targets a clearly distinct action: layer-specific scaffolds, full resource scaffolding, route validation, migration execution, and linting. The full resource tool is explicitly named and described as a superset, so there is little risk of misselection.
All tools follow a consistent verb-first snake_case pattern: scaffold_*, validate_route, run_migration, lint_against_framework_rules. The naming conventions are uniform and predictable.
Seven tools is well-scoped for a CodeIgniter scaffolding and validation server. Each tool earns its place and the set is neither bloated nor thin.
The server covers the main resource scaffolding workflow, routing validation, migrations, and framework linting. Minor gaps exist such as no standalone entity/migration/test generator outside the full resource scaffold, but common workflows can be completed without dead ends.
Maintenance
Related MCP Connectors
The Mercado Pago MCP Server implements the Model Context Protocol to provide AI agents and LLMs with access to Mercado Pago's APIs and tools within compatible development environments. It acts as an intermediary that translates Mercado Pago resources into executable functions (tools) that AI applications can invoke to perform actions and automate flows. The server simplifies integration, enables using documentation to implement or improve code, and optimizes operations through natural language interactions without manual implementations.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yoβ¦
A Model Context Protocol (MCP) application for automated GitHub PR analysis and issue management.β¦
A MCP server built for developers enabling Git based project management with project and personalβ¦
Related MCP Servers
- AlicenseBqualityDmaintenanceA comprehensive Model Context Protocol server that provides advanced Node.js development tooling for automating project creation, component generation, package management, and documentation with AI-powered assistance.79MIT
- AlicenseBqualityBmaintenanceComprehensive Model Context Protocol server for MySQL databases featuring 191 specialized tools for CRUD operations, JSON functions, spatial/GIS, schema management, performance monitoring, and advanced features like OAuth 2.1 authentication and connection pooling.43135 npm11MIT
- AlicenseAqualityDmaintenanceA production-ready Model Context Protocol (MCP) server that bridges your Symfony/PHP project with LLMs such as Claude. It exposes tools that let the AI read your project's routes, services, Twig templates, and PHP source code.8MIT
- FlicenseNot gradedqualityDmaintenanceA Model Context Protocol server integrating developer tools including Git control, document conversion, remote SSH execution, database operations, and utilities for automation and development productivity.1-