自动发文 MCP Server

自动发文 MCP Server

MCP自动发文服务

gulihua10010

Research & Data
Visit Server

README

自动发文 MCP Server

简介

本项目实现通过AI生成一篇文章,然后自动发文到CSDN、掘金、博客园。关于MCP协议,详见MCP官方文档

依赖MCP Java SDK开发,任意支持MCP协议的智能体助手(如ClaudeCursor以及千帆AppBuilder等)都可以快速接入。

以下会给更出详细的适配说明。

工具列表

搜索面经 searchExperienceQuestion

  • 从牛客搜索用户发表的面经
  • 输出: 面经内容

查询资讯 searchNews

  • 从网上查询最新的科技资讯话题内容
  • 输出: 资讯标题、资讯内容

发布文章到CSDN publishArticle2Csdn

  • 输入: 文章标题、内容、描述
  • 输出: 文章id、文章链接

发布文章到掘金 publishArticle2Juejin

  • 输入: 文章标题、内容、描述
  • 输出: 文章id、文章链接

发布文章到博客园 publishArticle2Cnblog

  • 输入: 文章标题、内容、描述
  • 输出: 文章id、文章链接

环境参数

JUEJIN_COOKIE

掘金账号的Cookie,主要的请求头Cookie的sessionid字段

CSDN_COOKIE

CSDN账号的Cookie,主要是请求头Cookie的SESSION字段、UserName字段,UserInfo字段、UserToken字段 请求头签名:x-ca-key、x-ca-nonce、x-ca-signature、x-ca-signature-headers、accept、content-type 写死就行了

CNBLOG_COOKIE

博客园账号的Cookie,主要是请求头Cookie的.CNBlogsCookie字段、AspNetCore.Antiforgery.xxxxxxxx字段,.Cnblogs.AspNetCore.Cookies字段

CNBLOG_TOKEN

博客园请求头x-xsrf-token字段

快速开始

使用发文 MCP Server主要通过Java SDK 的形式

Java 接入

前提需要Java 17 运行时环境

安装

git clone https://github.com/yuyuanweb/mcp--server-article

构建

cd mcp--server-article
mvn clean package

使用

  1. 打开Cherry Studio设置,点击MCP 服务器cherry1.png

  2. 点击编辑 JSON,将以下配置添加到配置文件中。

{
  "mcpServers": {
    "articleServer": {
      "command": "java",
      "args": [
        "-Dspring.ai.mcp.server.stdio=true",
        "-Dspring.main.web-application-type=none",
        "-Dlogging.pattern.console=",
        "-jar",
        "/Users/gulihua/IdeaProjects/mcp-server-article/target/mcp-server-0.0.1-SNAPSHOT.jar"
      ],
      "env": {
        "JUEJIN_COOKIE": "掘金的cookie",
        "CNBLOG_COOKIE": "博客园的cookie",
        "CNBLOG_TOKEN": "博客园的x-xsrf-token",
        "CSDN_COOKIE": "CSDN的cookie"
      }
    }
  }
}

cherry2.png

  1. 在设置-模型服务里选择一个模型,输入API密钥,选择模型设置,勾选下工具函数调用功能。 cherry3.png
  2. 在输入框下面勾选开启MCP服务。 cherry4.png
  3. 配置完成,然后查询牛客的用户真实面经,AI生成文章,然后发布到CSDN、掘金、博客园。 cherry5.png

代码调用

  1. 引入依赖
        <dependency>
            <groupId>com.alibaba.cloud.ai</groupId>
            <artifactId>spring-ai-alibaba-starter</artifactId>
            <version>1.0.0-M6.1</version>
        </dependency>
    <dependency>
      <groupId>org.springframework.ai</groupId>
      <artifactId>spring-ai-mcp-client-spring-boot-starter</artifactId>
      <version>1.0.0-M6</version>
    </dependency>
  1. 配置MCP服务器 需要在application.yml中配置MCP服务器的一些参数:
spring:
  ai:
    mcp:
      client:
        stdio:
          # 指定MCP服务器配置文件
          servers-configuration: classpath:/mcp-servers-config.json
  mandatory-file-encoding: UTF-8

其中mcp-servers-config.json的配置如下:

{
  "mcpServers": {
    "articleServer": {
      "command": "java",
      "args": [
        "-Dspring.ai.mcp.server.stdio=true",
        "-Dspring.main.web-application-type=none",
        "-Dlogging.pattern.console=",
        "-jar",
        "/Users/gulihua/IdeaProjects/mcp-server-article/target/mcp-server-0.0.1-SNAPSHOT.jar"
      ],
      "env": {
        "JUEJIN_COOKIE": "掘金的cookie",
        "CNBLOG_COOKIE": "博客园的cookie",
        "CNBLOG_TOKEN": "博客园的x-xsrf-token",
        "CSDN_COOKIE": "CSDN的cookie"
      }
    }
  }
}

客户端我们使用阿里巴巴的通义千问模型,所以引入spring-ai-alibaba-starter依赖,如果你使用的是其他的模型,也可以使用对应的依赖项,比如openAI引入spring-ai-openai-spring-boot-starter 这个依赖就行了。 配置大模型的密钥等信息:

spring:
  ai:
    dashscope:
      api-key: ${通义千问的key}
      chat:
        options:
          model: qwen-max

通义千问的key可以直接去官网 去申请,模型我们用的是通义千问-Max。 3) 初始化聊天客户端

@Bean
public ChatClient initChatClient(ChatClient.Builder chatClientBuilder,
                                 ToolCallbackProvider mcpTools) {
    return chatClientBuilder
    .defaultTools(mcpTools)
    .build();
}
  1. 接口调用
    @PostMapping(value = "/ai/answer/sse", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    public Flux<String> generateStreamAsString(@RequestBody AskRequest request) {

        Flux<String> content = chatClient.prompt()
                .user(request.getContent())
                .stream()
                .content();
        return content
                .concatWith(Flux.just("[complete]"));

    }

Recommended Servers

Crypto Price & Market Analysis MCP Server

Crypto Price & Market Analysis MCP Server

A Model Context Protocol (MCP) server that provides comprehensive cryptocurrency analysis using the CoinCap API. This server offers real-time price data, market analysis, and historical trends through an easy-to-use interface.

Featured
TypeScript
MCP PubMed Search

MCP PubMed Search

Server to search PubMed (PubMed is a free, online database that allows users to search for biomedical and life sciences literature). I have created on a day MCP came out but was on vacation, I saw someone post similar server in your DB, but figured to post mine.

Featured
Python
dbt Semantic Layer MCP Server

dbt Semantic Layer MCP Server

A server that enables querying the dbt Semantic Layer through natural language conversations with Claude Desktop and other AI assistants, allowing users to discover metrics, create queries, analyze data, and visualize results.

Featured
TypeScript
mixpanel

mixpanel

Connect to your Mixpanel data. Query events, retention, and funnel data from Mixpanel analytics.

Featured
TypeScript
Sequential Thinking MCP Server

Sequential Thinking MCP Server

This server facilitates structured problem-solving by breaking down complex issues into sequential steps, supporting revisions, and enabling multiple solution paths through full MCP integration.

Featured
Python
Nefino MCP Server

Nefino MCP Server

Provides large language models with access to news and information about renewable energy projects in Germany, allowing filtering by location, topic (solar, wind, hydrogen), and date range.

Official
Python
Vectorize

Vectorize

Vectorize MCP server for advanced retrieval, Private Deep Research, Anything-to-Markdown file extraction and text chunking.

Official
JavaScript
Mathematica Documentation MCP server

Mathematica Documentation MCP server

A server that provides access to Mathematica documentation through FastMCP, enabling users to retrieve function documentation and list package symbols from Wolfram Mathematica.

Local
Python
kb-mcp-server

kb-mcp-server

An MCP server aimed to be portable, local, easy and convenient to support semantic/graph based retrieval of txtai "all in one" embeddings database. Any txtai embeddings db in tar.gz form can be loaded

Local
Python
Research MCP Server

Research MCP Server

The server functions as an MCP server to interact with Notion for retrieving and creating survey data, integrating with the Claude Desktop Client for conducting and reviewing surveys.

Local
Python