Sponsored by Deepsite.site

Mcp Seal Generator Server

Created By
lilei03036 months ago
基于 Spring AI 的印章生成的 MCP Server 服务,快速让 AI 生成公章、私章。
Content

公章、私章生成 MCP Server

简介

MCP公章、私章生成服务是一款基于Spring Boot开发的服务,支持通过MCP协议生成公章和私章图片。服务提供以下主要功能: 关于MCP协议,详见MCP官方文档

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

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

工具列表

公章生成 generateOfficialSeal

  • 根据公章描述生成公章图片返回URL
  • 输入: 公章描述
  • 输出: 链接+提示

私章生成 generatePersonalSeal

  • 根据公章描述生成公章图片返回URL
  • 输入: 私章描述
  • 输出: 链接+提示

快速开始

使用公/私章生成MCP Server可以通过Java SDKSSE 的形式

Mcp Server java 开发

Java 版本

java 17 及以上版本

核心依赖

<!-- MCP Server 核心依赖 -->
<dependencies>
   <dependency>
      <groupId>org.springframework.ai</groupId>
      <artifactId>spring-ai-mcp-server-webflux-spring-boot-starter</artifactId>
      <version>1.0.0-M6</version>
   </dependency>
   <!-- minio本地存储服务依赖 -->
   <dependency>
      <groupId>io.minio</groupId>
      <artifactId>minio</artifactId>
      <version>8.5.12</version>
   </dependency>
</dependencies>

配置文件

application.yml中配置MCP Server的相关参数:可选择使用SSE模式或stdio模式。

spring:
  application:
    name: mcp-seal-generate-server
  profiles:
    active: sse # 使用 SSE 模式

server:
  port: 8888

minio:
  endpoint: http://127.0.0.1:9000 #Minio服务所在地址
  bucketName: seal-down #存储桶名称
  accessKey: adminadmin #访问的key
  secretKey: adminadmin #访问的秘钥
SSE模式

application-sse.yml配置示例:

spring:
  ai:
    mcp:
      server:
        enabled: true                # 启用/禁用 MCP 服务
        stdio: false                 # 启用/禁用 stdio 传输
        name: my-mcp-server          # 服务名称
        version: 0.0.1               # 服务版本
        type: SYNC                   # 服务类型(SYNC/ASYNC)
        sse: true                   # 启用 SSE 传输
        resource-change-notification: true  # 启用资源变更通知
        prompt-change-notification: true    # 启用提示词变更通知
        tool-change-notification: true      # 启用工具变更通知
#        sse-endpoint: /sse              # SSE 端点路径
本地stdio标准输入输出模式

application-stdio.yml配置示例:

spring:
   ai:
      mcp:
         server:
            name: mcp-seal-generate-server
            version: 0.0.1
            type: SYNC
            # stdio
            stdio: true
   # stdio
   main:
      web-application-type: none # 禁用Web应用类型 
      banner-mode: off # 禁用Banner

定义工具

@Service
public class SealGenerationService {

    @McpTool(name = "generateOfficialSeal", description = "生成公章")
    public String generateOfficialSeal(@ToolParam(description = "参数详细描述", required = false) String param) {
        // 调用生成公章逻辑
        return "url";
    }

    @McpTool(name = "generatePersonalSeal", description = "生成私章")
    public Mono<McpToolResponse> generatePersonalSeal(@ToolParam(description = "参数详细描述", required = true) String param) {
        // 调用生成私章逻辑
        return "url";
    }
}
  • required: 表示该参数是否必须, true:表示必须,false:表示可选。

配置工具回调

@Configuration
public class McpServerConfig {
   @Bean
   public ToolCallbackProvider sealGenerationTool(SealGenerationService sealGenerationService) {
      // 返回一个 ToolCallbackProvider 实例,用于处理印章生成工具的回调
      return MethodToolCallbackProvider.builder()
              .toolObjects(sealGenerationService)
              .build();
   }
}

MinIO 配置

Minio是一个开源的对象存储服务,可以用于存储生成的公章和私章图片。本项目中用于上传生成的印章图片。 通过docker快速部署MinIO服务,docker-compose.yml配置示例:

services:
  minio:
    image: bitnami/minio:latest
    ports:
      - 9000:9000 # api 端口
      - 9001:9001 # 服务器 端口
    environment:
      - MINIO_ROOT_USER=adminadmin
      - MINIO_ROOT_PASSWORD=adminadmin # 管理后台密码,最小8个字符

运行:已安装docker

  • 在文件路径下cmd窗口执行命令docker-compose up -d
  • 在idea中执行

Mcp客户端调用 - SSE模式接入

代码接入

  1. 配置

需要java 17及以上版本 首先需要引入客户端依赖:

<dependency>
   <groupId>org.springframework.ai</groupId>
   <artifactId>spring-ai-mcp-client-spring-boot-starter</artifactId>
   <version>1.0.0-M6</version>
</dependency>

其次配置文件需要配置MCP服务器的一些参数:sse模式配置如下:

spring:
   ai:
      mcp:
         client:
            enabled: true
            name: my-mcp-client
            version: 0.0.1
            request-timeout: 60000
            type: SYNC  # or ASYNC for reactive applications
            sse:
               connections:
                  server1:
                    url: http://localhost:8888
  1. 使用

需要在代码中配置MCP服务器的工具回调提供者,会根据工具的定义自动生成对应的回调提供者。

public class ModelService {
    @Resource
    ToolCallbackProvider toolCallbackProvider;
    // ...
}

注入后,ai模型会根据对话情况考虑收调用工具服务

public class ModelService {
   private SelfModelChatClient selfModelChatClient;
   public String doChatWithMcp(String message, String chatId) {
      ChatResponse chatResponse = selfModelChatClient.prompt().user("请帮我生成一枚公章,内容是: " + message)
              // 使用 MCP 工具
              .tools(toolCallbackProvider)
              .call()
              .chatResponse();
      String text = chatResponse.getResult().getOutput().getText();
      log.info("Chat response with MCP: {}", text);
      return text;
   }
}

Cherry Studio 接入

使用

  1. 打开Cherry Studio设置,点击MCP 服务器cherry1.png
  2. 点击添加服务器,选择快速创建按下列顺序进行配置。 cherry2.png
  3. 图中标注为绿则表示配置成功。 cherry3.png
  4. 选择一个模型,选择配置的印章MCP服务,输入语句 “请帮我生成一枚圆形公章,主题是“智印信息科技有限公司”,中间是一颗红星,还需要有13位数字的印章编码”。和AI进行对话。 cherry4.png
  5. AI会根据输入语句选择是否调用MCP服务,生成公章图片,并返回图片链接。 cherry5.png
  6. 点击链接可以查看生成的公章图片。 cherry6.png

Mcp客户端调用 - stdio模式接入

代码接入

其余配置和使用方式和SSE模式相同,只需修改配置文件即可,配置文件如下:

spring:
   ai:
      mcp:
         client:
            enabled: true
            name: my-mcp-client
            version: 0.0.1
            request-timeout: 60000
            type: SYNC  # or ASYNC for reactive applications
            stdio:
              servers-configuration: classpath:mcp-server.json # MCP服务器配置文件路径

注意:使用stdio方式时,需要在classpath下创建一个mcp-server.json文件(名称可自定义),内容如下:

{
  "mcpServers": {
    "mcp-seal-generate-server": {
      "command": "java",
      "args": [
        "-Dspring.ai.mcp.server.stdio=true",
        "-Dspring.main.web-application-type=none",
        "-Dlogging.pattern.console=",
        "-jar",
        "/yours_path/mcp-server-0.0.1-SNAPSHOT.jar" 
      ],
      "env": {}
    }
  }
}

其中/yours_path/mcp-server-0.0.1-SNAPSHOT.jar需要替换为实际的MCP Server的jar包路径。

Cherry Studio 接入

使用

  1. 打开Cherry Studio设置,点击MCP 服务器
  2. 点击添加服务器,选择从JSON导入粘贴上述mcp-server.json中的内容。
  3. 图中标注为绿则表示配置成功。

注意:在软件客户端通过stdio模式配置时相当于是在本地启动一个MCP Server,使用标准输入输出方式与客户端进行交互,用的是本地java环境。所以 如果Mcp Server开发环境是Java 17,那么需要确保本地环境也是Java 17及以上版本。如果开发时用的Java 21,那么本地环境也需要是Java 21。

Server Config

{
  "mcpServers": {
    "mcp-seal-generate-server": {
      "command": "java",
      "args": [
        "-Dspring.ai.mcp.server.stdio=true",
        "-Dspring.main.web-application-type=none",
        "-Dlogging.pattern.console=",
        "-jar",
        "/yours_path/mcp-seal-generate-server-0.0.1-SNAPSHOT.jar"
      ],
      "env": {}
    }
  }
}
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
ChatWiseThe second fastest AI chatbot™
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.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
DeepChatYour AI Partner on Desktop
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Tavily Mcp
Serper MCP ServerA Serper MCP Server
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Amap Maps高德地图官方 MCP Server
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
CursorThe AI Code Editor
WindsurfThe new purpose-built IDE to harness magic
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.
Playwright McpPlaywright MCP server
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
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.
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"