一、概述
MCP 架构图

MCP 生命周期

二、创建 MCP SERVER 的 Java 工程
生成初始化工程代码
访问网址:https://start.spring.io/ 填写基本信息→添加依赖项。
选择 Server,点击生成,解压后用 IDEA 打开。
修改 pom.xml 文件
把 spring-ai-starter-mcp-server 依赖改为 spring-ai-starter-mcp-server-webmvc。
完整 pom.xml 内容:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.5.8
com.example
test-mcp-server
0.0.1-SNAPSHOT
test-mcp-server
Demo project for Spring Boot
17
1.1.2
org.springframework.ai
spring-ai-starter-mcp-server-webmvc
org.springframework.boot
spring-boot-starter-test
test
org.springframework.ai
spring-ai-bom
${spring-ai.version}
pom
import
org.springframework.boot
spring-boot-maven-plugin


