mcpField
M
Medium MCP API Server

Medium MCP API Server

本地服务
github.com/jignesh88开发工具684 周前更新

关于 Medium MCP API Server

Medium MCP API Server 将 Medium API 封装为内容发布与账户管理服务,面向需要从外部应用管理 Medium 的用户。支持草稿、定时发布和媒体上传。

主要功能

  1. 01Medium OAuth 与用户资料管理
  2. 02Markdown 和 HTML 内容发布
  3. 03草稿管理与定时发布
  4. 04标签及 publication 支持
  5. 05图片上传与内容格式处理

适用场景

  1. 01从应用发布 Medium 文章
  2. 02先保存草稿再安排发布时间
  3. 03上传文章配图并管理内容
  4. 04集中管理 Medium 用户账户

MCP 相关

该服务通过 MCP 连接 AI 助手与 Medium API,向 MCP 客户端提供内容发布和账户管理能力。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

暂未收录安装方式

我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。

代码仓库

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

Medium MCP API 服务

一个模型上下文协议(MCP)服务,可与 Medium 的 API 集成,以便从外部应用无缝发布内容并管理用户账户。模型上下文协议为 AI 模型与外部服务和 API 交互提供了标准化方式,让此服务能够充当 AI 助手与 Medium 发布平台之间的桥梁。

🚀 功能

  • 身份验证与用户管理

    • 安全的 Medium OAuth 集成
    • 基于 JWT 的身份验证
    • 用户个人资料管理
  • 内容发布

    • 支持 Markdown 和 HTML 内容格式
    • 草稿创建与管理
    • 帖子定时发布
    • 发布集成
    • 标签和类别支持
  • 媒体管理

    • 图片上传与存储
    • 内容格式化工具
  • 可靠性与性能

    • 基于 Redis 的缓存
    • 帖子发布任务调度
    • 全面的错误处理
    • 速率限制

📋 要求

  • Node.js 16+
  • MongoDB
  • Redis(可选,但建议用于定时发布)
  • Medium API 凭据

🛠️ 安装

使用 Docker(推荐)
  1. 克隆代码库:

    git clone https://github.com/jignesh88/medium-mcp-api.git
    cd medium-mcp-api
    
  2. 根据示例创建 .env 文件:

    cp .env.example .env
    
  3. 使用你的凭据更新 .env 文件:

    MEDIUM_CLIENT_ID=your_medium_client_id
    MEDIUM_CLIENT_SECRET=your_medium_client_secret
    MEDIUM_REDIRECT_URI=http://your-domain.com/api/auth/medium/callback
    JWT_SECRET=your_strong_secret_key
    
  4. 使用 Docker Compose 启动服务:

    docker-compose up -d
    
手动安装
  1. 克隆代码库:

    git clone https://github.com/jignesh88/medium-mcp-api.git
    cd medium-mcp-api
    
  2. 安装依赖:

    npm install
    
  3. 创建并配置 .env 文件

  4. 启动 MongoDB 和 Redis 服务

  5. 启动应用:

    npm start
    

🔐 Medium API 设置

  1. 在 https://medium.com/me/applications 创建 Medium 开发者应用
  2. 将回调 URL 设置为 http://your-domain.com/api/auth/medium/callback
  3. 将 Client ID 和 Client Secret 复制到 .env 文件中

📚 API 文档

身份验证端点
注册新用户
POST /api/auth/register

请求正文:

{
  "email": "[email protected]",
  "name": "John Doe"
}

响应:

{
  "message": "User registered successfully",
  "token": "jwt_token_here",
  "user": {
    "userId": "user_id",
    "email": "[email protected]",
    "name": "John Doe"
  }
}
登录
POST /api/auth/login

请求正文:

{
  "email": "[email protected]"
}

响应:

{
  "message": "Login successful",
  "token": "jwt_token_here",
  "user": {
    "userId": "user_id",
    "email": "[email protected]",
    "name": "John Doe",
    "mediumConnected": true
  }
}
连接 Medium 账户
GET /api/auth/medium

请求头:

Authorization: Bearer jwt_token_here

响应:

{
  "authUrl": "https://medium.com/m/oauth/authorize?client_id=..."
}
内容管理端点
创建帖子
POST /api/posts

请求头:

Authorization: Bearer jwt_token_here

请求正文:

{
  "title": "My New Post",
  "content": "# Markdown Content\n\nThis is my post content.",
  "contentFormat": "markdown",
  "tags": ["programming", "tutorial"],
  "publishStatus": "draft",
  "publicationId": "optional_publication_id"
}

响应:

{
  "_id": "post_id",
  "userId": "user_id",
  "title": "My New Post",
  "content": "# Markdown Content\n\nThis is my post content.",
  "contentFormat": "markdown",
  "tags": ["programming", "tutorial"],
  "publishStatus": "draft",
  "createdAt": "2025-03-16T07:00:00.000Z",
  "updatedAt": "2025-03-16T07:00:00.000Z"
}
将帖子发布到 Medium
POST /api/posts/:postId/publish

请求头:

Authorization: Bearer jwt_token_here

响应:

{
  "message": "Post published successfully",
  "post": {
    "_id": "post_id",
    "mediumPostId": "medium_post_id",
    "title": "My New Post",
    "published": true,
    ...
  }
}
获取用户的帖子
GET /api/posts?status=draft&page=1&limit=10

请求头:

Authorization: Bearer jwt_token_here

响应:

{
  "posts": [
    {
      "_id": "post_id",
      "title": "My New Post",
      ...
    }
  ],
  "total": 15,
  "page": 1,
  "pages": 2
}
媒体管理
上传图片
POST /api/media/upload

请求头:

Authorization: Bearer jwt_token_here
Content-Type: multipart/form-data

表单数据:

image: [file]

响应:

{
  "message": "File uploaded successfully",
  "filePath": "/uploads/filename.jpg",
  "fileName": "filename.jpg",
  "originalName": "my-image.jpg",
  "mimeType": "image/jpeg",
  "size": 12345
}

🔄 与 MCP 服务集成

示例:使用 Node.js 发布帖子
const axios = require('axios');

const API_URL = 'http://your-domain.com';
const TOKEN = 'your_jwt_token';

async function publishPost() {
  try {
    // Create a draft post
    const post = await axios.post(`${API_URL}/api/posts`, {
      title: 'My Awesome Article',
      content: '# Hello Medium\n\nThis is my first post published via the MCP API.',
      contentFormat: 'markdown',
      tags: ['api', 'medium', 'tutorial'],
      publishStatus: 'draft'
    }, {
      headers: {
        'Authorization': `Bearer ${TOKEN}`
      }
    });
    
    // Publish the post to Medium
    const published = await axios.post(`${API_URL}/api/posts/${post.data._id}/publish`, {}, {
      headers: {
        'Authorization': `Bearer ${TOKEN}`
      }
    });
    
    console.log('Post published successfully!', published.data);
  } catch (error) {
    console.error('Error publishing post:', error.response?.data || error.message);
  }
}

publishPost();

📅 定时发布

此服务支持将帖子安排在未来发布。创建或更新帖子时,请添加包含 ISO 时间戳的 scheduledAt 字段:

{
  "title": "Scheduled Post",
  "content": "This will be published automatically.",
  "scheduledAt": "2025-03-20T12:00:00.000Z"
}

如果配置了 Redis,服务会在指定时间自动发布帖子。

🛡️ 安全注意事项

  • 在生产环境中始终使用 HTTPS
  • 定期轮换 JWT 密钥
  • 设置适当的监控和日志记录
  • 将敏感数据存储在环境变量或安全保险库中
  • 实施适当的 CORS 策略

🔧 配置

所有配置均通过环境变量完成:

变量描述必填
PORT服务端口(默认:3000)否
MONGODB_URIMongoDB 连接字符串是
REDIS_URLRedis 连接字符串否
JWT_SECRETJWT 令牌密钥是
MEDIUM_CLIENT_IDMedium API 客户端 ID是
MEDIUM_CLIENT_SECRETMedium API 客户端密钥是
MEDIUM_REDIRECT_URIOAuth 回调 URL是
FRONTEND_URL前端重定向 URL是

📜 许可证

MIT

🤝 参与贡献

欢迎贡献!请随时提交 Pull Request。

  1. Fork 此仓库
  2. 创建功能分支(git checkout -b feature/amazing-feature)
  3. 提交更改(git commit -m 'Add some amazing feature')
  4. 将分支推送到远程仓库(git push origin feature/amazing-feature)
  5. 发起 Pull Request

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。