CodePen has an MCP (Model Context Protocol) server. Connect it to the AI tool you already use (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code, and the like) and that tool can create and change your Pens, add Blocks, read builds and their diagnostics, take screenshots, read the console, manage Collections and Assets, and deploy Pens as sites, all within your own CodePen account.
Any MCP client that speaks Streamable HTTP works. The server address is:
https://mcp.codepen.io/mcpCode language: plaintext (plaintext)
Add it with no credentials and the application sends you to codepen.io to sign in and approve what it may do: read, or read and write. Each application gets its own grant with only the access it asked for, nothing secret sits in a config file, and you can see every connected app (and disconnect it at any time) at Settings → API.
Connecting
Claude Code
Add the server for every project, then sign in. The login command opens your browser.
claude mcp add --transport http --scope user codepen https://mcp.codepen.io/mcp
claude mcp login codepenCode language: Bash (bash)
--scope user makes the server available in every project; without it, only the directory you ran the command in. You can also run /mcp inside Claude Code and choose Sign in from the menu.
Claude (claude.ai and the desktop app)
Settings → Connectors → Add custom connector, paste the URL, then Connect.
Codex
The CLI, desktop app and IDE extension share one configuration.
codex mcp add codepen --url https://mcp.codepen.io/mcp
codex mcp login codepenCode language: Bash (bash)
In the IDE extension: the gear menu, MCP servers, Add server, Streamable HTTP, the URL, then Authenticate.
Cursor
Add to Cursor with one click, or put this in ~/.cursor/mcp.json (every project) or .cursor/mcp.json (one project). Cursor then shows the server as needing login, and Sign in opens the browser.
{
"mcpServers": {
"codepen": { "url": "https://mcp.codepen.io/mcp" }
}
}Code language: JSON / JSON with Comments (json)
VS Code
Add to VS Code with one click, run MCP: Add Server from the command palette, or put this in .vscode/mcp.json:
{
"servers": {
"codepen": { "type": "http", "url": "https://mcp.codepen.io/mcp" }
}
}Code language: JSON / JSON with Comments (json)
pi
pi mcp add codepen --url https://mcp.codepen.io/mcp
pi mcp login codepenCode language: Bash (bash)
Running /mcp inside a pi session shows the server and offers Sign in too.
Other clients
Any other MCP client works the same way: Streamable HTTP, that URL, no credentials, and the sign-in the client offers when the server answers 401. The server follows the MCP authorization specification (it publishes its authorization server at /.well-known/oauth-protected-resource/mcp and supports dynamic client registration), so a compliant client needs no pre-registered credentials.
API Key for Headless Use
No browser to sign in from (a server, CI, a container)? Send an API key as a Bearer token in the Authorization header instead. Generate one at Settings → API. A key gives the application every permission on your account’s Pens, Collections and Assets, including deleting and deploying, so treat it like a password. With the key in a CODEPEN_API_KEY environment variable:
# Claude Code
claude mcp add --transport http --scope user codepen https://mcp.codepen.io/mcp \
--header "Authorization: Bearer $CODEPEN_API_KEY"
# Codex
codex mcp add codepen --url https://mcp.codepen.io/mcp --bearer-token-env-var CODEPEN_API_KEY
# pi
pi mcp add codepen --url https://mcp.codepen.io/mcp --bearer-token-env-var CODEPEN_API_KEYCode language: Bash (bash)
Cursor and VS Code take a headers object beside url, and both expand environment variables in it:
{
"mcpServers": {
"codepen": {
"url": "https://mcp.codepen.io/mcp",
"headers": { "Authorization": "Bearer ${env:CODEPEN_API_KEY}" }
}
}
}Code language: JSON / JSON with Comments (json)
It’s one or the other: a client configured with an Authorization header sends it and never offers sign-in. To switch to signing in later, remove the header first.
Team Use
Signing in covers your own account. To work on a Team’s Pens, send the Team’s API key as a Bearer token (see above). A Team key starts with cp_team_; your own starts with cp_user_. With a Team key, get_profile answers with the Team’s plan and features, and every tool acts on the Team’s content.
Things to Try
Once connected, your agent can do nearly anything you can do on CodePen. Talk to it in your own words; it picks the tools. Some prompts to get you started:
- Pens: “make a new Pen”, then “build me a platformer game with a little kangaroo that has to jump over obstacles”. Or “fork the Pen ‘Grid Lanes Experiment'”, or “update the current Pen’s modal to use the native
<dialog>element”. - Existing work: paste a Pen’s URL and ask “are there any accessibility or performance improvements you can suggest?” or “update the title, description, and tags of this Pen based on what it does”.
- Builds and previews: “show me a screenshot of the breakfast burritos website”, “are there any build errors on the latest build? what are they?”, “look at the runtime errors in the console for this Pen and fix them”, “open a live preview of this Pen”.
- Blocks: “what Blocks are available?”, “add the Mermaid Block to this Pen and make an example pie chart”, “use Svelte, Tailwind, and TypeScript to build a calendar UI”.
- Shipping: “deploy this Pen” puts it on a public URL (PRO). “Turn on deploy-on-save” makes every successful save go live, so you can follow up with “implement a dark mode toggle” and watch it ship.
- Collections, Assets and sharing: “make a new Collection called ‘My Main Side Projects’ and add the breakfast burritos site to it”, “show me any .mp4 Assets on my account”, “add the user ‘shshaw’ as an editor on the latest CSS Modules Pen”, “make the breakfast burritos Pen public”.
The editor also speaks WebMCP, so an agent that’s already in your browser (the ChatGPT desktop app, or a tool like agent-browser) can work the Pen with you without connecting to this server at all.
How it works
The server works on Pens made in the CodePen 2.0 editor. A Pen is a frontend web project with files and assets for one or more pages. Saved versions capture its files; the head is the current saved version. Blocks process the source files into a build (the compiled HTML, CSS, JavaScript and assets that previews and deployments serve), and matching source files activate them: a .scss file brings Sass, a .ts file brings TypeScript.
The typical loop an AI application runs:
create_penwith a set of files, orget_penandread_fileson an existing one.write_files(whole files) oredit_files(find-and-replace hunks) to change it. Each write saves one new version and builds it.- Read the build’s diagnostics in the answer, or poll
get_buildwhile it’s still running, and fix until it succeeds. preview_pento verify the result with a screenshot and the console.- Hand you the editor URL, a temporary
get_preview_url, ordeploy_penit (PRO).
A few things worth knowing:
- Every tool works on your own account’s content. A Pen you don’t own is “not found”, public or not.
pen_idaccepts a Pen’s id or any CodePen URL of it (editor, pen or preview URL), so pasting a link into the chat is enough.- Writes are conflict-safe. They take an
expected_version_id, and if the Pen has moved on since that version (say you edited it in the browser meanwhile), the write is refused withCONFLICTrather than overwriting newer work. - Writes also take a
labelfor the version, shown in the editor’s history, anddry_run: true, which builds the proposed files without saving anything. - Pens made in the classic editor can be read (their three panels read as files) but not changed. The AI can port one by making a new Pen from its files.
- Deleting a Pen or Collection moves it to the trash, where it can be restored for 3 days.
- Binary files (images, fonts) go through
create_asset_upload, which answers a URL toPUTthe bytes to. A chat client without HTTP access can only send text files. - Free accounts connect and create Pens with daily allowances. PRO adds higher limits, deployment, Asset uploads, collaborator invitations, Private Pens and PRO Blocks. A refused call says what the requirement is.
Tools
The server has 38 tools. Each needs either the read scope or the write scope; an API key holds both, and a sign-in grant holds the ones you approved.
Account
| Tool | Scope | What it does |
|---|---|---|
get_profile | read | The account the credential acts for: username, plan, how the call is authenticated, the scopes granted, every rate limit and allowance with what remains, and which PRO features (deploy, uploads, collaborators) the plan includes. |
Pens
| Tool | Scope | What it does |
|---|---|---|
list_pens | read | Your Pens, most recently updated first, 20 per page. Filters by access, deployment, template, fork status, tags, dates, Block and a search term; sorts by Updated, Created, Popularity or Title. |
get_pen | read | One Pen: title, description, tags, access, URLs, settings, its saved version and build, deployment, and its file list (no content). |
read_files | read | The content of a Pen’s files, by path or id, from the head or any saved version. Large files come back in chunks. output: true reads the compiled output instead of the source. |
list_versions | read | A Pen’s saved versions, newest first, each with its build status and diagnostics. |
get_build | read | A version’s build: status, diagnostics, errors, applied patches and the compiled output files. wait_seconds makes one call wait for a running build to settle. |
create_pen | write | Creates a Pen from text files, saves them as its first version and builds it. Blocks are set from the files written. Counts against the daily create allowance. |
fork_pen | write | Copies one of your Pens into a new one and builds it. |
update_pen | write | Changes title, description, tags, template flag, access, password and editor settings (auto deploy, auto run, auto save, indentation). Takes pen_ids to change up to 100 Pens at once. |
write_files | write | Creates, updates, renames and deletes a Pen’s text files as one new saved version, then builds it. |
edit_files | write | Applies old/new text hunks to a Pen’s files as one new version, without resending whole files. Each old must match exactly once (or everywhere with replace_all). |
restore_version | write | Makes an earlier saved version the head again, as a new version. |
deploy_pen | write | Publishes the head, or a given version, at the Pen’s deployment URL. PRO. |
undeploy_pen | write | Takes the deployment down. The Pen and its versions stay. |
delete_pen | write | Moves a Pen to the trash. Takes pen_ids for up to 50 at once. |
Preview
| Tool | Scope | What it does |
|---|---|---|
preview_pen | read | Loads your Pen in a real browser and answers a Screenshot (viewport, full page, or one element) and/or the Console (logs, uncaught errors with stacks, failed requests). Options for path, viewport size, light or dark color scheme and reduced motion. Can scroll to an element, run up to six interactions (click, hover, type, press, wait, scrollTo) and capture again, and probe selectors for what they match. |
get_preview_url | read | A link to the Pen’s saved head that renders for one hour outside CodePen, no session needed. Works on every plan. |
Trash
| Tool | Scope | What it does |
|---|---|---|
list_trash | read | Your Pens and Collections in the trash, with when each stops being restorable. |
restore_pen | write | Takes a Pen out of the trash, with its id, URL, versions and deployment as they were. |
restore_collection | write | Takes a Collection out of the trash, with its Pens as they were. |
Sharing
| Tool | Scope | What it does |
|---|---|---|
list_collaborators | read | A Pen’s collaborators with their roles, and pending invitations. |
manage_collaborators | write | Invites people (Editor or Viewer), changes roles, removes collaborators, cancels or resends invitations, in one call. PRO. |
manage_domains | write | Adds and removes custom domains on a deployed Pen and answers the DNS records to create. With no changes, it lists them. |
Collections
| Tool | Scope | What it does |
|---|---|---|
list_collections | read | Your Collections, most recently updated first, with item counts and URLs. |
get_collection | read | One Collection with its Pens, paginated. |
create_collection | write | Creates a Collection. A Private Collection needs PRO. |
update_collection | write | Changes a Collection’s title, description or access. |
manage_collection_pens | write | Adds and removes Pens in a Collection (classic editor Pens included). |
delete_collection | write | Moves a Collection to the trash. The Pens in it are not deleted. |
Assets
| Tool | Scope | What it does |
|---|---|---|
list_assets | read | Your Assets (uploaded files), newest first, each with its URL. |
get_asset | read | One Asset: filename, URL, and for a text Asset (SVG, CSS, JavaScript, JSON, text) its content. |
create_asset_upload | write | A URL to PUT a binary file to, for a new Asset, an existing Asset’s new bytes, or a file in a Pen. Good for 15 minutes. PRO. |
get_upload | read | Where an upload stands: pending, processing, completed, failed or expired. |
update_asset | write | Renames an Asset (which changes its URL), replaces a text Asset’s content, or both. |
delete_asset | write | Deletes an Asset; its URL stops serving. |
Blocks
| Tool | Scope | What it does |
|---|---|---|
list_blocks | read | Every Block the compiler offers: name, purpose, whether it needs PRO, what kind of task it runs and the file types it processes. |
get_block | read | One Block in full: file types, the triggers that activate it, its config file path, every option with its type and default, and documentation links. |
update_pen_blocks | write | Adds and removes Blocks on a Pen and sets Block options, in one call, as a new saved version that is then built. |
The server also exposes two resources for clients that attach context by reference (such as an @ mention in Claude Code): codepen://pens/{pen_id}/files/{path} for a file’s text and codepen://blocks/{name} for a Block’s description.
Limits
Calls through the MCP server share the public API’s allowances, counted together with your other API use:
| Free | PRO and Teams | |
|---|---|---|
| Requests per hour | 150 | 9,000 |
| Reads per day | 1,500 | 30,000 |
| Pen creates per day | 5 | 150 |
| Collection creates per day | 5 | 150 |
| Saves per 5 minutes | 100 | 500 |
Browser renders (preview_pen with options beyond the site’s own screenshot) have their own allowance of 120 an hour per account, one at a time. A refused call says which limit it hit and when to retry, and get_profile shows what remains of each.
Errors
A failed tool call is a tool error, never a broken connection. Its text starts with the code and a message, then the fields a client needs to recover, then a hint saying what to do next.
| Code | Meaning |
|---|---|
NOT_FOUND | The id names nothing your account owns. |
BAD_USER_INPUT | An argument is wrong; field names it when known. |
CONFLICT | expected_version_id is stale; head_version_id is the Pen’s head now. |
LIMIT_EXCEEDED | A rate or allowance limit; retry_after_seconds says when to retry. |
CLASSIC_READ_ONLY | A write reached a Pen made in the classic editor. |
FORBIDDEN | The plan or the Pen’s rules refuse it; the message says which and where to upgrade. |
INSUFFICIENT_SCOPE | The grant doesn’t cover this tool; the client can ask you to re-consent. |
BUILD_TIMEOUT | A dry run’s build did not finish inside the call. |
OPERATION_IN_PROGRESS | A create with the same idempotency_key is still running; retry shortly. |
OPERATION_INTERRUPTED | A create committed but its answer was lost; the error names what was saved. |
RESULT_TOO_LARGE | The result exceeds the response budget; read smaller pages or file chunks. |
INTERNAL | Something broke on our end; it is reported. |
A 401 on the connection itself means the key or sign-in token is missing or no longer valid.
Questions
Email support@codepen.io and mention MCP in the subject line.