A
addozhang/spring-rest-to-mcp
Convert Spring REST API to MCP Server with OpenRewrite
在 GitHub 查看 ↗链接已于 2026-11-12 核查 · 自动访问被拒(HTTP 429),状态未能确认
我们没有从该仓库取到可核对的安装命令,也没有公开的远端端点。这两样都没有时,我们不出配置——编一条出来比不给更糟。 各客户端的接法 →
- 来源明细
- 收录自 abordage/awesome-mcp 榜单(我们从中收集的条目之一) · 条目类型:MCP 服务
- 收录与活跃
- 收录于 2026-11-05 · 最近见到 2026-11-14 · 共见到 10 次 · 被 10 个来源列出
- 评分构成
- 综合分 1,003 · 10 个来源 · mcp
常见问题(答案都来自我们的记录)
它适合谁 / 用来做什么?
我们把它归在这些标签下: MCP 服务。标签来自条目自身,不是我们强加的分类。
谁维护它、还在更新吗?
我们收录于 2026-11-05;最近见到 2026-11-14。这里没有"官方认证"或"质量评级"——我们只记录来源与时间。
# Spring Web to MCP Converter 🚀
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
An OpenRewrite recipe collection that automatically converts Spring Web REST APIs to Spring AI Model Context Protocol (MCP) server tools.
## 📋 Introduction
This project provides a set of OpenRewrite recipes that help you migrate traditional Spring Web REST APIs to Spring AI's Model Context Protocol (MCP) server tools. The transformation includes:
1. 🔄 Converting Spring Web annotations to Spring AI MCP @Tool annotations
2. 🔧 Adding necessary MCP configuration and components
3. 📦 Updating Maven dependencies to include Spring AI MCP server components
The recipes automatically extract documentation from your existing REST controllers to create properly documented MCP tools, making your APIs accessible to AI agents through the Model Context Protocol.
For more details about Spring AI's implementation of MCP, see the Spring AI MCP documentation.
## 🛠️ How to Build and Install
### Prerequisites
Java 17 or higher
Maven 3.6+
### Prerequisites for Target REST API Projects
To successfully migrate your Spring Web REST API to MCP, your project should:
Use Spring Boot 3.2+ (3.2.0 or newer)
Use Spring Web MVC for REST controllers
Use Maven build tool
The recipe adds Spring AI MCP dependencies (version 1.0.0-SNAPSHOT or newer) to your project automatically.
### Build Steps
1. Clone this repository:
bash
git clone https://github.com/yourusername/web-to-mcp.git
cd web-to-mcp
2. Build the project:
bash
mvn clean install
This will compile the code and install the artifact to your local Maven repository.
## 🔥 How to Use
To apply the recipes to your Spring Web project, run the following Maven command:
bash
mvn org.openrewrite.maven:rewrite-maven-plugin:6.4.0:run \
-Drewrite.activeRecipes=RewriteWebToMCP \
-Drewrite.recipeArtifactCoordinates=com.atbug.rewrite:web-to-mcp:1.0-SNAPSHOT \
-Drewrite.exportDatatables=true
Important: This command needs to be executed twice:
1. First execution will update your pom.xml to add necessary repositories and dependencies
2. Second execution will perform the actual code conversion of your Spring Web controllers to MCP tools
## ✨ Features
The recipe performs several transformations that are organized into three main components:
### 1. POM Updates (UpdatePom)
Adds Spring Snapshots repository (https://repo.spring.io/snapshot)
Adds Central Portal Snapshots repository (https://central.sonatype.com/repository/maven-snapshots/)
Adds Spring AI MCP server WebMVC dependency (spring-ai-starter-mcp-server-webmvc)
### 2. Code Transformations
AddToolAnnotationToMappingMethod: Automatically converts Spring Web controller methods to MCP tools
Adds @Tool annotations to methods with Spring Web mapping annotations (@GetMapping, @PostMapping, etc.)
Extracts method descriptions from JavaDoc comments to populate the description attribute
Adds @ToolParam annotations to method parameters, preserving their descriptions from JavaDoc
AddToolCallbackProviderBean: Creates or updates a bean to register MCP tools
Identifies Spring Boot application entry point class
Creates a ToolCallbackProvider bean to register all controllers with @Tool annotations
Intelligently updates existing provider beans if they already exist
AddSpringAIMcpProperties: Configures MCP server properties
## 📋 Introduction
This project provides a set of OpenRewrite recipes that help you migrate traditional Spring Web REST APIs to Spring AI's Model Context Protocol (MCP) server tools. The transformation includes:
1. 🔄 Converting Spring Web annotations to Spring AI MCP @Tool annotations
2. 🔧 Adding necessary MCP configuration and components
3. 📦 Updating Maven dependencies to include Spring AI MCP server components
The recipes automatically extract documentation from your existing REST controllers to create properly documented MCP tools, making your APIs accessible to AI agents through the Model Context Protocol.
For more details about Spring AI's implementation of MCP, see the Spring AI MCP documentation.
## 🛠️ How to Build and Install
### Prerequisites
Java 17 or higher
Maven 3.6+
### Prerequisites for Target REST API Projects
To successfully migrate your Spring Web REST API to MCP, your project should:
Use Spring Boot 3.2+ (3.2.0 or newer)
Use Spring Web MVC for REST controllers
Use Maven build tool
The recipe adds Spring AI MCP dependencies (version 1.0.0-SNAPSHOT or newer) to your project automatically.
### Build Steps
1. Clone this repository:
bash
git clone https://github.com/yourusername/web-to-mcp.git
cd web-to-mcp
2. Build the project:
bash
mvn clean install
This will compile the code and install the artifact to your local Maven repository.
## 🔥 How to Use
To apply the recipes to your Spring Web project, run the following Maven command:
bash
mvn org.openrewrite.maven:rewrite-maven-plugin:6.4.0:run \
-Drewrite.activeRecipes=RewriteWebToMCP \
-Drewrite.recipeArtifactCoordinates=com.atbug.rewrite:web-to-mcp:1.0-SNAPSHOT \
-Drewrite.exportDatatables=true
Important: This command needs to be executed twice:
1. First execution will update your pom.xml to add necessary repositories and dependencies
2. Second execution will perform the actual code conversion of your Spring Web controllers to MCP tools
## ✨ Features
The recipe performs several transformations that are organized into three main components:
### 1. POM Updates (UpdatePom)
Adds Spring Snapshots repository (https://repo.spring.io/snapshot)
Adds Central Portal Snapshots repository (https://central.sonatype.com/repository/maven-snapshots/)
Adds Spring AI MCP server WebMVC dependency (spring-ai-starter-mcp-server-webmvc)
### 2. Code Transformations
AddToolAnnotationToMappingMethod: Automatically converts Spring Web controller methods to MCP tools
Adds @Tool annotations to methods with Spring Web mapping annotations (@GetMapping, @PostMapping, etc.)
Extracts method descriptions from JavaDoc comments to populate the description attribute
Adds @ToolParam annotations to method parameters, preserving their descriptions from JavaDoc
AddToolCallbackProviderBean: Creates or updates a bean to register MCP tools
Identifies Spring Boot application entry point class
Creates a ToolCallbackProvider bean to register all controllers with @Tool annotations
Intelligently updates existing provider beans if they already exist
AddSpringAIMcpProperties: Configures MCP server properties
收录徽章(可选)
想把收录标记放进 README 就复制这行,可选,不影响收录。
[](https://anclum.com/zh/s/addozhang-spring-rest-to-mcp/)
- 来源
- awesome · https://github.com/addozhang/spring-rest-to-mcp
- 按领域浏览
- MCP 服务
- 收录来源
- 10 个独立来源
- 收录于
- 今天
同类推荐
所属领域与标签
每个标签都能点进去看同类的全部条目。数字是当前库里的真实条数。