Skip to content

MCP server ​

Panifex tools are not only for Panifex agents. PanifexServer (src/Mcp/PanifexServer.php, adapting tools through src/Mcp/Tool/AiToolAdapter.php) serves them over the Model Context Protocol over stdio, so any MCP client (Claude Code, Cursor, Zed, any agent that speaks MCP) can use CakePHP-aware tools against your app. That means coding from any agent: the client brings the model, Panifex brings the tools that understand your CakePHP codebase, with the same safety layer enforced in PHP.

Setup ​

Serve it through the MCP plugin's command (registered via the Panifex plugin bootstrap):

bash
bin/cake mcp start panifex

Register it with Claude Code from your app directory:

bash
claude mcp add panifex -- bin/cake mcp start panifex

Or add it to .mcp.json manually:

json
{
  "mcpServers": {
    "panifex": {
      "command": "bin/cake",
      "args": ["mcp", "start", "panifex"]
    }
  }
}

From that point the client's tool list includes the Panifex tools below, and the model can call them like any native tool.

Served tools ​

The exposed set is controlled by Panifex.mcp.tools and defaults to 16 read, inspect, and analysis tools: no file writes, no shell:

ToolWhat the client gets
ReadFileRead a text file, or a line range — the client's window into your code
GlobList files matching a pattern (protected paths excluded)
SearchCodeGrep-style search returning file, line, and snippet
GitDiffShow staged, committed, or ranged diffs
ListRoutesRegistered routes with method, URI, name, and action
DescribeRouteOne route as the framework resolved it — middleware, bindings, validation, authorization
DescribeTablesReal columns, casts, finders, and associations for a table — schema answers without reading files
DescribeSchemaRaw tables, columns, types, indexes, and foreign keys off the live connection
QueryDatabaseRead-only SELECT, capped at 100 rows, returned as JSON
MutateDatabaseGuarded single write — same confirmation rules as in agent sessions; rolls back with no human to confirm
ReadLogLast lines of the application log, with optional filter
ReadSpeculumEntrySpeculum exception entries for the failing code under discussion
ReadSentryIssueSentry issue with exception, stacktrace, breadcrumbs, and request context
ReadIssueTracker issue with title, body, labels, and comments
ReadPullRequestPull or merge request with branch, state, and review comments
RunPhpstanPHPStan findings for a path — the client verifies its own edits
RunTestsPest summary — pass/fail counts with file:line failures, not the raw log

What this gives you in practice: the client reads your code (ReadFile, SearchCode), understands the schema without guessing (DescribeTables, DescribeSchema), checks how routes behave (DescribeRoute), looks at failing context (ReadLog, ReadSentryIssue, ReadSpeculumEntry), verifies its own work (RunPhpstan, RunTests), and reports back. The pieces it cannot do, editing files, running shells, stay with the tools you explicitly add.

Add write tools (EditFile, WriteFile, RunCodingStyle) to Panifex.mcp.tools when you trust the connected client. That is the line between "the client reviews and diagnoses" and "the client edits your codebase". Cross it deliberately.

Safety rules ​

The same safety layer applies exactly as it does for Panifex's own agents: protected paths block reads, the CakePHP allowlist gates RunCake-family execution, database queries stay read-only, and context guards bound oversized results. Interactive tools (AskUser, ConfirmAction) are refused outright. An MCP client has no terminal to answer their prompts. Avoid tools that ask for terminal confirmation, such as CommitAndPush: they would hang the stdio session.

Hooks do not apply to tools served over MCP. The connected MCP client is the policy layer there. The guard pack still does: path, secret, network, and composer-script enforcement runs in PHP underneath, regardless of which client called.

The other direction ​

Panifex's agents can also consume external MCP servers (a browser, an external system, anything you trust) as agent tools. The agent declares them, the harness runs them. See Extending.

Next steps ​

  • Tools — the full built-in toolset these are drawn from
  • Hosting connections — trackers and Sentry behind the issue tools
  • Safety — the enforcement underneath

Released under the MIT License.