
psalm
io.github.psalm/psalm
PHP security analysis: Psalm's taint analysis finds SQL injection, XSS and more, plus type checks
Documentation
Psalm plugins for AI coding agents
Psalm is a static analyzer that finds security vulnerabilities and bugs in PHP code. Its taint analysis follows user input to the calls where it is dangerous, to find SQL injection, XSS, command injection, path traversal, SSRF and more. This plugin gives an agent:
- MCP tools to check files or the whole project (
psalm_check), to trace each security issue from its source to its sink (psalm_trace), to see the types Psalm infers (psalm_inspect), to find where a symbol is used (psalm_references), and to read the documentation of an issue (psalm_explain); - a skill to run Psalm, fix its issues and annotate code, which is the one the Psalm of your project ships;
- in Claude Code, the language server, which shows Psalm's errors after each edit.
Setup
Install Psalm in the project with composer require --dev vimeo/psalm, and create its config with
vendor/bin/psalm --init, or let the agent do it with psalm_install (see below). Then install the plugin, in Claude
Code:
/plugin marketplace add psalm/agent-plugins
/plugin install psalm@psalm
Gemini CLI: gemini extensions install https://github.com/psalm/agent-plugins
OpenCode: opencode plugin add github:psalm/agent-plugins
Cursor: agent plugin install https://github.com/psalm/agent-plugins
GitHub Copilot CLI: copilot plugin marketplace add psalm/agent-plugins, then copilot plugin install psalm@psalm
Two environment variables change what the plugin runs:
PSALM_PHP: the PHP binary that runs Psalm;PSALM_PROJECT_DIR: the project, if several directories have apsalm.xml.
Other agents: Using Psalm with AI agents.
MCP registry
The MCP registry lists the MCP server as io.github.psalm/psalm, in two
packages that bring a psalm.phar for projects without Psalm:
-
an MCP bundle (
psalm-VERSION.mcpb, in this repository's releases) for Claude Desktop and other clients that install bundles. It needsphp; -
the image
ghcr.io/psalm/psalm-mcp, which needs Docker. It runs with the project mounted at its own path:docker run -i --rm --mount type=bind,src="$PWD",dst="$PWD" --workdir "$PWD" ghcr.io/psalm/psalm-mcp
What the plugin runs and sends
php scripts/server.phpstarts when the agent does. It looks for the Psalm of the project (the project itself in a checkout of Psalm, thenvendor/,vendor-bin/*/vendor/,tools/, the global Composer packages, then thePATH) and runs its MCP server (psalm-mcp) or, in Claude Code, its language server (psalm-language-server), in the project directory.- In a Composer project without Psalm, the MCP server says how to install it, and offers
psalm_install, which the agent should call only after you agree. It runscomposer require --dev vimeo/psalm(which changescomposer.jsonandcomposer.lock, downloads from Packagist and GitHub, and runs the project's Composer scripts), thenpsalm --initif there is nopsalm.xml, and hands the session over to the Psalm MCP server, without a restart.psalm --initpicks theerrorLevelat which the project has few issues now; the agent is told that the issues of the stricter levels are bugs too, to fix in the files it changes, and to offer to bring the project toerrorLevel="1". - Without Psalm, the MCP server looks for it again at each request: once the agent or you install it some other way,
or the project gets a
composer.json, the session gets the Psalm tools orpsalm_install, without a restart. - Psalm loads the project's Composer autoloader and the Psalm plugins in its
psalm.xml, so use the plugin in projects you trust.psalm_checkwithout paths runs the project'spsalmcommand. - The skill runs the scripts of the skill that the project's Psalm ships, in
vendor/vimeo/psalm/skills/psalm. - The MCP bundle and the image also run the
psalm.pharthey ship when the project has no Psalm. - Nothing is sent anywhere by default. The skill can send a self-contained snippet to
https://psalm.dev/check, to check a bug report against the latest Psalm, only after you agree, and it reads the documentation on psalm.dev. Psalm sends its results tohttps://shepherd.devonly when it runs with--shepherd. The plugin downloads nothing but Psalm, whenpsalm_installruns, and collects no data.
Releasing
The plugins are released with each Psalm release, under its version. Within an hour of the release, release.yml
sets the version in .claude-plugin/plugin.json, .cursor-plugin/plugin.json, gemini-extension.json and
package.json on main, tags it vVERSION, creates the GitHub release that Gemini CLI installs, and publishes the
OpenCode package to npm. It also publishes the MCP bundle (in the mcp-VERSION release), the image and the registry
entry, with the release's psalm.phar. Changes merged into main ship with the next Psalm release.
Run the workflow by hand, with a Psalm version or without one (the latest), to finish a release that failed: it skips what is already published.
https://github.com/psalm/agent-plugins/releases/download/mcp-7.25.0/psalm-7.25.0.mcpb# mcpb: https://github.com/psalm/agent-plugins/releases/download/mcp-7.25.0/psalm-7.25.0.mcpbghcr.io/psalm/psalm-mcp:7.25.0docker pull ghcr.io/psalm/psalm-mcp:7.25.0:undefined