PHPackages                             josbeir/cakephp-synapse - 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. [DevOps &amp; Deployment](/categories/devops)
4. /
5. josbeir/cakephp-synapse

ActiveCakephp-plugin[DevOps &amp; Deployment](/categories/devops)

josbeir/cakephp-synapse
=======================

CakePHP MCP Server Plugin - Expose CakePHP functionality via Model Context Protocol

0.2.0(1mo ago)78123MITPHPPHP &gt;=8.2CI passing

Since Nov 20Pushed 1mo agoCompare

[ Source](https://github.com/josbeir/cakephp-synapse)[ Packagist](https://packagist.org/packages/josbeir/cakephp-synapse)[ RSS](/packages/josbeir-cakephp-synapse/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (16)Versions (21)Used By (0)

[![PHPStan Level 8](https://camo.githubusercontent.com/ff3c7f8c8667ce643f47e74532748f673482a5f95d7d4269f925f2eebbe5117e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230382d627269676874677265656e)](https://github.com/josbeir/cakephp-synapse)[![Build Status](https://github.com/josbeir/cakephp-synapse/actions/workflows/ci.yml/badge.svg)](https://github.com/josbeir/cakephp-synapse/actions)[![codecov](https://camo.githubusercontent.com/d45a76190db165831f1edab271cd62523b20dbb6e25afb9e5c918013c28ad703/68747470733a2f2f636f6465636f762e696f2f6769746875622f6a6f73626569722f63616b657068702d73796e617073652f67726170682f62616467652e7376673f746f6b656e3d345647574a5154574835)](https://codecov.io/github/josbeir/cakephp-synapse)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![PHP Version](https://camo.githubusercontent.com/744f8821cc27dec8b0013ade48179731a44eadf4f943e0b1d9ffcb93f80177de/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e322532422d626c75652e737667)](https://www.php.net/releases/8.2/en.php)[![CakePHP Version](https://camo.githubusercontent.com/e4555ed03e5c2dfca6a44248a236ee5d773386c599fe5a8df5c77a102163a9cb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f43616b655048502d352e322532422d7265642e737667)](https://cakephp.org/)[![Packagist Downloads](https://camo.githubusercontent.com/33af368409fbc13da03a8b5575bd8dc2634e12936990f4e123e609bcc4ec9865/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a6f73626569722f63616b657068702d73796e61707365)](https://packagist.org/packages/josbeir/cakephp-synapse)

Synapse: a CakePHP MCP-Server plugin
====================================

[](#synapse-a-cakephp-mcp-server-plugin)

Expose your CakePHP application functionality via the Model Context Protocol (MCP).

[![CakePHP Synapse Hero](/docs/hero.jpg)](/docs/hero.jpg)

Table of Contents
-----------------

[](#table-of-contents)

- [Overview](#overview)
- [Features](#features)
- [Installation](#installation)
    - [Requirements](#requirements)
    - [Installing the Plugin](#installing-the-plugin)
- [Quick Start](#quick-start)
- [Configuration](#configuration)
- [Built-in Tools](#built-in-tools)
- [Built-in Prompts](#built-in-prompts)
    - [Creating Custom Tools, Resources, and Prompts](#creating-custom-tools-resources-and-prompts)
- [CLI usage](#cli-usage)
- [Running the Server](#running-the-server)
    - [Command Options](#command-options)
    - [Testing with MCP Inspector](#testing-with-mcp-inspector)
    - [Transport Options](#transport-options)
- [Discovery Caching](#discovery-caching)
- [Testing](#testing)
- [Contributing](#contributing)
- [License](#license)
- [Credits](#credits)

Overview
--------

[](#overview)

Synapse is a CakePHP plugin that implements the [Model Context Protocol (MCP)](https://modelcontextprotocol.io/), allowing AI assistants and other MCP clients to interact with your CakePHP application through a standardized interface.

Warning

This plugin uses the [MCP PHP SDK](https://github.com/modelcontextprotocol/php-sdk) which is currently in active development. Features and APIs may change as the SDK evolves.

The Model Context Protocol is an open protocol that enables seamless integration between AI assistants (like Claude) and your application's data and functionality. With Synapse, you can expose:

- **Tools**: Functions that AI assistants can call (e.g., database queries, route inspection)
- **Resources**: Data sources that can be read
- **Prompts**: Pre-configured templates for common tasks

Features
--------

[](#features)

- 🚀 **Rapid Integration**: Enable MCP support in your CakePHP app with minimal setup
- 🔍 **Attribute-Based Discovery**: Finds MCP tools, resources, and prompts using PHP 8+ attributes and class scanning
- 🛠️ **Built-in Tools**: Includes tools for system info, database schema exploration, route inspection, code execution, log inspection, cache management, ORM introspection, and more
- 📚 **Advanced Documentation Search**: Full-text search with fuzzy matching and relevance ranking, powered by SQLite FTS5 (indexes official CakePHP markdown docs)
- 🧩 **Customizable &amp; Extensible**: Easily define your own tools, resources, and prompts using attributes and configuration
- ⚡ **Prompt Workflows**: Built-in prompt flows for common development tasks, code review, debugging, and feature building

Installation
------------

[](#installation)

### Requirements

[](#requirements)

- PHP 8.2 or higher
- CakePHP 5.2 or higher

### Installing the Plugin

[](#installing-the-plugin)

Install via Composer as a development dependency:

```
composer require --dev josbeir/cakephp-synapse
```

Note

This plugin is typically used as a development tool to allow AI assistants to interact with your application during development. It should not be installed in production environments.

```
bin/cake plugin load --only-cli --optional Synapse
```

The plugin will automatically register itself and discover MCP elements in your application.

Tip

**After updating the plugin**, it's recommended to re-index the documentation to ensure all features work correctly:

```
bin/cake synapse index -d  # Destroy old index
bin/cake synapse index     # Re-index documentation
```

Quick Start
-----------

[](#quick-start)

1. **Install the plugin** (see above)
2. **Configure your MCP-enabled client**:

To connect Claude Code/Desktop or other MCP clients (VSCode/Zed/...):

1. Configure the client to use stdio transport
2. Point it to your CakePHP bin directory: `bin/cake synapse server`
3. The client will communicate with your app via the MCP protocol

Most clients require a **command** wich will be your cake executable `bin/cake` followed by **arguments**: `synapse server`

```
{
  "my-cakephp-app": {
    "command": "bin/cake",
    "args": ["synapse", "server"]
  }
}
```

Or run when using `DDEV` instance

```
{
  "my-cakephp-app": {
    "command": "ddev",
    "args": ["cake", "synapse", "server"],
  }
}
```

Configuration
-------------

[](#configuration)

Various configuration options are available for Synapse. Refer to `config/synapse.php` in this plugin for details on available settings and customization.

Built-in Tools
--------------

[](#built-in-tools)

Synapse includes several built-in tools and resources for common operations:

CategoryNameDescriptionSystem`system_info`Get CakePHP version, PHP version, debug mode, etc.System`config_read`Read configuration valuesSystem`debug_status`Check if debug mode is enabledSystem`list_env_vars`List all available environment variablesCode Execution`tinker`Execute arbitrary PHP code with full application contextDatabase`database_connections`List all configured database connectionsDatabase`database_schema`Get detailed schema information for tables (view all tables, inspect columns, constraints, indexes, understand foreign key relationships)Routes`list_routes`List all routes with filtering and sortingRoutes`get_route`Get detailed information about a specific routeRoutes`match_url`Find which route matches a given URLRoutes`detect_route_collisions`Find potential route conflictsDocumentation`search_docs`Search documentation with relevance ranking, fuzzy matching, and filteringDocumentation`get_doc`Retrieve full document content by document ID (format: `source::path`)Documentation`docs_stats`View index statistics and available sourcesDocumentation`docs://search/{query}`Search CakePHP documentation and return formatted resultsDocumentation`docs://content/{documentId}`Retrieve full document content by document ID (format: `source::path`)Commands`list_commands`List all available CakePHP console commands with optional filtering and sortingCommands`get_command_info`Get detailed information about a specific console command (options, arguments, help)Commands`run_command`Run a registered CakePHP console command in a subprocess with configurable timeoutLogs`log_list`List all log files in the application logs directory with size and modification timeLogs`log_read`Read the last N lines from a log file, optionally filtered by log level (error, warning, info, debug, …)Cache`cache_configs`List all configured CakePHP cache configurations with engine informationCache`cache_read`Read a value from a cache configuration by keyCache`cache_write`Write a string value to a cache configurationCache`cache_delete`Delete a key from a cache configurationCache`cache_clear`Clear all entries from a cache configurationORM`orm_describe`Describe a CakePHP ORM Table: associations, behaviors, display field, primary key, entity classORM`orm_find`Run a find query (`all`, `first`, or `count`) on an ORM Table with a configurable row limitWarning

The `tinker` tool executes arbitrary code in your application. Use responsibly and avoid modifying data without explicit approval.

Tip

The `tinker` tool can be used to query the database using CakePHP's ORM. The tinker context provides access to `$this->fetchTable()` for easy database operations.

Note

Documentation is indexed from the official [CakePHP markdown documentation](https://github.com/cakephp/docs-md). The index is built locally using SQLite FTS5 for fast, dependency-free full-text search.

Built-in Prompts
----------------

[](#built-in-prompts)

Synapse includes pre-defined prompt workflows that guide LLMs through common CakePHP development tasks. Prompts combine multiple tools (search docs, read documentation, tinker) into structured, best-practice workflows.

### Available Prompts

[](#available-prompts)

PromptDescriptionArguments`documentation-expert`Get comprehensive guidance on CakePHP features with examples`topic` (required), `depth` (optional: basic/intermediate/advanced)`debug-helper`Systematic debugging workflow for errors and issues`error` (required), `context` (optional: controller/model/database/view)`feature-builder`Guide for implementing complete features following conventions`feature` (required), `component` (optional: controller/model/behavior/helper/middleware/command/full-stack)`database-explorer`Explore database schema, relationships, and data`table` (required), `show` (optional: schema/data/relationships/all)`code-reviewer`Review code against CakePHP conventions and best practices`code` (required), `focus` (optional: conventions/security/performance/testing/all)`migration-guide`Help migrate code between CakePHP versions`fromVersion`, `toVersion` (required), `area` (optional: specific feature or general)`testing-assistant`Generate test cases and testing guidance`subject` (required), `testType` (optional: unit/integration/fixture/all)`performance-analyzer`Analyze and optimize performance issues`concern` (required), `context` (optional: code snippet or description)`orm-query-helper`Build complex ORM queries with guidance`queryGoal` (required), `tables` (optional: comma-separated list)`tinker-workshop`Interactive PHP exploration and testing guide`goal` (required: explore/test/debug), `subject` (optional)`quality-assurance`Coding guidelines and QA best practices for CakePHP`context` (optional: guidelines/integration/troubleshooting/all), `tools` (optional: all or comma-separated list)**Prompts automatically:**

- Search relevant documentation
- Read detailed guides
- Execute test code via tinker
- Provide structured, comprehensive answers following best practices

**Benefits:**

- **Faster workflows** - Common tasks become one-step operations
- **Best practices** - Prompts encode CakePHP expertise and conventions
- **Consistency** - Standardized approaches to common problems
- **Discovery** - See available workflows without remembering tool combinations

### Configuring Prompts

[](#configuring-prompts)

Prompts can reference a specific CakePHP version and use various quality tools. Configure both in `config/synapse.php`:

```
return [
    'Synapse' => [
        'prompts' => [
            // Target CakePHP version for prompt responses (e.g. '5.x', '5.2', '4.5', '4.x')
            'cakephp_version' => env('MCP_CAKEPHP_VERSION', '5.x'),

            // Target PHP version for prompt responses (e.g. '8.2', '8.3', '8.x')
            'php_version' => env('MCP_PHP_VERSION', PHP_VERSION),

            // Quality tools configuration
            'quality_tools' => [
                'phpcs' => ['enabled' => true, 'standard' => 'cakephp'],
                'phpstan' => ['enabled' => true, 'level' => 8],
                'phpunit' => ['enabled' => true, 'coverage' => true],
                'rector' => ['enabled' => false, 'set' => 'cakephp'],
                'psalm' => ['enabled' => false, 'level' => 3],
            ],
        ],
    ],
];
```

### Creating Custom Tools, Resources, and Prompts

[](#creating-custom-tools-resources-and-prompts)

You can extend Synapse with your own tools, resources, and prompts using PHP attributes. Synapse automatically discovers classes in your `src/` directory using MCP attributes.

**Tools** expose functions that AI assistants can call. Create them with `#[McpTool]`:

```
