Skip to main content
Glama
The-Swarm-Corporation

openapi-to-mcp

MCP Scribe

将任意 OpenAPI schema 转换为生产级 MCP 服务器。

PyPI Python License

Swarms GitHub Swarms website Discord Twitter


Related MCP server: Any API MCP Server

概述

将 MCP Scribe 指向一个 OpenAPI schema。即可获得一个 MCP 服务器。

spec 中的每个操作都会成为一个模型可调用的工具,JSON Schema、凭据、重试、速率限制和响应整形都已处理妥当。无需维护生成的代码,也不用保持适配层同步——spec 就是事实来源,服务器在启动时从中派生而出。

MCP Scribe 专为将真实 API 置于语言模型之前的团队而设计,在这些场景中,真正重要的故障模式是凭据泄露、对可计费端点的失控重试,以及因工具面过大而让模型无法导航的问题。


安装

pip install mcp-scribe

从源码安装,作为全局 CLI:

git clone https://github.com/kyegomez/mcp-scribe && cd mcp-scribe
uv tool install --editable ".[http]"

http 附加依赖会安装 uvicornstarlette,仅 HTTP 传输需要它们。stdio 服务器两者都不需要。

要求: Python 3.10 – 3.13。


快速开始

部署一个共享服务器

一条命令。输入 spec,服务器即刻就绪。

mcp-scribe deploy https://api.swarms.world/openapi.json --port 8000

调用该服务器

import asyncio
import os
import sys

from dotenv import load_dotenv
from mcp import ClientSession
from mcp.client.streamable_http import streamable_http_client
from mcp.shared._httpx_utils import create_mcp_http_client

load_dotenv()

# Streamable HTTP path defaults to /mcp (see transport.path).
MCP_URL = "http://127.0.0.1:8000/mcp"


async def main() -> None:
    api_key = os.environ.get("SWARMS_API_KEY")
    if not api_key:
        sys.exit(
            "set SWARMS_API_KEY first: export SWARMS_API_KEY=sk-..."
        )

    http = create_mcp_http_client(headers={"x-api-key": api_key})
    async with http, streamable_http_client(
        MCP_URL, http_client=http
    ) as (read, write), ClientSession(read, write) as session:
        await session.initialize()
        result = await session.call_tool(
            "get_available_models_v1_models_available_get",
            {},
        )
        print(result.content[0].text)


if __name__ == "__main__":
    asyncio.run(main())

CLI 命令

Usage: mcp-scribe [OPTIONS] COMMAND [ARGS]...

Turn any OpenAPI schema URL into a production-grade MCP server.

Options:
  --help          Show this message and exit.

Commands:
  serve     Run the MCP server.
  deploy    Serve over HTTP with production defaults. The short path to a shared server.
  inspect   Show the tools a spec produces — the fastest way to validate a setup.
  call      Invoke one tool from the terminal — the same code path the server uses.
  generate  Write a self-contained, deployable MCP server project for a spec.
  install   Build the server and register it with your MCP client in one step.
  version   Print the version.

关键能力

能力

提供的价值

通用 spec 导入

支持从 URL、文件或 stdin 读取 OpenAPI 3.1、3.0 和 Swagger 2.0——JSON 或 YAML 格式。Swagger 2.0 会提前转换;外部和递归的 $ref 会被预取并解析。

零代码工具生成

每个操作对应一个 MCP 工具,以 JSON Schema 2020-12 格式输出,支持完整的 style/explode 矩阵、递归模型的 $defs,并自动进行请求体展平以提高工具调用准确性。

凭据隔离

spec 中声明的凭据参数会从工具 schema 中剥离,并在请求时注入。模型永远不会被要求生成其并不持有的密钥。

企业级身份验证

API 密钥(header、query、cookie)、Bearer、HTTP Basic、带自动刷新的 OAuth2 client credentials,以及任意静态 header——可组合,每次请求都会应用。

多租户隔离

按调用方进行凭据透传,支持 header 白名单和 fail-closed 强制,因此一台共享服务器不意味着共享身份或共享账单。

默认高韧性

全抖动指数退避并遵循 Retry-After、每主机熔断器、令牌桶、并发上限,以及每次工具调用的墙钟预算。

默认安全的重试

POST 和 PATCH 在未明确启用时绝不重试。重发可计费请求被视为比失败更糟。

攻击面控制

按标签、路径正则、方法或 operationId 过滤;--read-only 用一个 flag 即可将服务器限制为仅 GET/HEAD/OPTIONS。

上下文治理

响应会按可配置的预算截断,并附提示信息告知模型如何缩小请求范围。

双传输

stdio 适用于个人、按用户划分的服务器;流式 HTTP 带 /health 探活和无状态会话,适用于共享、水平扩展的部署。

密钥卫生

支持 .env 文件、MCP_SCRIBE_* 环境变量以及配置中的 ${VAR} 插值。密钥在内存中为 SecretStr,在输出中会被脱敏。

运维工具

inspect 无需启动任何进程即可验证配置;call --dry-run 可查看准确的出站请求;结构化 JSON 日志;以及热加载 spec 更新。

可部署产物

generate 生成一个自带项目,包含 Dockerfile、固定版本的依赖、配置和离线启动所需的备份 spec。


文档

文档

内容

docs/DOCS.md

完整用户指南——心智模型、传输方式、凭据、多租户、过滤、schema 整形、可靠性、调试、部署和故障排查。

docs/REFERENCE.md

详尽参考——每个 CLI 命令和 flag、每个配置键及类型和默认值、完整的环境变量表、Python API 和异常层级。

CLAUDE.md

贡献者和 agent 指南——命令、逐模块架构、承重不变量、约定和常见坑。

MCP_SCRIBE_SKILL.md

Agent 技能定义——自主 agent 应如何选择命令、验证配置以及处理凭据。


许可证

Apache-2.0。详见 LICENSE


引用

@misc{mcpscribe2026,
    title   = {mcp-scribe: production-grade MCP servers from OpenAPI schemas},
    author  = {Gomez, Kye},
    year    = {2026},
    url     = {https://github.com/kyegomez/mcp-scribe}
}
@misc{mcp2024,
    title   = {Model Context Protocol},
    author  = {Anthropic},
    year    = {2024},
    url     = {https://modelcontextprotocol.io}
}
A
license - permissive license
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

View all related MCP servers

Related MCP Connectors

  • Point Gecko at an OpenAPI spec; get first-call-correct, auth-hidden agent tools.

  • Free public MCP for AI agents — 193 tools, 44 workflows. No API key.

  • Generate a typed SDK, CLI, and MCP server from any OpenAPI or GraphQL spec, and keep them current.

View all MCP Connectors

Latest Blog Posts

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/The-Swarm-Corporation/mcp-scribe'

If you have feedback or need assistance with the MCP directory API, please join our Discord server