Spring Boot starter that automatically exposes SpringDoc OpenAPI operations as MCP tools.
- Auto-discovery of OpenAPI operations from your running Spring app
- Auto-registration of MCP tools for discovered API operations
- Smart-context tools:
meta_discover_api_tools,meta_invoke_api_by_intent - Response optimization with projection/summarization controls
- Risk controls for dangerous operations (
_confirm, blocked paths, role checks, audit logs)
graph TD
User([User / LLM Client]) <--> MCP[MCP Client / Claude Desktop]
MCP <--> Bridge[Swagger MCP Bridge /starter/]
Bridge <--> Docs[SpringDoc OpenAPI /v3/api-docs]
Bridge <--> API[Your Spring Controller /hello]
Use:
- Java 17+
- Spring Boot 3.5.x
- Spring Web
Gradle (build.gradle.kts):
plugins {
id("org.springframework.boot") version "3.5.9"
id("io.spring.dependency-management") version "1.1.7"
java
}
java {
sourceCompatibility = JavaVersion.VERSION_17
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springdoc:springdoc-openapi-starter-webmvc-api:2.8.3")
implementation("io.github.neo1228:spring-boot-starter-swagger-mcp:<version>")
}Maven (pom.xml):
<properties>
<swagger-mcp.version>0.1.0-SNAPSHOT</swagger-mcp.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
<version>2.8.3</version>
</dependency>
<dependency>
<groupId>io.github.neo1228</groupId>
<artifactId>spring-boot-starter-swagger-mcp</artifactId>
<version>${swagger-mcp.version}</version>
</dependency>
</dependencies>Use a release version (for example 0.1.0) when consuming from a remote artifact repository.
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@RestController
public class HelloController {
@Operation(operationId = "getHello", summary = "Get greeting message")
@GetMapping("/hello")
public Map<String, Object> hello(@RequestParam(defaultValue = "world") String name) {
return Map.of("message", "Hello " + name);
}
}spring:
ai:
mcp:
server:
protocol: STREAMABLE_HTTP
streamable-http:
mcp-endpoint: /mcp
swagger:
mcp:
enabled: true
api-docs-path: /v3/api-docs
tool-name-prefix: api_- Start app:
./gradlew bootRunor./mvnw spring-boot:run - Verify OpenAPI:
http://localhost:8080/v3/api-docs - Verify MCP endpoint:
http://localhost:8080/mcp - Connect from an MCP client
Generated tool names follow <tool-name-prefix><operation-id> (example: api_gethello).
If the artifact is not published to a remote registry yet:
- Build and publish to local Maven cache:
./gradlew publishToMavenLocal
- In your consumer app:
- add
mavenLocal()repository - use version
0.1.0-SNAPSHOT(or your chosen local version)
- add
swagger.mcp.enabled: enable/disable bridge (defaulttrue)swagger.mcp.api-docs-path: OpenAPI docs path (default/v3/api-docs)swagger.mcp.tool-name-prefix: tool name prefix (defaultapi_)swagger.mcp.smart-context.gateway-only: expose only meta toolsswagger.mcp.security.require-confirmation-for-risky-operations: require_confirmtoken for risky methods
For risky HTTP methods (POST, PUT, PATCH, DELETE), default policy requires _confirm=CONFIRM.
| Starter | Java | Spring Boot | springdoc-openapi | Spring AI BOM |
|---|---|---|---|---|
| 0.1.x | 17+ | 3.5.x | 2.8.3 | 1.1.2 |
Spring Boot 4.x is not supported in this repository.
See examples/minimal-webmvc-gradle for a minimal app using this starter.
- Release process:
RELEASING.md - Versioning policy:
VERSIONING.md - Changelog:
CHANGELOG.md
- Run tests:
./gradlew test - Contribution guide:
CONTRIBUTING.md - Security reporting:
SECURITY.md
Apache License 2.0 (LICENSE)