# Plasmic MCP

> Plasmic offers AI control over your visual headless page builder. List projects, query CMS data, check component structures, and trigger publishes—all via natural conversation. Use your AI agent to manage web content drafts and deploy changes without leaving your code editor.

## Overview
- **Category:** developer-tools
- **Price:** Free
- **Tags:** visual-builder, low-code, react, nextjs, web-development

## Description

You're gonna run your whole headless content flow straight from your chat window, no browser context switching required. This server gives your AI agent direct access to Plasmic’s backend functions, letting you manage entire site drafts and deploy changes right from your code editor or terminal. You get full control over the project lifecycle using simple commands.

### Project Configuration and Global Control

You can change overall project settings or metadata for the whole site with `update_project`. This tool lets you trigger global updates that affect how Plasmic renders content across multiple pages. For listing available work, your agent pulls all defined projects when you reference the capability to list them.

### Data Retrieval and Structure Inspection

Need to know what data's sitting in a CMS collection? You use `query_cms_items` to fetch filtered lists of records from any designated Plasmic database table based on criteria you specify. If you just need a rough count, `count_cms_items` tells you the total number of entries in a table. To understand how a component is built, your agent calls `get_model`, which returns the full JSON structure (SDUI) detailing all internal components and their properties for any project element.

### Content Management: Drafting and Modification

When you're working on drafts, you manage content records using standard CRUD operations. To start fresh, your agent adds a brand-new item or draft record to the CMS via `create_cms_item`. If existing content needs tweaking—say, changing some body copy or swapping out an image in a draft—you call `update_cms_item` to modify specific details of an existing entry. You can permanently remove records using `delete_cms_item`, which takes an item from any specified CMS table.

### Publishing and Rendering Output

Drafting is only half the battle; you gotta get it live. To move a draft content item into a visible state, your agent executes `publish_cms_item`. This function makes sure that piece of content shows up on the actual site. For final output, if you need to test exactly what a component looks like before deployment, `render_html` generates and returns the clean HTML code for any specific component instance. The entire process operates by having your AI client treat these tools like native functions; it calls them when you ask it to perform an action—like 'Give me the latest copy for the pricing page' or 'Check if the contact form is ready.' When the agent executes a tool call, it returns the raw data or confirmation back to you in plain language. You’re essentially running core CMS operations without leaving your IDE. This gives your AI client power over Plasmic's backend functions, letting you manage content and project states entirely through natural conversation.

## Tools

### count_cms_items
Counts the total number of records in a specified Plasmic CMS database table.

### create_cms_item
Adds a brand-new item or draft record to any designated Plasmic CMS table.

### delete_cms_item
Permanently removes an existing item from a specific Plasmic CMS database table.

### get_model
Returns the full JSON structure (SDUI) of a project element, detailing its internal components and properties.

### publish_cms_item
Takes a draft content item and publishes it to make it visible on the live site.

### query_cms_items
Fetches filtered lists of items from a Plasmic CMS database table based on criteria you provide.

### render_html
Generates and returns the final, clean HTML output for a specific component instance.

### update_cms_item
Modifies the content details of an existing CMS item (e.g., changing text or images in a draft).

### update_project
Programmatically changes project settings or overall metadata for the entire Plasmic site.

## Prompt Examples

**Prompt:** 
```
List all my Plasmic projects.
```

**Response:** 
```
I've found 3 projects in your account: 'Marketing Site' (ID: 8vK...), 'E-commerce Store' (ID: 2mP...), and 'Documentation' (ID: 9qL...). Which one would you like to inspect?
```

**Prompt:** 
```
Show me the pages for project ID 8vK...
```

**Response:** 
```
Fetching pages for 'Marketing Site'... I found 4 pages: 'Home' (/), 'About Us' (/about), 'Pricing' (/pricing), and 'Contact' (/contact).
```

**Prompt:** 
```
Publish the latest changes for project 8vK...
```

**Response:** 
```
Publishing 'Marketing Site' (ID: 8vK...) now... The project has been successfully published to production.
```

## Capabilities

### Project Lifecycle Control
Change project metadata, trigger global updates, or list all available projects using `update_project`.

### Content Drafting and Publishing
Create new CMS records, update existing drafts (`update_cms_item`), and move them to a live state with `publish_cms_item`.

### Data Retrieval and Inspection
Query specific content tables using filters, or get a structural JSON model of any component via `query_cms_items` or `get_model`.

### Component Output Generation
Get the final HTML code for a component (`render_html`) or simply count records in a data table using `count_cms_items`.

## Use Cases

### The Quick Hotfix
A client reports a typo on the homepage. Instead of logging into Plasmic Studio and navigating deep into component settings, you ask your agent to run `query_cms_items` for the 'Homepage Banner' content. You use `update_cms_item` to fix the word, then immediately call `publish_cms_item`. Problem solved in three tool calls.

### SEO Content Audit
You need to confirm every product page has a unique H1 tag. You ask your agent to run `query_cms_items` across the 'Product' table, filtering by metadata fields for the H1 count and content status. This quickly identifies all missing or incorrect titles before launch.

### Component Debugging
The e-commerce checkout page looks broken in staging. You ask your agent to run `get_model` on the 'Product Card' component. The returned JSON model shows that a necessary prop (`is_discountable`) is missing, allowing you to fix the code without guessing.

### Initial Project Setup
You just started a new client site and need to verify all existing data tables are populated. You ask your agent to run `count_cms_items` for every core collection (e.g., 'Testimonials', 'Team Members'). The agent reports the total count for each, confirming you have enough starting content.

## Benefits

- **Instant Site Updates:** You don't manually trigger builds. Calling `publish_cms_item` pushes content drafts live instantly, giving you immediate proof that your changes are visible to users.
- **Deep Component Inspection:** Need to know how a component is built? Use `get_model`. It returns the JSON structure of any element, letting you inspect its internal logic without opening the visual builder.
- **Efficient Content Auditing:** Forget clicking through pages. Run `query_cms_items` to fetch all articles tagged 'Q3 Marketing' and check their status in one single API call.
- **Reliable Content Modification:** When a copy needs fixing, you don't rewrite the whole thing. Use `update_cms_item` to target specific fields (like headline or date) across thousands of records efficiently.
- **Full Project Control:** Want to change site-wide settings? The `update_project` tool lets your agent modify core project metadata directly, which is critical for staging environment switches.

## How It Works

The bottom line is: You never have to switch windows or copy IDs; your AI handles the API calls for you.

1. First, you subscribe to this server and input your Plasmic Project ID and API Token.
2. Next, you ask your AI client for a specific task—for example, 'List all pages in my Marketing Site project.'
3. The agent runs the appropriate tool (like one of the listing tools), gets the data back, and reports the result to you.

## Frequently Asked Questions

**How do I use `get_model` to debug a component?**
`get_model` returns the full JSON representation (SDUI) of any element. You pass it the element ID, and you get back a schema that shows exactly how all its nested components are structured.

**What's the difference between `query_cms_items` and listing pages?**
`query_cms_items` is for content records stored in CMS tables; it lets you filter by specific fields like 'Author' or 'Date.' Listing pages handles the site structure (routes) itself.

**Do I have to manually run a build after using `publish_cms_item`?**
No. The tool manages the publish state. Calling `publish_cms_item` triggers the necessary deployment action, making the content live immediately without manual CI/CD steps.

**`update_project` is for what kind of changes?**
`update_project` handles overarching site configuration metadata—things like changing the primary domain or updating global style tokens that affect every page in the project.

**When I use `query_cms_items`, can I filter the results based on specific criteria?**
Yes, you specify filters in your query parameters. You don't just pull everything; you define exact criteria—like only records tagged 'Draft' or created after a certain date. This keeps your data set small and focused.

**If I need to create many new entries, how does `create_cms_item` handle bulk operations?**
The tool processes items one by one per call. For large batches, you'll want your agent to loop through the records and execute multiple calls sequentially. This ensures every item gets created without hitting limits.

**What security checks are in place when I use `delete_cms_item`?**
The server verifies your permissions before running the delete command. It won't let you remove sensitive data unless your connected agent has explicit write access rights for that specific collection.

**How does `render_html` handle large or complex components to maintain performance?**
It optimizes the output by fetching only the necessary generated HTML. It treats the component's structure as a single unit, preventing excessive data transfer and keeping the resulting code efficient.

**Can I list all my Plasmic projects to find a specific Project ID?**
Yes! Use the `list_projects` tool. Your agent will return a list of all projects associated with your credentials, including their names and unique IDs.

**How do I see which pages are currently built inside a project?**
Simply ask the agent to run `get_project_pages` with the target Project ID. It will list all pages, their paths, and basic metadata.

**Is it possible to publish my changes to production using the AI?**
Yes. By using the `publish_project` tool, you can trigger a new publish for a specific project ID, making your visual changes live immediately.