Spring Web to MCP Converter logo

Spring Web to MCP Converter

by addozhang

This project provides OpenRewrite recipes to migrate Spring Web REST APIs to Spring AI's Model Context Protocol (MCP) server tools. It converts Spring Web annotations to Spring AI MCP `@Tool` annotations, adds necessary MCP configuration, and updates Maven dependencies.

View on GitHub

Last updated: N/A

What is Spring Web to MCP Converter?

This is a collection of OpenRewrite recipes that automates the conversion of Spring Web REST APIs to Spring AI Model Context Protocol (MCP) server tools. It simplifies the process of making existing REST APIs accessible to AI agents through the Model Context Protocol.

How to use Spring Web to MCP Converter?

To use the recipes, build the project and then run the provided Maven command against your Spring Web project. The command needs to be executed twice: first to update the pom.xml with necessary repositories and dependencies, and second to perform the actual code conversion.

Key features of Spring Web to MCP Converter

  • Converts Spring Web annotations to Spring AI MCP @Tool annotations

  • Adds necessary MCP configuration and components

  • Updates Maven dependencies to include Spring AI MCP server components

  • Extracts documentation from existing REST controllers to create properly documented MCP tools

Use cases of Spring Web to MCP Converter

  • Migrating existing Spring Web REST APIs to be compatible with Spring AI's Model Context Protocol.

  • Enabling AI agents to discover and interact with existing REST APIs.

  • Automatically generating documentation for MCP tools from existing JavaDoc comments.

  • Simplifying the integration of REST APIs with AI-powered applications.

FAQ from Spring Web to MCP Converter

What are the prerequisites for using this tool?

Java 17+, Maven 3.6+, Spring Boot 3.2+, Spring Web MVC, and Maven build tool.

What dependencies are added to my project?

Spring AI MCP server WebMVC dependency (spring-ai-starter-mcp-server-webmvc) and Spring Snapshots repository and Central Portal Snapshots repository

How do I verify the conversion?

Check your controller classes for added @Tool and @ToolParam annotations, look for the new ToolCallbackProvider bean in your main application class, and check that application.properties or application.yml has MCP server configuration.

How do I test my MCP server after conversion?

Use the official MCP Inspector to connect to your server and test the available tools. The inspector can be found at https://github.com/modelcontextprotocol/inspector.

Will my existing REST endpoints still work after conversion?

Yes, after conversion, your Spring Boot application will function both as a traditional REST API and as an MCP server. All your existing endpoints continue to work as before.