AI 工具

本页内容

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-site

ChatGPT 桌面应用、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 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”
  • 查看菜单 — “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 服务器参考。