
lyeslabs/mcpgen
Developer toolsЭта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал
lyeslabs/mcpgen - кандидат на сервер MCP, импортированный из https://github.com/lyeslabs/mcpgen.
Обзор
lyeslabs/mcpgen - кандидат на сервер MCP, импортированный из https://github.com/lyeslabs/mcpgen.
Обзор (машинный перевод)
mcpgen - это инструмент командной строки, который легко генерирует готовый к производству шаблон сервера Model Context Protocol (MCP) из ваших спецификаций OpenAPI, что позволяет легко раскрывать существующие API в качестве мощных инструментов для агентов ИИ.
Ключевые особенности
Совместимость с OpenAPI: ** Считывает и обрабатывает спецификации OpenAPI в формате YAML или JSON, поддерживающие версии 3.0. Поколение MCP-серверов: Создает полный шаблон Go, необходимый для настройки сервера MCP, включая инициализацию сервера, регистрацию инструмента и скелеты обработчика. Точный перевод схемы: ** Автоматически переводит определения схемы OpenAPI в необходимые JSON Schemas для вводов инструментов (совместим с MCP) и генерирует подробные шаблоны ответов на основе разметки для различных кодов состояния и типов контента, обеспечивая богатый контекст для моделей ИИ. ** Расширенная поддержка схемы: Обрабатывает сложные конструкции схемы OpenAPI, в том числе:
- Массивы и вложенные структуры
- Типовые союзы и комбинаторы
oneOf/anyOf/allOf - Рекурсивные определения типов
- Ограничения проверки (например,
minimum,maximum,maxLength,pattern))
Эта страница переведена автоматически. Технические детали смотрите в оригинале.
README
Показан фрагмент оригинального README. Открыть оригинал.
mcpgen: Seamlessly Transform OpenAPI APIs into AI Agent Tools
mcpgen is a command-line tool that seamlessly generates production-ready Model Context Protocol (MCP) server boilerplate from your OpenAPI specifications, enabling you to easily expose your existing APIs as powerful tools for AI agents.
Key Features
- OpenAPI Compatibility: Reads and processes OpenAPI specifications in YAML or JSON format, supporting versions 3.0.
- Comprehensive MCP Server Generation: Generates the full Go boilerplate required to set up an MCP server, including server initialization, tool registration, and handler skeletons.
- Accurate Schema Translation: Automatically translates OpenAPI schema definitions into the necessary JSON Schemas for tool inputs (compatible with MCP) and generates detailed markdown-based Response Templates (Prompts) for various status codes and content types, providing rich context for AI models.
- Advanced Schema Support: Handles complex OpenAPI schema constructs, including:
- Arrays and nested structures
- Type unions and
oneOf/anyOf/allOfcombinators - Recursive type definitions
- Validation constraints (e.g.,
minimum,maximum,maxLength,pattern)
- Multiple Content Type Handling: Correctly processes and generates templates for operations defining multiple request and response content types.
- Generated Code Quality: Produces well-structured, idiomatic Go code with embedded schemas and prompts, leveraging constants for clarity and maintainability.
- Optional Client & Types Generation: Can optionally generate a Go HTTP client and corresponding Go types based on your OpenAPI schema, simplifying the implementation logic within the generated MCP handlers.
- Developer Friendly: Provides clear handler function skeletons with guidance on where to integrate your core logic to connect to the actual backend API.
- Battle-Tested Foundation: The code generation logic is backed by extensive testing, ensuring high reliability (as demonstrated by 94% coverage and 200% test volume).
Installation
go install github.com/lyeslabs/mcpgen/cmd/mcpgen@latest
By default, the binary is installed to $HOME/go/bin (or %USERPROFILE%\go\bin on Windows).
Make sure this directory is in your PATH.
Usage
mcpgen --input openapi.yaml --output generated-server
Required flags
-
--inputPath to your OpenAPI specification file (YAML or JSON). -
--outputOutput directory for the generated MCP server boilerplate.
Optional flags
-
--validationEnable OpenAPI validation (default:false). -
--packageName for the generated Go package (default:mcpgen). -
--includesComma-separated list of additional includes for the generated code. Usehttpclient,typesto generate the HTTP client and types.
Example
Установка
This server does not publish a one-line install command.
Open the repository installation guide Новичок в MCP? Начните с руководства на mcpskill.org →