swagger-codegen-mcp
Generates TypeScript API client code from Swagger/OpenAPI documentation, enabling automated creation of typed API functions and interfaces.
Provides TypeScript type definitions and API functions derived from Swagger documentation, streamlining frontend development with fully typed API clients.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@swagger-codegen-mcpgenerate code for tag VillageNursing"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Swagger API 代码生成器 MCP
从 Swagger/OpenAPI 文档自动生成 TypeScript API 代码的 MCP 服务器。
功能
list_services - 列出所有可用的 API 服务及其 Swagger URL
list_tags - 列出 Swagger 中所有的 API 分组(tags)
list_endpoints - 列出指定 tag 下的所有接口
get_endpoint_detail - 获取单个接口的详细信息
generate_api_code - 生成 TypeScript 代码(支持按 tag 或单个接口)
Related MCP server: Swagger MCP (Multi-API Edition)
支持的服务
MCP 服务器预配置了以下 API 服务,会根据 API 路径自动推断使用哪个服务:
服务名 | Swagger URL | 匹配路径示例 |
village |
|
|
basic |
|
|
ffp |
|
|
dynamic |
|
|
customform |
|
|
ncdp |
|
|
gis |
|
|
query |
|
|
提示:当你传入
path参数时(如/api/village/VillageNursing/GetNursingStats),服务器会自动从路径中提取village并使用对应的 swagger.json,无需手动指定swagger_url。
安装
cd C:\Users\Administrator\.gemini\mcp\swagger-codegen-mcp
npm install配置 Gemini CLI
在 settings.json 中添加此 MCP 服务器:
{
"mcpServers": {
"swagger-codegen": {
"command": "node",
"args": [
"C:\\Users\\Administrator\\.gemini\\mcp\\swagger-codegen-mcp\\src\\index.js"
]
}
}
}使用示例
1. 列出所有可用服务
list_services()返回示例:
{
"success": true,
"total": 8,
"services": [
{
"name": "village",
"url": "https://dvs-dev2.utuapp.cn/api/village/swagger.json"
},
{
"name": "basic",
"url": "https://dvs-dev2.utuapp.cn/api/basic/swagger.json"
}
],
"hint": "使用 path 参数时会自动根据路径推断服务"
}2. 列出所有 API 分组
list_tags()返回示例:
{
"success": true,
"swaggerUrl": "https://dvs-dev2.utuapp.cn/api/village/swagger.json",
"total": 50,
"tags": [
{ "name": "VillageNursing", "description": "" },
{ "name": "Accusation", "description": "" }
]
}3. 列出指定分组的接口
list_endpoints(tag: "VillageNursing")4. 获取接口详情(自动推断服务)
get_endpoint_detail(
path: "/api/village/VillageNursing/GetNursingStats",
method: "get"
)无需指定
swagger_url,会自动从 path 中提取village并使用 village 服务的 swagger.json。
5. 生成整个模块的代码
generate_api_code(tag: "VillageNursing")生成两个文件:
villagenursing.types.ts- 类型定义villagenursing.ts- API 函数
6. 生成单个接口的代码(自动推断服务)
generate_api_code(
path: "/api/basic/User/GetList",
method: "get"
)会自动使用 basic 服务的 swagger.json。
生成的代码风格
生成的代码兼容项目的 request.js 封装:
import request from "@/common/utils/request";
import type {
GetPageListParams,
VillageNursingListDto,
} from "./villagenursing.types";
/** 查询列表 */
export function getPageList(
params: GetPageListParams
): Promise<VillageNursingListDto[]> {
return request("/api/village/VillageNursing/GetPageList", {
method: "get",
params: { RegionId, Limit, Page, Keyword },
});
}配置文件
服务端点配置位于 src/swagger-config.js,可以根据需要添加更多服务:
const SWAGGER_SERVICES = {
village: `${API_BASE_URL}/village/swagger.json`,
basic: `${API_BASE_URL}/basic/swagger.json`,
// 添加更多服务...
};测试
# 运行配置测试
node test/test-config.js
# 查找模型定义
node test/find-model.jsAvailable Tools
5 toolsgenerate_api_codeA
生成TypeScript API代码。可以按tag生成整个模块,或按单个接口生成。会根据path自动推断对应的服务。
| Name | Required | Description | Default |
|---|---|---|---|
| tag | No | 按tag生成整个模块的代码(与path/method二选一) | |
| path | No | 生成单个接口的代码(与tag二选一) | |
| method | No | 配合path使用的HTTP方法 | |
| swagger_url | No | Swagger JSON文档的URL(可选,会根据path自动推断服务) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden. It discloses a notable behavior (auto-inferring the service from the path), but does not describe the output format, potential side effects, error conditions, or authentication requirements—leaving meaningful gaps for an agent.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is two sentences, front-loads the main action, and contains no filler. Every clause adds useful information about functionality and behavior.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description is adequate for a simple generator tool but lacks elaboration on what the generated output looks like, how to select between modes operationally, and what happens if no parameter is provided. It does not mention the optional swagger_url's role or dependency on sibling discovery tools, leaving some context incomplete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Although schema descriptions cover 100% of parameters, the description adds semantic context by clarifying that tag and path are mutually exclusive modes and that path auto-infers the service, reinforcing the relationship between parameters beyond the schema's individual descriptions.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: generating TypeScript API code. It further specifies two generation modes (by tag or by single endpoint), distinguishing it from sibling tools that list or fetch endpoint details.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides clear usage context: generate code for an entire module via tag or a single API via path. It implicitly frames itself as the code-generation tool among siblings, though it does not explicitly mention when to use alternatives like get_endpoint_detail.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_endpoint_detailA
获取单个API接口的详细信息,包括参数和响应定义。会根据path自动推断对应的服务(如/api/village/...会使用village服务)。
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | API接口路径,如 "/api/village/VillageNursing/GetPageList" | |
| method | Yes | HTTP方法,如 "get", "post", "put", "delete" | |
| swagger_url | No | Swagger JSON文档的URL(可选,会根据path自动推断服务) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The description discloses a useful behavioral trait: it automatically infers the corresponding service from the path, with an example. It also states what the response includes (parameters and responses). With no annotations provided, the description carries the burden and adequately signals a read-only 'get' operation without explicit side effects.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is two sentences long, with the first clearly stating the primary purpose and the second adding an essential behavioral detail. No redundant or excessive information is present.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's low complexity and the absence of output schema/annotations, the description covers the essential aspects: what it does, what it returns, and service selection logic. Minor gaps like error behavior are acceptable for this type of retrieval tool.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the baseline per guidelines is 3. The description adds no new parameter meanings beyond the schema, and the auto-inference behavior is already mentioned in the swagger_url parameter description.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states it retrieves detailed information for a single API endpoint, including parameter and response definitions. This distinguishes it from sibling tools like list_endpoints and generate_api_code, which serve listing and code generation purposes respectively.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The intended use case is clear: to fetch details for a specific endpoint identified by path and method. It does not explicitly name alternatives but the context inherently implies this tool is for single-endpoint detail lookup versus listing endpoints or services.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_endpointsA
列出指定tag下的所有API接口。每次调用都会获取最新的Swagger文档。
| Name | Required | Description | Default |
|---|---|---|---|
| tag | Yes | API分组的tag名称,如 "VillageNursing" | |
| swagger_url | No | Swagger JSON文档的URL(可选,默认使用预设URL) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the burden of disclosing behavioral traits. It adds one useful trait: 'Each call fetches the latest Swagger document,' which indicates freshness and potential network dependency. However, it does not mention read-only safety, error behavior, or output format, leaving some transparency gaps.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is two concise sentences, front-loaded with the core purpose. No unnecessary information or repetition, making it highly efficient.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The tool is simple (2 parameters, no output schema). The description states the purpose and adds a key behavioral note about fetching live Swagger docs. While it doesn't describe return types or error scenarios, these are less critical for a listing tool, making it sufficiently complete for its complexity.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100% for both parameters (tag and swagger_url). The description does not add extra semantic meaning beyond the schema, so the baseline of 3 applies.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's function: 'List all API endpoints under the specified tag.' The verb 'list' and resource 'API endpoints' are specific, and the tag scoping distinguishes it from sibling tools like list_tags (lists tags) and get_endpoint_detail (gets details for one endpoint).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage by mentioning 'specified tag' but does not explicitly tell when to use this tool over alternatives or mention prerequisites (e.g., first call list_tags to get a valid tag). Sibling tool names provide context, but the description itself lacks explicit guidance or exclusions.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_servicesA
列出所有可用的API服务及其Swagger URL。用于了解有哪些服务可用。
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden. It discloses the action (listing) and the output (Swagger URLs), but does not mention potential side effects, permissions, or other behavioral details. Adequate but minimal.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is two concise sentences. It states the action and the purpose without any filler, making it easy to parse.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool has no parameters, no output schema, and is a simple listing operation, the description fully covers what the tool does and why to use it. No further context is needed.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
There are zero parameters, so schema coverage is trivially 100%. The description does not need to add parameter details, and the baseline for 0-param tools is 4.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states 'List all available API services and their Swagger URLs,' which is a specific verb+resource combination. It clearly distinguishes itself from sibling tools like list_tags and list_endpoints by focusing on services and Swagger URLs.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description adds 'used to understand what services are available,' providing clear usage context. It does not explicitly mention when not to use it or name alternatives, but the intent is clear.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_tagsA
列出Swagger文档中所有的API分组(tags)。每次调用都会获取最新的Swagger文档。
| Name | Required | Description | Default |
|---|---|---|---|
| swagger_url | No | Swagger JSON文档的URL(可选,默认使用预设URL) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden. It discloses '每次调用都会获取最新的Swagger文档' (always fetches the latest document), which is useful. However, it does not mention other behaviors like error handling or response format, so it is adequate but not rich.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is two short, front-loaded sentences with no redundant information. It efficiently conveys the core purpose and a key behavioral note.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple listing tool with one optional parameter and no output schema, the description adequately covers the purpose and a relevant behavior. It could mention the output structure, but the tool name and description sufficiently imply what is returned.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100% for the single optional parameter swagger_url, so the schema provides full parameter meaning. The tool description adds no parameter-specific info beyond what the schema already states, hence the baseline score.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool lists all API groups (tags) from Swagger documentation, using the verb '列出' and resource 'API分组'. This distinguishes it from sibling tools like list_endpoints and list_services.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage when tags are needed and notes that each call fetches the latest Swagger doc, providing some context. However, it does not explicitly mention alternatives or when not to use this tool, leaving the guidance somewhat implicit.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
5 tool updates
v1.0.0- First observed
generate_api_code - First observed
get_endpoint_detail - First observed
list_endpoints - First observed
list_services - First observed
list_tags
TDQS
Each tool has a clear, distinct purpose: list_tags for API groups, list_endpoints for endpoints in a tag, list_services for available services, get_endpoint_detail for endpoint details, and generate_api_code for code generation. No two tools overlap in function, and the descriptions make their boundaries explicit.
All tool names follow a consistent verb_noun pattern with lowercase and underscores: list_tags, list_endpoints, list_services, get_endpoint_detail, generate_api_code. This makes the toolset predictable and easy to navigate.
With 5 tools, the server is well-scoped for its purpose of exploring Swagger/OpenAPI definitions and generating TypeScript code. Each tool covers a necessary step in the workflow, and there is no excess or deficiency.
The toolset covers the full lifecycle of API discovery and code generation: listing services, inspecting tags and endpoints, fetching details, and generating code. The inference of services from paths in get_endpoint_detail and generate_api_code fills potential gaps, and there are no obvious missing operations.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
- typeshipOAuthdev.typeship
Generate a typed SDK, CLI, and MCP server from any OpenAPI or GraphQL spec, and keep them current.
Kickstart development with a customizable TypeScript template featuring sample tools for greeting,…
327 dev tools via REST API and MCP. Generate Dockerfiles, schemas, K8s, APIs, and more.
Ship production-ready TypeScript code in half the time, at half the cost.
Related MCP Servers
- AlicenseBqualityDmaintenanceA server based on Model Context Protocol that parses Swagger/OpenAPI documents and generates TypeScript types and API client code for different frameworks (Axios, Fetch, React Query).121616ISC
- AlicenseNot gradedqualityFmaintenanceEnables AI to interact with multiple Swagger/OpenAPI specifications by listing endpoints, exploring models, and generating TypeScript code. It centralizes the management of various APIs through a configuration file, allowing for seamless integration of documentation into AI workflows.214MIT
- FlicenseAqualityDmaintenanceEnables reading and parsing Swagger/OpenAPI specifications to list API endpoints, get detailed endpoint info, search APIs, and generate TypeScript types for request/response.9-
- FlicenseNot gradedqualityDmaintenanceEnables AI to scan and query local OpenAPI/Swagger documentation, listing API groups and endpoints, and generating TypeScript type definitions for specific endpoints.-
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/aehyok/swagger-codegen-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server