Back to MCP directory
publicPublicdnsLocal runtime

medium-mcp-api

一个集成Medium API的MCP服务器,提供内容发布和用户管理功能,支持多种内容格式和定时发布。

article

README

🚀 中文 MCP 服务器文档

中型 MCP(Medium Control Panel)服务器是一个用于管理内容发布和分发的平台。它提供了创建、编辑、发布和调度文章的功能,并支持通过 API 集成到其他系统。

🚀 快速开始

中型 MCP 服务器可助力你轻松管理内容的发布与分发,支持文章的全流程操作,还能通过 API 与其他系统集成。

✨ 主要特性

  • 提供创建、编辑、发布和调度文章的功能。
  • 支持通过 API 集成到其他系统。

📦 安装指南

快速安装

按照以下步骤快速安装 MCP 服务器:

  1. 克隆仓库:
git clone git@github.com:your-repo/mcp-server.git
  1. 安装依赖项:
npm install
  1. 启动服务器:
node index.js

配置

所有配置通过环境变量完成,需在 .env 文件中设置以下参数: | 变量名 | 描述 | 是否必填 | |-----------------|--------------------------|----------| | PORT | 服务器端口(默认:3000) | 否 | | MONGODB_URI | MongoDB 连接字符串 | 是 | | REDIS_URL | Redis 连接字符串 | 否 | | JWT_SECRET | JWT 密钥 | 是 | | MEDIUM_CLIENT_ID | Medium API 客户端 ID | 是 | | MEDIUM_CLIENT_SECRET | Medium API 客户端密钥 | 是 | | MEDIUM_REDIRECT_URI | OAuth 回调 URL | 是 | | FRONTEND_URL | 前端 URL | 是 |

💻 使用示例

基础用法

创建草稿

const axios = require('axios');

async function createDraft() {
  try {
    const response = await axios.post('http://localhost:3000/api/posts', {
      title: '我的第一篇文章',
      content: '# 欢迎使用 MCP 服务器\n这是我的第一篇通过 API 发布的文章。',
      contentFormat: 'markdown',
      tags: ['MCP', '教程', 'API'],
      publishStatus: 'draft'
    }, {
      headers: {
        'Authorization': `Bearer ${TOKEN}`
      }
    });
    
    console.log('草稿创建成功:', response.data);
  } catch (error) {
    console.error('创建草稿失败:', error.response?.data || error.message);
  }
}

createDraft();

发布文章

async function publishArticle(postId) {
  try {
    const response = await axios.post(`http://localhost:3000/api/posts/${postId}/publish`, {}, {
      headers: {
        'Authorization': `Bearer ${TOKEN}`
      }
    });
    
    console.log('文章已发布:', response.data);
  } catch (error) {
    console.error('发布失败:', error.response?.data || error.message);
  }
}

// 调用示例
publishArticle('647f5d3b0c87e5a9c23b1aa1');

获取文章列表

async function listArticles(status = 'all', page = 1, limit = 10) {
  try {
    const response = await axios.get(`http://localhost:3000/api/posts?status=${status}&page=${page}&limit=${limit}`, {
      headers: {
        'Authorization': `Bearer ${TOKEN}`
      }
    });
    
    console.log('文章列表:', response.data);
  } catch (error) {
    console.error('获取文章失败:', error.response?.data || error.message);
  }
}

// 示例调用
listArticles('draft', 1, 20);

调度发布

const scheduledPost = {
  title: '明天的文章',
  content: '# 明天见\n这是一篇预定发布的内容。',
  publishStatus: 'draft',
  scheduledAt: '2023-10-10T15:00:00Z'
};

async function scheduleArticle() {
  try {
    const response = await axios.post('http://localhost:3000/api/posts', scheduledPost, {
      headers: {
        'Authorization': `Bearer ${TOKEN}`
      }
    });
    
    console.log('文章已调度:', response.data);
  } catch (error) {
    console.error('调度失败:', error.response?.data || error.message);
  }
}

scheduleArticle();

📚 详细文档

安全指南

JWT 认证

所有需要认证的 API 请求都需要在头中添加 Authorization 字段,格式如下:

Bearer <your-jwt-token>

密钥管理

确保 JWT_SECRET 和其他敏感配置不被泄露。建议使用环境变量或密钥管理工具来存储这些信息。

错误处理

常见错误代码

| 状态码 | 描述 | |--------|--------------------------| | 401 | 未授权 | | 403 | 禁止访问 | | 500 | 内部服务器错误 |

弃用警告

某些旧的 API 接口可能已弃用,建议更新到最新版本。

开发指南

贡献代码

  1. 提交代码前,请确保通过所有测试。
  2. 遵循项目编码规范。
  3. 提交 PR 时请附带详细的变更说明。

使用 Docker

# Dockerfile
FROM node:16-alpine

WORKDIR /app

COPY package*.json ./

RUN npm install --production

COPY . .

CMD ["node", "index.js"]

📄 联系我们

如需反馈或技术支持,请访问我们的 GitHub 仓库 或发送邮件至 support@yourdomain.com。

感谢使用 MCP 服务器!

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client