MCP Server Demo 项目文档

MCP Server Demo 项目文档

一个基于Spring Boot 的MCP(Model Control Protocol)服务示例项目

liqingdong

Developer Tools
Visit Server

README

MCP Server Demo 项目文档

项目简介

这是一个基于Spring Boot 3.4.4的MCP(Model Control Protocol)服务示例项目,集成Spring AI工具链实现智能服务功能。项目包含基础数值运算、天气查询等服务的实现模板。

核心功能

1. 数字服务NumberService

  • 奇偶数判断
  • 素数检测(已实现)
  • 扩展建议:可添加质因数分解、斐波那契计算等

2. 天气服务WeatherService

  • 天气数据接口(当前使用随机数伪代码。真实需对接第三方API实现,可参考OpenWeatherMap API

3. MCP工具支持

  • 通过@Tool注解暴露服务为标准化工具
  • 通过@ToolParam注解定义服务参数

项目结构

src
|-- main
|  |-- java
|  |  `-- cn
|  |    `-- liqingdong
|  |      `-- mcp
|  |        `-- server
|  |          |-- McpApplication.java
|  |          `-- service
|  |            |-- NumberService.java
|  |            `-- WeatherService.java
|  `-- resources
|    `-- application.yml
`-- test
  `-- java
    `-- cn
      `-- liqingdong
        `-- mcp
          `-- server
            |-- McpApplicationTest.java
            `-- SSEMcpTest.java
            `-- STDIOMcpTest.java


快速开始

环境要求

  • JDK 17
  • Maven 3.8+
  • IDE(推荐IntelliJ IDEA)

运行步骤

1. 克隆仓库

git clone https://github.com/liqingdong/mcp-server-demo.git 

2. 构建项目

mvn clean install

3. 使用服务

3.1 使用STDIO模式
3.1.1 配置启动命令
java -jar -Dspring.ai.mcp.server.stdio=true target/mcp-server-demo-0.0.1-SNAPSHOT.jar
3.1.2 使用支持MCP工具的客户端,例如:Cherry Studio 进行测试
3.2 使用SSE模式
3.2.1 配置启动命令(默认访问地址为:http://localhost:8081/sse)
java -jar target/mcp-server-demo-0.0.1-SNAPSHOT.jar 

核心测试类

测试类名 测试内容
McpApplicationTest 应用上下文加载验证
SSEMcpTest/StdioMcpTest 不同协议的MCP服务测试

开发规范

  1. 代码风格:遵循Spring官方编码规范
  2. 工具注解:所有服务方法需用@Tool标注,参数需用@ToolParam标注
  3. 测试覆盖率:核心功能需达到80%+单元测试覆盖

贡献指南

  1. Fork仓库 → 创建功能分支
  2. 实现新功能/修复问题
  3. 添加对应单元测试
  4. 提交Pull Request至main分支

项目状态

Java Spring Boot Maven MCP junit

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
MCP Package Docs Server

MCP Package Docs Server

Facilitates LLMs to efficiently access and fetch structured documentation for packages in Go, Python, and NPM, enhancing software development with multi-language support and performance optimization.

Featured
Local
TypeScript
Claude Code MCP

Claude Code MCP

An implementation of Claude Code as a Model Context Protocol server that enables using Claude's software engineering capabilities (code generation, editing, reviewing, and file operations) through the standardized MCP interface.

Featured
Local
JavaScript
@kazuph/mcp-taskmanager

@kazuph/mcp-taskmanager

Model Context Protocol server for Task Management. This allows Claude Desktop (or any MCP client) to manage and execute tasks in a queue-based system.

Featured
Local
JavaScript
Linear MCP Server

Linear MCP Server

Enables interaction with Linear's API for managing issues, teams, and projects programmatically through the Model Context Protocol.

Featured
JavaScript
mermaid-mcp-server

mermaid-mcp-server

A Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.

Featured
JavaScript
Jira-Context-MCP

Jira-Context-MCP

MCP server to provide Jira Tickets information to AI coding agents like Cursor

Featured
TypeScript
Linear MCP Server

Linear MCP Server

A Model Context Protocol server that integrates with Linear's issue tracking system, allowing LLMs to create, update, search, and comment on Linear issues through natural language interactions.

Featured
JavaScript
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