MCP integration
The MCP integration exposes a Panda CSS project’s design system to AI assistants through the Model Context Protocol (MCP). It lets a client ask about tokens, recipes, patterns, conditions, and usage while keeping the project’s Panda configuration as the source of truth. It sits beside the main Panda developer CLI as an optional tool for AI-assisted development.
Product role
MCP server boundary
The MCP server is the boundary between an AI client and Panda project data. It starts in a project directory, loads that project’s Panda context, and answers MCP tool requests with structured design-system data. The default connection uses standard input and output so supported clients can start the server as a child process.
This boundary keeps the AI client focused on conversation and lets Panda remain responsible for resolving configuration and design-system data. The server sends protocol data on standard output and sends status and error messages on standard error.
References: packages/…/server.ts• L19-33 packages/…/server.ts• L181-216
Panda context and developer data
The server uses the same resolved Panda context that supports other developer tools. This gives AI clients a view of the project after its configuration, tokens, recipes, patterns, and related design data have been resolved rather than a separate copy of that information.
The connection also supports a usage report. This report analyzes the project source and shows token and recipe usage so an assistant can help with audits, cleanup, and missing or unused design definitions.
References: packages/…/server.ts• L4-8 packages/…/server.ts• L128-164
Client connection
Client setup
The package provides an init command that adds a Panda MCP server entry to the configuration used by a selected AI client. It supports Claude, Cursor, VS Code, Windsurf, and Codex. The setup flow creates the needed directory and merges the Panda entry into an existing configuration when that file is valid.
The generated entry starts @pandacss/mcp with npx. A client therefore starts the server when it needs the Panda tools instead of requiring a separate long-running process.
References: packages/…/init.ts• L12-35 packages/…/init.ts• L51-101 packages/…/clients.ts• L1-40 packages/…/clients.ts• L53-63
Server session
An AI client normally starts the package without a subcommand. The server loads the Panda configuration from the client’s working directory, or from an explicit configuration path when one is supplied, and then serves requests over the MCP connection.
The process owns its session only while the client connection is open. It closes on a closed input pipe or termination signal, and it exits on a fatal error. This prevents a disconnected assistant from leaving an orphan server behind.
The session flow connects the client, project context, and MCP tools as follows:
flowchart LR
Client[AI client] -->|starts command| Launcher[package launcher]
Launcher --> Server[MCP server]
Server -->|loads| Config[Panda project configuration]
Config --> Context[resolved Panda context]
Context --> Tools[MCP tools]
Tools -->|structured responses| Client
References: packages/…/cli.ts• L18-38 packages/…/server.ts• L181-216 packages/…/server.ts• L233-275
Capability groups
Design-system queries
The query tools expose the main design-system concepts that an assistant needs when writing or reviewing Panda code. They return tokens, semantic tokens, color values, recipes, patterns, conditions, keyframes, and style compositions. The assistant can request a whole group or narrow some groups by category or name.
The resolved Panda configuration is also available. This helps an assistant understand the project’s active settings instead of assuming default Panda behavior.
References: packages/…/server.ts• L47-132 website/…/mcp-server.mdx• L109-126
Usage analysis
The usage tool turns Panda’s project analysis into a compact report for an AI client. It can report token usage, recipe usage, or both. This supports questions about unused definitions, missing definitions, and the parts of a design system that are active in the codebase.
The report depends on the project files covered by the Panda configuration. It is therefore an analysis of the project as Panda sees it, not a general search of every file in the repository.
References: packages/…/server.ts• L134-164 website/…/mcp-server.mdx• L128-129 website/…/mcp-server.mdx• L258-264
Tooling relationships
CLI boundary
MCP is a separate package from @pandacss/dev. This keeps the MCP SDK and its related server dependencies out of normal Panda CLI installs. The separate package still uses Panda’s node-level context and analysis capabilities, so it adds an AI interface without creating a second design-system engine.
The old panda mcp and panda init-mcp commands remain as migration points. They return an error that directs users to the standalone package rather than silently starting a different server.
References: packages/…/package.json• L1-10 packages/…/package.json• L44-56 packages/…/README.md• L1-10 packages/…/mcp-moved.ts• L4-16 packages/…/cli-main.ts• L636-642
Developer observability
MCP belongs to the developer tooling layer with reporting and logging. Its usage report explains how Panda definitions are used, while its server messages explain whether the MCP session started or failed. These are related but separate concerns: MCP returns project knowledge to an AI client, while reporting and logging help engineers inspect tool behavior and project state.
See developer observability for the wider tooling view and reporting and logging for the related report and log behavior.
References: packages/…/server.ts• L4-8 packages/…/server.ts• L209-215 packages/…/server.ts• L264-270
Change checklist
When these files or sections are changed, remember to consider these:
- When an MCP tool name, input, or result shape changes, update the client-facing tool descriptions and the MCP server documentation together.
- When a supported client changes its configuration path or top-level key, update both the client map and the configuration initializer. Verify that existing client configuration remains intact.
- When Panda context or analysis data changes, check every MCP capability that reads resolved specs or usage reports. The MCP package must not expose stale or differently shaped data.
- When startup output changes, keep protocol responses on standard output and move human-readable messages to standard error.
- When the package boundary changes, keep the standalone install path and the migration behavior of the legacy CLI commands aligned.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The selected working directory has no valid Panda configuration | The server cannot build the Panda context, so the client cannot use Panda tools | Start from the project directory or pass the correct configuration path. |
| A client configuration uses the wrong path or top-level key | The AI client does not discover the Panda server | Use the client-specific entries in packages/…/clients.ts. |
| Human-readable output is written to standard output | MCP protocol messages can become invalid and the client session can fail | Keep startup and error messages on standard error. |
| The host closes the input pipe or sends a termination signal | The server must end the session instead of remaining as an orphan process | Use the managed process lifecycle in the server boundary. |
| Panda source paths do not cover the code that uses Panda | The usage report can be empty or incomplete | Align the project’s include paths with its source files before requesting an audit. |
A user runs the old panda mcp or panda init-mcp command | The CLI returns a migration error instead of starting MCP | Use npx -y @pandacss/mcp or its init command. |
Key files
| File | Why to read it |
|---|---|
| packages/…/server.ts | Defines the MCP boundary, the design-system query surface, usage analysis, startup options, and process lifetime. |
| packages/…/cli.ts | Shows how the default server session and the client setup command are exposed to users. |
| packages/…/init.ts | Explains how project-level AI client configuration is created and merged. |
| packages/…/clients.ts | Maps supported AI clients to their configuration locations and server entry shape. |
| packages/…/index.ts | Shows the public package surface for server startup, setup, and client configuration. |
| packages/…/package.json | Shows why MCP is a separate publishable package and which runtime boundary it provides. |
| packages/…/mcp-moved.ts | Defines the migration path from the legacy Panda CLI commands. |
| packages/…/cli-main.ts | Shows where the legacy MCP command names are retained as migration commands. |
| website/…/mcp-server.mdx | Describes the supported client setup and the user-facing tool capabilities. |