
spring boot mcp
A zero-configuration tool for automatically exposing Sprint boot endpoints as Model Context Protocol (MCP) tools. This is inspired by https://github.com/tadata-org/fastapi_mcp
Repository Info
About This Server
A zero-configuration tool for automatically exposing Sprint boot endpoints as Model Context Protocol (MCP) tools. This is inspired by https://github.com/tadata-org/fastapi_mcp
Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.
Documentation
Spring Boot MCP Starter
A Spring Boot starter to make your application compliant with the Model Context Protocol (MCP).
Features
- Automatically expose Spring REST controllers as MCP tools.
- Configurable via
application.propertiesorapplication.yml. - Supports tool discovery and execution.
Installation
Add the dependency to your Spring Boot project:
<dependency>
<groupId>com.msra.mcp</groupId>
<artifactId>spring-boot-mcp-starter</artifactId>
<version>1.0.0</version>
</dependency>
Configuration
Add the following properties to your application.properties:
mcp.server.enabled=true
mcp.server.path=/mcp
mcp.server.name=My MCP Server
Usage
Once added, the starter will automatically expose your @RestController endpoints as MCP tools. You can access the MCP server at /mcp.
Available Endpoints
/mcp/tools: Lists all available tools./mcp/execute: Executes a specific tool based on the provided request.
Building and Using Locally
If you want to use this starter in another project (e.g., spring-boot-mcp-demo), follow these steps:
1. Build the Project
Run the following command to build the project and publish it to your local Maven repository:
./gradlew clean build publishToMavenLocal
This will compile the code, run tests, and publish the artifact to your local Maven repository (usually located at ~/.m2/repository).
2. Add Dependency to Your Project
In your spring-boot-mcp-demo project, add the following dependency to your build.gradle:
dependencies {
implementation 'com.msra.mcp:spring-boot-mcp-starter:1.0.0'
}
If you are using Maven, add this to your pom.xml:
<dependency>
<groupId>com.msra.mcp</groupId>
<artifactId>spring-boot-mcp-starter</artifactId>
<version>1.0.0</version>
</dependency>
3. Verify Integration
Ensure that the spring-boot-mcp-starter is correctly integrated by running your spring-boot-mcp-demo application and testing the MCP server functionality.
Testing
To test the Spring Boot MCP Starter, follow these steps:
1. Create a Test Spring Boot Application
Create a new Spring Boot application and add the MCP starter dependency to your build.gradle or pom.xml.
Example build.gradle:
dependencies {
implementation 'com.msra.mcp:spring-boot-mcp-starter:1.0.0'
}
Example pom.xml:
<dependency>
<groupId>com.msra.mcp</groupId>
<artifactId>spring-boot-mcp-starter</artifactId>
<version>1.0.0</version>
</dependency>
2. Define REST Endpoints
Add some @RestController endpoints to your test application. For example:
@RestController
@RequestMapping("/api")
public class TestController {
@GetMapping("/hello")
public String sayHello() {
return "Hello, MCP!";
}
@PostMapping("/echo")
public String echo(@RequestBody String message) {
return message;
}
}
3. Run the Application
Start your Spring Boot application. The MCP server will automatically expose the endpoints as MCP tools.
4. Test the MCP Server
- Access the MCP server at the configured path (e.g.,
/mcp). - Use an MCP client (e.g., Cursor or Claude Desktop) to connect to the MCP server.
- Verify that the tools corresponding to your REST endpoints are discovered and can be executed.
5. Unit Tests
You can also write unit tests for your application using Spring Boot's testing framework. For example:
@SpringBootTest
@AutoConfigureMockMvc
class McpIntegrationTest {
@Autowired
private MockMvc mockMvc;
@Test
void testMcpEndpoint() throws Exception {
mockMvc.perform(get("/mcp"))
.andExpect(status().isOk());
}
}
6. Debugging
If the MCP server is not working as expected:
- Check the logs for errors or warnings.
- Verify that the
mcp.server.enabledproperty is set totrue. - Ensure your REST endpoints are properly annotated with
@RestControllerand mapping annotations like@GetMapping.
License
MIT License.
Quick Start
Clone the repository
git clone https://github.com/ramki982/spring-boot-mcpInstall dependencies
cd spring-boot-mcp
npm installFollow the documentation
Check the repository's README.md file for specific installation and usage instructions.
Repository Details
Recommended MCP Servers
Discord MCP
Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.
Knit MCP
Connect AI agents to 200+ SaaS applications and automate workflows.
Apify MCP Server
Deploy and interact with Apify actors for web scraping and data extraction.
BrowserStack MCP
BrowserStack MCP Server for automated testing across multiple browsers.
Zapier MCP
A Zapier server that provides automation capabilities for various apps.