Claude Code 或 Cursor 如何透過 MCP 接入 dochost 發布工具並保留頁面原連結
Give Claude Code or Cursor a publish tool over MCP, and keep the same link when it edits the page
這篇教學示範如何讓 Claude Code 或 Cursor 透過 MCP 接入 dochost 發布工具,並在修改已發布頁面時沿用原有連結。其 Streamable HTTP 端點為 https://dochost.io/api/mcp;修改時應先讀取現有內容,再用 update_page 更新,並以 set_page_options 調整設定,避免重新發布造成新連結。
Disclosure: I build dochost, the service used in the examples. The setup steps are specific to it; the four rules in the second half apply to any "publish" tool you give an agent. Checked against the live server on October 18, 2026.
Most of what an AI assistant writes for other people ends up as a file: a Markdown report, an HTML quiz, a status page. Then someone has to put it somewhere with a URL. If the assistant can call a publish tool, that step goes away. You ask for the page, the assistant sends the content, and you get a link back in the same reply.
This is a short guide to wiring that up over the Model Context Protocol (MCP). It also covers the part people skip: what happens on the second request, when you ask the agent to fix a typo on a page someone already has open.
One URL, two ways to authenticate
The server is a remote Streamable HTTP endpoint:
https://dochost.io/api/mcp
tools/list answers without auth, so you can see what you're connecting to before you sign in. Tool calls need an account, and there are two ways to give one:
| You are using | Use | Why |
|---|---|---|
| Claude Code, Claude Desktop, ChatGPT, Cursor, VS Code, Windsurf | OAuth | The client opens a browser window and you approve once. Nothing gets pasted into a config file |
| A cron job, your own script, a headless agent (OpenClaw, Hermes) | API key | There's no browser to approve in, so the agent sends a bearer token |
Both end up as the same account. Ownership, quota and plan limits come from the account, never from the tool arguments.
Connect it
Claude Code (one line, then run /mcp inside Claude Code and approve in the browser):
claude mcp add --transport http dochost https://dochost.io/api/mcp
Add --scope user if you want it in every project, not only the current one.
Cursor, VS Code, Windsurf, Claude Desktop config:
{
"mcpServers": {
"dochost": {
"type": "http",
"url": "https://dochost.io/api/mcp"
}
}
}
Claude Desktop (UI): Settings → Connectors → Add custom connector, paste the URL, Connect.
ChatGPT: Settings → Connectors (developer mode), add a connector with the same URL. Custom MCP connectors have to be available on your ChatGPT plan.
Headless agents: create a key in Settings → API keys, store it as DOCHOST_API_KEY in the agent's environment (never in a repo), and send it as Authorization: Bearer …. Rotating a key kills the old one immediately, so a leaked key is a 30-second fix.
The server supports OAuth dynamic client registration, so clients that implement the MCP auth spec don't need a pre-registered client ID.
What the agent gets
Eight tools:
-
publishcreates a page from Markdown or HTML and returns the URL -
update_pagereplaces a page's content in place -
get_page_contentreads back the current source of a page -
get_pagereturns metadata only (title, status, views, expiry, password yes/no) -
set_page_optionschanges visibility, search indexing or password without republishing -
list_my_pages,get_account,delete_page
Pages are unlisted unless you ask for public. HTML JavaScript runs in a sandbox on a separate origin (dochost.co), so an AI-made quiz or calculator stays interactive without touching your session on the app domain.
Four rules so the agent doesn't break the link you already sent
The first publish is easy. The trouble starts on revision two. Here's what to tell your agent, or put in your project's agent instructions file.
1. Update, don't republish
If the page already exists, the agent should call update_page, not publish. A second publish creates a second URL. The person you sent the first link to keeps seeing the old version and never finds out there's a new one. update_page keeps the URL, view count and expiry, and resending identical content does nothing.
A line that works in a CLAUDE.md or .cursorrules:
When revising a page you already published, call
update_pagewith its slug. Only callpublishfor a new page.
2. Read before you overwrite
update_page replaces the whole body. If the agent edits from memory (a new chat, a compacted context, or a page you tweaked by hand on the website), it silently drops whatever it can't see. So the rule is: unless the agent wrote the live content earlier in this conversation, call get_page_content first, edit that, then update.
3. Change settings without touching content
"Make it private", "add a password", "stop search engines indexing it" are settings changes, not new pages. set_page_options changes them in place. Deleting and publishing again would change the link you already shared.
4. Know the limits before you promise a link
Free links expire after 7 days (3 days for private, link-only pages). Paid plans make links permanent and add custom slugs and passwords. If a page has to outlive next week, have the agent call get_account first and tell you, rather than handing over a link that dies on Friday. There's also a rate limit (20 publishes a minute, 300 an hour), which only matters if you script it.
When this is the wrong tool
- A multi-page site with a build step: use a real static host (GitHub Pages, Netlify, Cloudflare Pages) and let the agent push to a repo.
- Anything that needs a backend: a form that has to store submissions needs a server. A sandboxed page can calculate in the browser, but it doesn't collect data for you.
- Permanent free hosting: the free tier here expires by design.
For one document that a person needs to open today, and that you'll probably ask the agent to fix twice, a publish tool with an in-place update beats exporting a file every time.
Setup page with per-client snippets: dochost.io/mcp. The server source and stdio bridge are MIT-licensed at github.com/zyli5313/dochost-mcp.
This article was drafted with AI assistance and checked by hand against the live MCP server's tool list.
來源:DEV Community · dev.to