Sponsored by Deepsite.site

腾讯云开发者社区文章发布 MCP 服务器

Created By
yangbuyiya7 months ago
这是一个基于 MCP (Model Context Protocol) 协议的服务器,专门用于自动化发布文章到腾讯云开发者社区。通过集成 Spring Boot 3.x 和 Spring AI,为 AI 助手提供了与腾讯云开发者社区交互的能力,实现文章的自动发布和管理。
Content

腾讯云开发者社区文章发布 MCP 服务器

📝 项目简介

这是一个基于 MCP (Model Context Protocol) 协议的服务器,专门用于自动化发布文章到腾讯云开发者社区。通过集成 Spring Boot 3.x 和 Spring AI,为 AI 助手提供了与腾讯云开发者社区交互的能力,实现文章的自动发布和管理。

访问计数

技术栈

  • 框架: Spring Boot 3.4.5
  • AI 集成: Spring AI 1.0.0
  • 运行环境: Java 17
  • 构建工具: Maven
  • 协议支持: MCP (Model Context Protocol)
  • HTTP 客户端: Retrofit2
  • JSON 处理: FastJSON, Jackson

快速开始

环境要求

  • JDK 17 或更高版本
  • Maven 3.6 或更高版本
  • 有效的腾讯云开发者社区账号

安装步骤

  1. 克隆项目
git clone https://github.com/yangbuyiya/tencent-send-article-mcp-server.git
cd tencent-send-article-mcp-server
  1. 获取腾讯云 Cookie

    • 登录 腾讯云开发者社区
    • 打开浏览器开发者工具 (F12)
    • 切换到 Network 标签页
    • 刷新页面,在任意请求的 Headers 中找到 Cookie
    • 复制完整的 Cookie 字符串
  2. 配置认证信息

# 方式一:环境变量
export TENCENT_API_COOKIE="your_cookie_here"

# 方式二:命令行参数
java -jar target/tencent-send-article-mcp-server-app.jar --tencent.api.cookie="your_cookie_here"
  1. 修改代码定义文章专栏

前往 getAddArticleRequest 方法中修改文章部分请求参数 具体参数前往 登录 腾讯云开发者社区 打开开发者工具, 发布一个测试文章选好你要发布的专栏等数据 找到 addArticle 请求复制出来, 将请求参数下面当中的参数替换即可

// 只允许修改下面的参数
addArticleRequest.setSourceType(1);  // 设置为原创
addArticleRequest.setClassifyIds(List.of(3,4));  // 设置文章分类
addArticleRequest.setTagIds(List.of(17375));  // 设置文章标签
addArticleRequest.setLongtailTag(List.of("面试","面试题","趣味面试"));  // 设置长尾标签
addArticleRequest.setColumnIds(List.of(105380));  // 设置专栏ID
addArticleRequest.setOpenComment(1);  // 开启评论
addArticleRequest.setCloseTextLink(1);  // 允许文本链接
addArticleRequest.setPic("https://foruda.gitee.com/images/1748188287230778527/9289646d_5151444.png");  // 设置封面图片
addArticleRequest.setSourceDetail(new HashMap<>());  // 设置来源详情
addArticleRequest.setZoneName("");  // 设置专区名称
  1. 编译和运行
# 编译项目
mvn clean package

配置说明

MCP 客户端配置 STDIO 模式

在您的 MCP 客户端配置文件中添加以下配置:

{
  "mcpServers": {
    "tencent-article-publisher": {
      "command": "java",
      "args": [
        "-Dspring.ai.mcp.server.stdio=true",
        "-Dfile.encoding=utf-8",
        "-jar",
        "/path/to/tencent-send-article-mcp-server-app.jar",
        "--tencent.api.cookie=your_cookie_here"
      ]
    }
  }
}

也可以调用 ClientStdio.java 类进行测试是否通信

MCP 客户端配置 SSE 模式

{
  "mcpServers": {
    "tencent-send-article-mcp-server": {
      "baseUrl": "http://127.0.0.1:8633/sse"
    }
  }
}

项目默认使用 STDIO 模式,如果需要使用 SSE 模式,请按照以下配置进行修改:(项目已经区分配置, 可通过 profiles.active=sse/stdio 切换模式)

修改配置文件 - 新增端口


server:
  port: 8633 # 端口号

修改配置文件 - 切换模式为SSE

  ai:
    mcp:
      server:
        stdio: true # 设置为false 为sse模式
        name: ${spring.application.name}
        version: 1.0.0
        type: sync # 同步/异步
        instructions: "
        这是一个基于 MCP (Model Context Protocol) 协议的服务器,
        专门用于自动化发布文章到腾讯云开发者社区。通过集成 Spring Boot 3.x 和 Spring AI,为 AI 助手提供了与腾讯云开发者社区交互的能力,
        实现文章的自动发布和管理。
        "
        sse-endpoint: /sse # sse端点
        sse-message-endpoint: /mcp/messages # 客户端 sse消息端点
        capabilities:
          tool: true
          resource: true
          prompt: true
          completion: true

修改配置文件 - 日志配置修改


# 注意:您必须禁用web横幅和控制台日志记录,以允许STDIO传输工作!!!
main:
  banner-mode: off
  # SSE打开, STDIO注释
  web-application-type: none

logging:
  # SSE打开, STDIO注释
  pattern:
    console: "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"
  file:
    name: data/log/${spring.application.name}.log

修改 pom.xml - 新增SSE依赖支持


<!-- 标准 SSE/STDIO 服务器配置 通过配置切换 -->
<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-starter-mcp-server-webflux</artifactId>
</dependency>

然后就可以调用 ClientSse.java 类进行测试是否通信

Docker 部署使用

快速部署


docker run -d --name tencent-send-article-mcp-server \
-p 8635:8633 \
-e TENCENT_API_COOKIE="测试Cookie" \
registry.cn-hangzhou.aliyuncs.com/yangbuyiya/tencent-send-article-mcp-server-app:1.0.0

构建镜像

⚠️先修改部署配置文件, 我这里以shell文件为例

# Docker镜像相关配置
DOCKER_IMAGE_NAME="改成你的DockerHub仓库名称/tencent-send-article-mcp-server-app"
DOCKER_IMAGE_TAG="1.0.0"
DOCKER_PLATFORM="linux/amd64,linux/arm64"
DOCKERFILE_PATH="Dockerfile"

# 阿里云配置
ALIYUN_REGISTRY="registry.cn-hangzhou.aliyuncs.com"
NAMESPACE="你的阿里云命名空间仓库名称"
IMAGE_NAME="tencent-send-article-mcp-server-app"
IMAGE_TAG="1.0.0"

修改完毕后, 运行 deploy 脚本进行构建, 构建完成后会生成镜像

运行


docker run -d --name tencent-send-article-mcp-server \
-p 8635:8633 \
-e TENCENT_API_COOKIE="你在腾讯云开发者社区获取的Cookie" \
registry.cn-hangzhou.aliyuncs.com/yangbuyiya/tencent-send-article-mcp-server-app:1.0.0

安全注意事项

⚠️ 重要提醒

  • Cookie 包含敏感的身份认证信息,请妥善保管
  • 不要将 Cookie 提交到代码仓库或公开分享
  • 建议使用环境变量方式配置 Cookie
  • Cookie 可能会定期失效,需要及时更新
  • 生产环境建议使用更安全的认证方式

故障排除

常见问题

  1. Cookie 失效

    • 重新登录腾讯云开发者社区获取新的 Cookie
    • 检查 Cookie 格式是否完整
  2. 文章发布失败

    • 检查网络连接
    • 验证文章内容是否符合社区规范
    • 确认账号权限
  3. MCP 连接问题

    • 检查 Java 路径配置
    • 验证 JAR 文件路径
    • 查看应用日志文件

日志查看

# 查看实时日志
tail -f data/log/tencent-send-article-mcp-server.log

# 查看错误日志
grep "ERROR" data/log/tencent-send-article-mcp-server.log

贡献指南

欢迎提交 Issue 和 Pull Request!

  1. Fork 本项目
  2. 创建特性分支 dev
  3. 提交更改
  4. 推送到分支
  5. 开启 Pull Request

注意:本项目仅用于学习和研究目的,请遵守腾讯云开发者社区的使用条款和相关法律法规。

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Amap Maps高德地图官方 MCP Server
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
ChatWiseThe second fastest AI chatbot™
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
WindsurfThe new purpose-built IDE to harness magic
CursorThe AI Code Editor
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Tavily Mcp
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
DeepChatYour AI Partner on Desktop
Serper MCP ServerA Serper MCP Server
Playwright McpPlaywright MCP server