Telegraph API服务

一个将Telegraph API作为工具暴露给Claude和其他LLM客户端的MCP服务器,允许AI助手以编程方式创建、编辑和管理Telegraph页面。

  • by NehoraiHadad
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 NehoraiHadad/telegraph-mcp

使用说明

电报MCP服务器

一个MCP(模型上下文协议)服务器,它公开 电报API 作为Claude和其他LLM客户的工具。这允许AI助手以编程方式创建、编辑和管理Telegraph页面。

相关项目

这是Telegraph工具生态系统的一部分:

项目 描述 包
电报mcp (this) 用于AI助手的MCP服务器(TypeScript)
电报mcp-py 用于AI助手的MCP服务器(Python)
电报js JavaScript/TypeScript库
电报 Python库

快速开始

npx telegraph-mcp

或者添加到克劳德代码中:

claude mcp add telegraph -- npx telegraph-mcp

特性

  • 13电报API工具 涵盖所有电报功能
  • 创建和管理Telegraph帐户
  • 创建、编辑和检索电报页面
  • 查看页面统计信息
  • Markdown支持 -用Markdown编写内容,自动转换为Telegraph格式
  • 模板 -博客文章、文档、文章、变更日志和教程的预构建模板
  • 导出/备份 -将页面导出为Markdown或HTML,备份整个帐户
  • MCP资源 -访问电报页面作为MCP资源
  • MCP提示 -常见任务的预定义提示

安装

选项1:通过npm(推荐)

# With Claude Code
claude mcp add telegraph -- npx telegraph-mcp

# Or globally
npm install -g telegraph-mcp

选项2:来源

git clone https://github.com/NehoraiHadad/telegraph-mcp.git
cd telegraph-mcp
npm install
npm run build
claude mcp add telegraph -- node $(pwd)/dist/index.js

使用Claude代码

claude mcp add telegraph -- npx telegraph-mcp

使用Claude Desktop

将此添加到您的Claude Desktop配置文件中:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Linux: ~/.config/Claude/claude_desktop_config.json 视窗: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "telegraph": {
      "command": "npx",
      "args": ["-y", "telegraph-mcp"]
    }
  }
}

可用工具

账户管理

工具 描述 需要授权
telegraph_create_account 创建新的Telegraph帐户 否
telegraph_edit_account_info 更新帐户信息 是
telegraph_get_account_info 获取帐户详细信息 是
telegraph_revoke_access_token 撤销并重新生成访问令牌 是

页面管理

工具 描述 需要授权
telegraph_create_page 创建新的Telegraph页面(支持Markdown!) 是
telegraph_edit_page 编辑现有页面 是
telegraph_get_page 按路径获取页面 否
telegraph_get_page_list 列出帐户的所有页面 是
telegraph_get_views 获取页面的浏览统计信息 否

模板

工具 描述 需要授权
telegraph_list_templates 列出所有可用的页面模板 否
telegraph_create_from_template 使用模板创建页面 是

导出和备份

工具 描述 需要授权
telegraph_export_page 将页面导出为Markdown或HTML 否
telegraph_backup_account 备份帐户中的所有页面 是

示例用法

创建帐户

Use telegraph_create_account with:
- short_name: "MyBot"
- author_name: "AI Assistant"

这将返回一个 access_token 你应该为未来的操作存钱。

创建页面

Use telegraph_create_page with:
- access_token: "your_token_here"
- title: "My First Telegraph Page"
- content: "<p>Hello <b>world</b>!</p><p>This is my first Telegraph page.</p>"

使用Markdown创建页面

Use telegraph_create_page with:
- access_token: "your_token_here"
- title: "My Markdown Page"
- content: "# Hello World\n\nThis is **bold** and *italic*.\n\n- List item 1\n- List item 2"
- format: "markdown"

使用模板

Use telegraph_create_from_template with:
- access_token: "your_token_here"
- template: "blog_post"
- title: "My Blog Post"
- data: {
    "intro": "Welcome to my blog!",
    "sections": [
      {"heading": "First Section", "content": "Section content here"}
    ],
    "conclusion": "Thanks for reading!"
  }

可用模板: blog_post, documentation, article, changelog, tutorial

内容格式

这 content 参数接受:

  • 标记语言 (与 format: "markdown"): "# Hello\n\n**Bold** and *italic*"
  • HTML字符串: "<p>Hello <b>world</b></p>"
  • JSON节点数组: [{"tag": "p", "children": ["Hello ", {"tag": "b", "children": ["world"]}]}]

支持的Markdown语法

语法 结果
# Header H3航向
## Subheader H4航向
**bold** 粗体文本
*italic* 斜体文本
[text](url) 链接
![alt](url) 图片
- item 无序列表
1. item 已排序列表
> quote Blockquote
`code` 内联代码
```code``` 代码块
--- 水平规则

支持的HTML标签

a, aside, b, blockquote, br, code, em, figcaption, figure, h3, h4, hr, i, iframe, img, li, ol, p, pre, s, strong, u, ul, video

支持的属性

  • href -for <a> 标签
  • src -for <img>, <video>, <iframe> 标签

MCP资源

访问电报页面作为MCP资源:

telegraph://page/{path}

例子: telegraph://page/Sample-Page-12-15

MCP提示

指导工作流程的可用提示:

提示 描述
create-blog-post 创建博客文章的指南
create-documentation 文档创建指南
summarize-page 总结现有页面

发展

# Install dependencies
npm install

# Build TypeScript
npm run build

# Run directly (for testing)
npm start

MCP检验员测试

npx @modelcontextprotocol/inspector node dist/index.js

api参考

此服务器实现了 电报API:

  1. 创建帐户 -创建新的Telegraph帐户
  2. editAccountInfo -更新帐户信息
  3. 获取账户信息 -获取帐户详细信息
  4. revokeAccessToken -撤销访问令牌
  5. 创建页面 -创建新页面
  6. editPage -编辑现有页面
  7. 获取页面 -获取页面
  8. getPageList -获取页面列表
  9. 获取视图 -获取页面浏览统计信息

许可证

麻省理工学院