hatena-blog-mcp
hatena-blog-mcp
用于创建和更新はてな博客文章(記事)的 MCP 服务器。 它薄薄地封装了はてな博客 AtomPub API, 使 AI 代理能够处理文章的草稿、推敲和发布。
设置
包管理器使用 pnpm(通过 packageManager 字段固定)。
pnpm install # 依存のインストールと同時に prepare で dist がビルドされる获取配置值
在はてな博客的 [设置] > [详细设置] > [AtomPub] 中会显示「根端点」和「API 密钥」。 根端点的格式如下。
https://blog.hatena.ne.jp/{ブログ所有者のはてなID}/{ブログID}/atom环境变量 | 必需 | 值 |
| ○ | 用于认证的账户的はてな ID(API 密钥的持有者) |
| ○ | 根端点中 |
| ○ | API 密钥 |
| 根端点中 |
如果是自己拥有的博客,所有者与操作者是同一人,因此不需要
HATENA_BLOG_OWNER_ID对于共享博客(如公司的技术博客),所有者与操作者不同。此时请在
HATENA_BLOG_OWNER_ID中指定博客所有者的 ID,在HATENA_ID中指定自己的账户即使付费套餐使用了自定义域名,
HATENA_BLOG_ID也应指定设置自定义域名之前的域名
请参考 .env.example。
注册到 MCP 客户端
使用 Claude Code 时:
# 自分が所有するブログ
claude mcp add hatena-blog -s user \
-e HATENA_ID=your-hatena-id \
-e HATENA_BLOG_ID=your-blog.hatenablog.com \
-e HATENA_API_KEY=your-api-key \
-- node /absolute/path/to/hatena-blog-mcp/dist/index.js
# 共有ブログ(所有者と操作者が異なる場合は HATENA_BLOG_OWNER_ID を足す)
claude mcp add hatena-blog -s user \
-e HATENA_ID=your-hatena-id \
-e HATENA_BLOG_OWNER_ID=blog-owner-id \
-e HATENA_BLOG_ID=blog-owner-id.hatenablog.com \
-e HATENA_API_KEY=your-api-key \
-- node /absolute/path/to/hatena-blog-mcp/dist/index.js加上 -s user 即可在所有项目中使用。请勿使用 -s project(API 密钥会被写入 .mcp.json)。
直接写入配置文件时:
{
"mcpServers": {
"hatena-blog": {
"command": "node",
"args": ["/absolute/path/to/tech-blog/dist/index.js"],
"env": {
"HATENA_ID": "your-hatena-id",
"HATENA_BLOG_OWNER_ID": "blog-owner-id",
"HATENA_BLOG_ID": "blog-owner-id.hatenablog.com",
"HATENA_API_KEY": "your-api-key"
}
}
}
}注册完成后,调用 get_blog_info 即可确认连通性。
Related MCP server: Blogger MCP Server
工具
博客整体
工具 | 说明 |
| 获取博客标题和可用集合(也可用于连通性确认) |
| 获取博客中使用的分类列表 |
文章
工具 | 说明 |
| 按最新顺序列出文章(包括草稿)。使用 |
| 遍历页面,对标题、正文、分类进行部分匹配搜索 |
| 获取单篇文章(正文保持注册时的标记格式) |
| 新建文章(默认为草稿) |
| 对文章进行增量更新 |
固定页面
list_pages / search_pages / get_page / create_page / update_page 与文章具有相同的形式。
固定页面仅在はてな博客的付费套餐中可用(免费套餐会返回 404)。
固定页面不包含分类,因此没有 categories 参数。
设计上的决定
不实现删除
文章和固定页面的删除(DELETE)在 API 侧是存在的,但有意不将其作为工具公开。
因为误操作的影响很大,且无法撤销。删除请通过浏览器进行。
update_entry 是增量更新
AtomPub 的 PUT 是「用发送的内容整体替换」,因此即使只想修改标题,
也需要重新发送正文、分类和发布时间。
此服务器在 update_entry 内部执行 GET 后仅替换指定项目再 PUT。
省略的项目将保持当前值不变
省略
updated时,文章发布时间(显示的日期)不会改变传入
categories时是替换(而非追加)。若想保留现有分类,请连同现有分类一起传入
新建默认是草稿
create_entry 的 draft 默认为 true。为避免因代理的操作而突然发布文章,
只有在明确指定 draft: false 时才会发布。
正文的标记格式
content_type 可指定 text/x-markdown / text/x-hatena-syntax / text/html / text/plain(默认为 text/x-markdown)。
但实际如何解释取决于博客侧的「编辑模式」设置,因此需要与博客的设置保持一致来书写。
更新现有文章时,会继承编辑前的标记格式。
定时发布
在 create_entry 中指定 draft: true + scheduled: true + 未来时间的 updated。
列表的分页
はてな博客的 API 每页条数较少,条数由 API 侧决定
(官方文档记载为 7 篇文章,但已确认实际返回 10 篇)。
list_entries 返回一页的内容,将 next_page 传给下一次调用的 page 即可获取后续内容。
需要批量查找时,请使用内部遍历页面的 search_entries。通过 max_pages 控制遍历量。
认证与 URL 中的はてな ID
使用 WSSE 认证(X-WSSE 头)。每次请求都会生成 Nonce 和 Created,
并将 Base64(SHA1(Nonce + Created + API密钥)) 作为 PasswordDigest 发送。
请注意:端点 URL 中的はてな ID(博客所有者)与进行认证的账户是不同的。 API 密钥是按账户而非按博客签发的,因此在共享博客中
URL:
https://blog.hatena.ne.jp/{所有者的ID}/{博客ID}/atom认证: 自己账户的はてな ID + API 密钥
是这种组合。混淆两者会导致 401(密钥不属于所有者)或
403(该账户没有博客权限)。
此服务器通过 HATENA_BLOG_OWNER_ID 和 HATENA_ID 将两者分离,
省略时按同一 ID 处理,因此无论是自己的博客还是共享博客,都可以用相同的设置方法运行。
范围之外
图片上传: 不在 AtomPub 范围内(另有はてなフォトライフ API)
固定页面的布局更改: API 不支持。请通过浏览器设置
OAuth 认证: 仅支持通过 API 密钥进行 WSSE 认证
开发
pnpm run typecheck # 型チェック
pnpm test # ユニットテスト(API はモック)
pnpm run build # dist へビルド
pnpm run dev # ビルドせずに起動
pnpm run inspect # MCP Inspector で手動確認pnpm 10 默认会阻止依赖的构建脚本,因此仅在 package.json 的 pnpm.onlyBuiltDependencies 中允许了 tsx 所使用的 esbuild。
结构
src/
index.ts エントリポイント(stdio トランスポート)
server.ts McpServer の組み立て
config.ts 環境変数の読み込み
hatena/
client.ts AtomPub の HTTP クライアント
wsse.ts WSSE 認証ヘッダの生成
atom.ts Atom XML のパース・生成
types.ts ドメイン型
tools/
blog.ts ブログ全体に対するツール
collection.ts 記事・固定ページ共通のツール定義
shared.ts ツールの共通ヘルパー文章和固定页面在 AtomPub 上结构几乎相同,因此通过 tools/collection.ts 中的
registerCollectionTools,以文章用和固定页面用两种配置分别调用。
许可证
MIT License。详情请参阅 LICENSE。
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
No tool schema history has been recorded yet.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Create, manage, publish, and analyze Inblog content through AI agents.
Travel tools for AI agents: plan and edit real trips, search stays and tours, import travel videos.
Create, edit, organize, publish, and configure JustBlogged blogs from MCP clients.
SEO & marketing toolkit for AI agents: GA4, Search Console, AdSense, GTM, PageSpeed, Trends.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables searching and retrieving articles from Hatena Blog through Claude Desktop/Web. Supports keyword search, fetching recent posts, and retrieving post details by URL.1-
- AlicenseAqualityDmaintenanceEnables AI assistants to interact with the Google Blogger API v3 to manage blog posts and metadata. It supports the full post lifecycle including creating, updating, publishing, and deleting content through natural language.1017MIT
- FlicenseAqualityDmaintenanceEnables AI clients to manage Hexo blogs by providing tools for article CRUD operations, local previewing, and GitHub Pages deployment. It also supports site configuration access and automated Git backups to streamline the entire blogging workflow.121-
- AlicenseNot gradedqualityCmaintenanceEnables AI models to interact with Google Blogger blogs, manage posts, labels, and retrieve blog information via API key or OAuth2.19MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/sumiVer2/hatena-blog-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server