
lostinbrittany/swagger-to-mcp-generator
API development이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요. 원문 보기
Quarkus MCP 서버가 Open API Swagger 파일을 생성하는 Java 프로그램
개요
이 프로젝트는 OpenAPI/Swagger 사양을 Model Context Protocol (MCP) 서버로 자동 변환하는 강력한 도구를 제공하며 LLM은 표준화된 도구를 통해 REST API와 상호 작용할 수 있습니다. OpenAPI/Swagger 사양을 완전히 기능적인 MCP 서버로 변환하는 종합 유틸리티: - OpenAPI 사양 파일을 포괄합니다 - MCP 도구로 API 엔드포인트를 변환합니다 - 경로 매개변수, 쿼리 매개 변수 및 요청 본문을 처리하십시오 - 다중 HTTP 메소드 (GET, POST, PUT, DELETE, PATCH)를 지원하여 인증 지원 (API 키, Bearer 토큰, Basic auth)를 제공합니다 - readability에 대한 JSON 응답을 포맷합니다 - 오류 처리 오류 처리 및 유효성 검사를 포함합니다. OpenAPI 사양에서 MCP 서버를 생성하려면: 매개변수: - path/to/swagger.json: OpenAPI/Swagger 명세 파일에 경로 - GeneratedMcpServer: 산출 Java 파일의 이름 ( 없이.
개요(AI 번역)
이 프로젝트는 OpenAPI/Swagger 사양을 Model Context Protocol (MCP) 서버로 자동 변환하는 강력한 도구를 제공하며 LLM은 표준화된 도구를 통해 REST API와 상호 작용할 수 있습니다.
부품
SwaggerToMcpGenerator.java에 대한 의견
OpenAPI/Swagger 사양을 완전 기능 MCP 서버로 변환하는 종합 유틸리티:
- OpenAPI 사양 파일
- API 엔드포인트를 MCP 도구로 변환
- 핸들 경로 매개 변수, 쿼리 매개 변수, 및 요청 기관
- 다중 HTTP 방법 지원 (GET, POST, PUT, DELETE, PATCH)
- 인증 지원 제공 (API 키, Bearer 토큰, Basic auth)
- readability에 대한 JSON 응답
- 강력한 오류 처리 생성
- 유효 값과 기본값을 가진 매개변수 문서 포함
OpenAPI에서 MCP Server 생성
OpenAPI 사양에서 MCP 서버를 생성하려면:
모수:
path/to/swagger.json: OpenAPI/Swagger 사양 파일 경로GeneratedMcpServer: 출력의 이름 Java 파일 (.java 확장없이)
옵션:
--server-index: OpenAPI 사양(0기 기준)에서 사용하는 서버의 인덱스
이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요.
README
원문 README의 일부입니다. 원문 보기.
OpenAPI to MCP Generator
This project provides a powerful tool for automatically converting OpenAPI/Swagger specifications into Model Context Protocol (MCP) servers, allowing LLMs to interact with any REST API through standardized tools.
Components
SwaggerToMcpGenerator.java
A comprehensive utility that converts any OpenAPI/Swagger specification into a fully functional MCP server:
- Parses OpenAPI specification files
- Converts API endpoints to MCP tools
- Handles path parameters, query parameters, and request bodies
- Supports multiple HTTP methods (GET, POST, PUT, DELETE, PATCH)
- Provides authentication support (API keys, Bearer tokens, Basic auth)
- Formats JSON responses for readability
- Generates robust error handling
- Includes parameter documentation with valid values and defaults
Generating an MCP Server from OpenAPI
To generate an MCP server from any OpenAPI specification:
jbang SwaggerToMcpGenerator.java path/to/swagger.json GeneratedMcpServer [options]
Parameters:
path/to/swagger.json: Path to the OpenAPI/Swagger specification fileGeneratedMcpServer: Name of the output Java file (without .java extension)
Options:
--server-index: Index of the server to use from the OpenAPI specification (0-based)--server-url: URL of the server to use (overrides server-index)
This will create a new file GeneratedMcpServer.java that implements an MCP server with tools for each API endpoint defined in the swagger file. The generator will emit a warning if multiple servers are defined in the OpenAPI specification and none is explicitly selected.
Running the Generated MCP Server
To run the generated MCP server:
jbang GeneratedMcpServer.java
Server Selection
The generated MCP server includes constants for all servers defined in the OpenAPI specification, allowing you to choose which server to use at runtime. By default, the first server in the list is used, but you can select a specific server using environment variables:
# Select server by index (0-based)
export SERVER_INDEX=1
# Or select server by URL
export SERVER_URL="https://api-example.com/v2"
jbang GeneratedMcpServer.java
Authentication
The generated MCP server supports multiple authentication methods through environment variables:
- API Key: Set
API_KEYandAPI_KEY_HEADERenvironment variables - Bearer Token: Set
BEARER_TOKENenvironment variable - Basic Auth: Set
API_USERNAMEandAPI_PASSWORDenvironment variables
Example:
export API_KEY="your-api-key"
export API_KEY_HEADER="X-API-Key"
jbang GeneratedMcpServer.java
Examples
Open-Meteo Weather API
The project includes an example OpenAPI specification for the Open-Meteo Weather API in the examples/open-meteo directory.
Generating the Open-Meteo MCP Server
cd examples/open-meteo
jbang ../../SwaggerToMcpGenerator.java open-meteo-openapi.yml OpenMeteoMcpServer
설치
This server does not publish a one-line install command.
Open the repository installation guide MCP 초보자라면? mcpskill.org 가이드부터 시작하세요 →