MCP Server Demo 项目文档
一个基于Spring Boot 的MCP(Model Control Protocol)服务示例项目
liqingdong
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服务测试 |
开发规范
- 代码风格:遵循Spring官方编码规范
- 工具注解:所有服务方法需用
@Tool
标注,参数需用@ToolParam
标注 - 测试覆盖率:核心功能需达到80%+单元测试覆盖
贡献指南
- Fork仓库 → 创建功能分支
- 实现新功能/修复问题
- 添加对应单元测试
- 提交Pull Request至
main
分支
项目状态
Recommended Servers
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.
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.
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.
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.
@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.
Linear MCP Server
Enables interaction with Linear's API for managing issues, teams, and projects programmatically through the Model Context Protocol.
mermaid-mcp-server
A Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.
Jira-Context-MCP
MCP server to provide Jira Tickets information to AI coding agents like Cursor

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.

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.