spring-boot-starter-swagger-mcp (also known as Swagger MCP Bridge) is a Spring Boot Starter used to convert a Spring Boot application based on SpringDoc into a production-ready MCP gateway. It reuses the application's existing Swagger/OpenAPI documentation, automatically discovers API operations and registers them as MCP tools, while layering on an intelligent gateway that provides discovery, validation, response shaping, and multi-step workflow orchestration capabilities.
Purpose This project primarily addresses the problem of connecting existing Spring Boot REST APIs to the MCP (Model Context Protocol) ecosystem. Most MCP API bridging solutions are just thin tool wrappers, whereas this project is positioned as a runtime gateway: without modifying the original controller contracts, it exposes existing interfaces to LLM clients while retaining guardrails and observability.
Main capabilities
- Zero-boilerplate discovery: automatically reads SpringDoc OpenAPI operations from a running Spring application.
- Automatic MCP tool registration: each discovered API operation becomes an MCP tool, with the tool name format <tool-name-prefix><operation-id>, default prefix api_.
- Intelligent context gateway tools: provides meta-tools such as meta_get_api_capabilities, meta_validate_api_call, meta_discover_api_tools, meta_describe_api_tool, meta_list_api_groups, meta_plan_api_workflow, meta_invoke_api_workflow, meta_invoke_api_by_intent.
- API catalog and workflow layer: supports capability probing, pre-flight validation, grouped exploration, cold-start planning (dry-run), and sequential execution.
- Rich input schemas: generates required fields, enums, numeric/string/object constraints, examples, and deprecation hints based on OpenAPI constraints.
- Response shaping: controls returned content via JSONPath projection and summaries.
- Execution guardrails: required parameter validation, unresolved path template protection, and _headers security filtering.
- Structured errors: stable error codes, such as INVALID_ARGUMENT, SECURITY_DENIED, WORKFLOW_ERROR, HTTP_DISPATCH_FAILED.
- Dangerous operation protection: by default requires _confirm=CONFIRM for POST/PUT/PATCH/DELETE, with configurable role checks, audit logging, and path blacklists.
- Runtime compatibility: Java 17 bytecode, with CI covering Java 17, 21, 25; Java 21+ optional virtual thread dispatch, with Java 17 automatically falling back to platform threads.
Usage
- Create a Spring Boot 3.5.x application.
- Add the dependency. In Gradle (build.gradle.kts) or Maven (pom.xml), introduce the artifact io.github.neo1228:openapi-mcp-spring-boot-starter (release version such as 0.1.0). If it has not been published to a remote repository, you can first run ./gradlew publishToMavenLocal, and add the mavenLocal() repository on the consumer side, using a local version such as 0.1.0-SNAPSHOT.
- Add a controller.
- Configure in application.yml. Key configurations include: swagger.mcp.enabled (default true), swagger.mcp.api-docs-path (default /v3/api-docs), swagger.mcp.tool-name-prefix (default api_), swagger.mcp.smart-context.gateway-only (expose only meta-tools), swagger.mcp.execution.virtual-threads-enabled (default true, safe fallback on Java 17), swagger.mcp.execution.allowed-argument-headers, swagger.mcp.execution.blocked-argument-headers (by default blocks Host, Content-Length, Connection, Transfer-Encoding, etc.), swagger.mcp.security.require-confirmation-for-risky-operations.
- Start the application: ./gradlew bootRun or ./mvnw spring-boot:run.
- Verify: OpenAPI address http://localhost:8080/v3/api-docs;MCP endpoint http://localhost:8080/mcp。
- Connect from an MCP client. Recommended client flow: first call api_meta_get_api_capabilities to learn the gateway features and security policies; then use api_meta_discover_api_tools or api_meta_list_api_groups to find candidate operations; use api_meta_describe_api_tool to obtain the exact parameter schema; before a risky call, use api_meta_validate_api_call; for multi-step tasks, first api_meta_plan_api_workflow, then api_meta_invoke_api_workflow with dryRun=true to validate, and after confirming there are no errors, execute with dryRun=false. The workflow step format is {"id": "...", "toolName": "...", "arguments": {...}}, and subsequent steps can use JSONPath interpolation to read prior results, for example ${create:$.order.id}. Recursive meta-tool orchestration is prohibited; risky HTTP methods still require a _confirm token within workflows.
Applicable scenarios
- You already have a Spring Boot + SpringDoc OpenAPI application and want to quickly expose it to MCP clients.
- You need to let an LLM safely call backend APIs while preserving contracts, guardrails, and observability.
- Scenarios where a large API requires grouped discovery, preflight validation, and workflow orchestration.
- You want to control which operations are exposed (gateway-only mode) and to confirm dangerous operations.
Limitations
- Spring Boot 4.x is explicitly not supported on the 0.1.x line; you must use Spring Boot 3.5.x with springdoc-openapi 2.8.x.
- The build uses --release 17, and the artifact can be consumed on Java 17, but you need to pay attention to the runtime version.
- Recursive meta-tool orchestration is blocked, and workflow steps can only call generated API operation tools.
- Risky methods require a _confirm token by default.
- Dynamic _headers are restricted by allow/block lists.
- Some production integration capabilities (such as Smithery URL publishing) require the example server to be hosted behind a public HTTPS /mcp endpoint before it is compatible.
The project uses the Apache License 2.0. The example project is located at examples/minimal-webmvc-gradle and can be built into a runnable MCP server image for registry and marketplace submission. For more installation and marketplace-readiness information, see llms-install.md and docs/marketplace-readiness.md.