How to Deploy a Website with Claude Code
Claude Code can write HTML, CSS, and JavaScript. What it can't do on its own is put those files on the internet. Deploying a website with Claude Code requires one addition: an MCP server that connects Claude to a publishing endpoint. Once that's in place, Claude builds the page and publishes it in the same session, returning a live URL you can share immediately.
This guide uses the HTMLPub MCP server, which takes about five minutes to set up.
What you need
- Claude Code (the CLI tool, not Claude.ai chat)
- An HTMLPub account (free tier works)
- Your HTMLPub API key from the account settings page
Step 1: Add the HTMLPub MCP server to Claude Code
In your terminal, run:
claude mcp add htmlpub
When prompted, enter your HTMLPub API key. Claude Code stores it locally and connects to the HTMLPub MCP server for all future sessions.
If you prefer to configure it manually, add the following to your Claude Code settings file (~/.claude/settings.json on Mac):
{
"mcpServers": {
"htmlpub": {
"command": "npx",
"args": ["-y", "@htmlpub/mcp"],
"env": {
"HTMLPUB_API_KEY": "your-api-key-here"
}
}
}
}
Restart Claude Code after saving.
Step 2: Ask Claude to build and deploy a page
With the MCP server connected, Claude has access to HTMLPub's publish tools. You can now ask Claude to write and deploy in one request:
Build a landing page for a photography portfolio.
Dark background, full-width hero image placeholder,
gallery grid below, contact section at the bottom.
Publish it to HTMLPub when done.
Claude writes the HTML and calls the HTMLPub MCP tool to publish it. You get a live URL back in the conversation output, something like https://pages.htmlpub.com/your-username/photography-portfolio.
The entire process takes under two minutes for a typical single-page site.
Step 3: Iterate without re-deploying manually
Because Claude Code holds the context of what it built, updates are straightforward:
Change the hero text to "Capturing light since 2019"
and update the contact email to [email protected].
Republish.
Claude edits the HTML and calls the publish tool again, overwriting the previous version at the same URL. No manual steps, no copy-pasting, no switching to a browser.
When this is most useful
Claude Code deploy via MCP works best for:
- Single-page sites: Landing pages, portfolio pages, event announcements, bio links. These are self-contained HTML files that Claude can generate and publish in full.
- Rapid prototyping: When you need to show something to a client or teammate before it's polished. Get a URL, share it, iterate based on feedback.
- Automated pipelines: Claude Code running in a script or CI context where you want pages generated and published programmatically. For that use case, see how to automate web publishing with the HTMLPub API.
For full web apps that need a server runtime, database, or build pipeline, this workflow doesn't apply. Those require Vercel, Railway, or a similar platform.
Common issues
"MCP tool not found" error: Claude Code doesn't have the HTMLPub server loaded. Double-check your settings file and restart Claude Code. Run claude mcp list to confirm the server appears.
Published page is blank: The HTML Claude generated may reference external assets that didn't load, or there's a script error. Ask Claude: "Check the page for rendering issues and fix them, then republish." Claude can inspect its own output and correct problems.
API key rejected: HTMLPub API keys are account-scoped. Make sure you copied the full key from your HTMLPub account settings and that there are no extra spaces in the config.
What's next
The full setup walkthrough for connecting Claude to HTMLPub is in the Claude MCP connector tutorial — it covers the Claude.ai desktop app as well as Claude Code. For a broader look at what's possible when AI tools have direct publish access, MCP web publishing explains the workflow pattern and when it makes sense to use it.
If you want Claude to publish from inside the Claude.ai chat interface rather than the CLI, how to publish a website from Claude covers that path with step-by-step instructions.