EmDash 內建 Model Context Protocol (MCP) 伺服器,讓 AI 助手可直接處理網站內容。你可以讓 Claude、ChatGPT 或其他工具起草文章、更新頁面、管理媒體、搜尋內容等——全部透過自然語言對話完成。
網站的 MCP 伺服器
MCP 伺服器預設啟用。除非關閉,EmDash 會掛載 /_emdash/api/mcp。該端點接受 OAuth 或個人存取 bearer token;僅有管理瀏覽器工作階段並不能對 MCP 請求進行身分驗證。OAuth 讓連接客戶端的人在 EmDash 簽發 token 之前選擇 scope。
要停用,請在 Astro 設定中設定 mcp: false:
emdash({
mcp: false,
});
連接 AI 客戶端
網站的 MCP 伺服器 URL 為:
https://example.com/_emdash/api/mcp
將 example.com 取代為你的網域。本機開發使用 http://localhost:4321/_emdash/api/mcp。
Claude
將 URL 新增為遠端自訂連接器。Claude 會開啟 EmDash OAuth 流程,以便你登入並選擇權限。Anthropic 會獨立於 EmDash 變更連接器介面,因此請遵循其 目前自訂連接器說明 了解確切控制項與方案要求。
ChatGPT
ChatGPT 開發者模式可連接遠端 MCP 伺服器,並支援經 OAuth 身分驗證的工具。資格與設定介面可能變化,請遵循 官方 ChatGPT 開發者模式指南,並在建立應用時使用網站的 MCP URL。核准前請審查每次寫入呼叫。
Codex
從 Codex CLI 新增遠端伺服器,然後啟動其 OAuth 登入:
codex mcp add emdash-site --url https://example.com/_emdash/api/mcp
codex mcp login emdash-siteChatGPT 桌面應用、Codex CLI 與 IDE 擴充共用同一 Codex 主機的 MCP 設定。設定檔、OAuth 與支援的傳輸見 官方 Codex MCP 文件。
處理網站內容
連接後,可以用自然語言讓 AI 助手執行這些操作中的任何一項。不必知道工具名稱——只需描述你想要什麼。
Content
- 瀏覽內容 — “Show me the latest 10 blog posts” 或 “Find all draft pages”
- 閱讀內容 — “Get the post called ‘hello-world’ and summarize it”
- 建立內容 — “Write a new blog post about our summer sale” 或 “Create a draft page for the About section”
- 編輯內容 — “Update the pricing page to mention the new plan” 或 “Fix the typo in the FAQ post”
- 發佈與排程 — “Publish the summer sale post”、“Schedule the announcement for June 1st at 9am” 或 “Cancel the schedule on the launch post”
- 比較版本 — “Show me what changed in the homepage since it was last published”
- 管理草稿 — “Discard the draft changes on the about page” 或 “Duplicate the newsletter template”
- 翻譯 — “What translations exist for the welcome post?” 或 “Create a French draft linked to this English post”(啟用 i18n 時)
Bylines
- 瀏覽署名 — “List the guest contributors whose names contain ‘Lee’”
- 為內容署名 — “Add Priya Shah as the primary byline on this post”
- 管理署名 — “Create a guest byline for Sam Rivera” 或 “Update this contributor’s bio”
- 翻譯署名 — “Show the locale variants of this byline”
建立、更新、刪除與翻譯署名需要 Editor 角色。當呼叫者有權建立或編輯該內容時,內容寫入工具接受現有署名 ID。
Media
- 瀏覽媒體 — “List all uploaded images” 或 “Show me PDFs in the media library”
- 查看詳情 — “Get the details for this media item”
- 上傳檔案 — “Upload this base64 image as
banner.png” - 確認簽署上傳 — “Confirm the upload with this storage key”
- 更新中繼資料 — “Set the alt text on the hero image to ‘Mountain sunset’”
- 刪除檔案 — “Delete the old banner image”
media_upload 接受 base64 編碼的位元組,儲存檔案,註冊媒體項目,並回傳 ID 與 URL。它強制執行網站的 MIME 類型與上傳大小限制。
media_create 完成透過 POST /_emdash/api/media/upload-url 建立的待處理上傳。用回傳的簽署 URL 上傳檔案,然後從同一使用者帳戶將其 storageKey 傳給 media_create。確認會檢查已儲存檔案是否存在,並與請求上傳 URL 時提供的大小符合。此工作流程需要 Author 或更高角色;Contributor 可以使用 media_upload。
Search
- 尋找內容 — “Search for posts mentioning ‘accessibility’” 或 “Find anything about TypeScript across all collections”
Taxonomies
- 瀏覽 — “List all categories” 或 “Show me the tags”
- 建立術語 — “Add a ‘tutorials’ tag” 或 “Create a ‘Frontend’ subcategory under ‘Engineering’”
- 重新命名術語 — “Rename the ‘frontend’ category to ‘Web Frontend’”
- 移動術語 — “Move the ‘tutorials’ tag under the ‘guides’ category” 或 “Detach ‘react’ from its parent”
- 刪除術語 — “Delete the unused ‘archive’ tag”
Menus
- 查看選單 — “Show me the main navigation menu” 或 “What’s in the footer menu?”
- 建立選單 — “Create a new ‘sidebar’ menu”
- 編輯選單 — “Rename the ‘main’ menu to ‘Primary navigation’”
- 設定項目 — “Replace the items in the main menu with Home, Blog, About, and Contact”
- 刪除選單 — “Delete the unused ‘mobile’ menu”
Site settings
- 檢查 — “What’s the current site title?” 或 “Show me the social links”
- 更新身分 — “Set the site title to ‘Acme Blog’ and tagline to ‘Stories from the team’”
- 設定標誌 / favicon — “Use this image as the site logo”(用
media_upload上傳之後) - SEO 預設值 — “Set the default OG image to the new banner” 或 “Update the title separator to a vertical bar”
- 社交帳號 — “Add our GitHub and YouTube links to the social settings”
Schema(僅 Admin)
- 檢查 — “What collections exist?” 或 “Show me the fields on the posts collection”
- 建立集合 — “Create a new ‘testimonials’ collection with name and quote fields”
- 修改 schema — “Add a ‘featured’ boolean field to posts”
Revisions
- 查看歷史 — “Show the revision history for this post”
- 還原 — “Restore the post to its previous version”
權限
當 MCP 客戶端開啟 OAuth 同意頁時,它請求的每項權限預設都被選取。在核准存取前,取消客戶端不需要的任何權限。結果 token 僅限於你保持選取的權限以及 EmDash 角色允許的權限,因此授予更少權限絕不會增加客戶端能做的事。
| 角色 | AI 能做什麼 |
|---|---|
| Admin | 一切,包括 schema 變更與更新網站設定 |
| Editor | 管理所有內容、媒體、署名、分類法與選單。查看 schema 並讀取設定。 |
| Author | 建立內容;編輯並發佈自有內容;上傳媒體並管理自有媒體。 |
| Contributor | 建立草稿內容並上傳媒體,不可發佈。 |
當 token scope 或使用者角色不足時,EmDash 會拒絕工具呼叫。客戶端可以解釋該錯誤,但 EmDash 仍是強制執行的權威。
提示
- 對集合要具體。 若有多個集合,說「create a blog post」而不是「create a post」。
- 先詢問 schema。 若不確定集合有哪些欄位,在建立或編輯內容前先問「What fields does the posts collection have?」。
- 發佈前審查。 讓 AI 以草稿建立內容,在管理面板中審查,再讓 AI 發佈——或自行發佈。
- 用 compare 做審查。 發佈前問「Compare the live and draft versions of this post」,以準確查看將要變更的內容。
- 富文字欄位使用 Portable Text。 AI 可為富文字欄位撰寫內容,但複雜格式最好在管理編輯器中完成。
面向開發者
MCP 伺服器端點、身分驗證方法、OAuth 探索、工具參數與錯誤處理見 MCP 伺服器參考。