OpenAPI Services

io.github.alyiox由 GitHub 账号 alyiox 发布v0.2.1更新于 Oct 24, 2026

MCP server that fronts any OpenAPI service: discover operations from its spec and call them

概览

AI 生成的概览

一个本地 MCP 服务器,可对接任意 OpenAPI 服务:从规范中发现操作,并让助手通过统一的代理调用它们。

可以做什么
列出已配置的平台、区域、服务与环境,并显示加载失败项的错误。按查询词、标签或方法筛选浏览某个服务的操作。查看单个操作及其引用模式的传递闭包。执行操作,或调用规范中不存在的原始方法与路径。以 MCP 资源读取被截断响应的完整内容和等效的 curl 命令。
适用场景
当助手需要对接一个或多个有 OpenAPI 文档的后端时适用,尤其是同一 API 的多个部署环境,无需为每个服务单独安装 MCP 服务器。也适合在调用前先浏览 API 的操作与模式。
运行要求
以 stdio 在本地运行,需要 Python 3.13+ 和 uv(例如通过 uvx)。需要在 ~/.config/mcp-openapix/config.json 提供配置文件,描述平台、区域、服务与环境,以及每个服务的规范路径和基础 URL。需要网络访问以获取规范并调用 API。可选的令牌助手是配置中指定的外部命令。
安装前请注意
配置文件本身不含密钥,但令牌助手会作为本地命令运行并可能签发凭据。令牌会缓存到缓存目录下的磁盘中,生成的 curl 命令可能包含短期令牌。call_endpoint 会发起真实 API 请求,包括写入、发送和删除,并可调用规范中不存在的原始路径。规范通过未认证的 GET 请求获取。

安装

在 SourceWeft 中

  1. 打开 控制台中的 OpenAPI Services,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

mcp-openapix

[CI] [PyPI] [Python 3.13+] [License: MIT]

MCP server that fronts any OpenAPI service behind four generic tools.

An agent finds operations in each deployment's OpenAPI document and calls them; the server resolves the URL, obtains a bearer token, and builds the request. Discovery is list_platforms, list_endpoints and describe_endpoint; execution is the generic proxy call_endpoint.

example / us / items / prod  │     │     │      └── env ......... which deployment URL a call reaches  │     │     └───────── service ..... one backend, one OpenAPI spec  │     └─────────────── region ...... a geographic deployment  └───────────────────── platform .... the product or API family

Requirements

  • Python 3.13+ and uv
  • A config.json describing the deployments you hold credentials for

Quick start

Set up your config (see Configuration), then run the server:

bash
# Run directly with uvx (no clone needed)npx -y @modelcontextprotocol/inspector@latest uvx mcp-openapix
bash
# Or run from sourcenpx -y @modelcontextprotocol/inspector@latest uv run mcp-openapix

Configuration

config.json MUST live at ~/.config/mcp-openapix/config.json (%USERPROFILE%\.config\… on Windows). config.example.json is a full template.

json
{  "headers": { "accept": "application/json" },  "defaults": { "platform": "example", "region": "us", "service": "items", "env": "prod" },  "platforms": {    "example": {      "regions": {        "us": {          "services": {            "token_helper": "us",            "items": {              "desc": "Catalogue and inventory API",              "spec_path": "/swagger/v1/swagger.json",              "canonical_env": "prod",              "envs": {                "prod": { "url": "https://api.example.com/items" },                "dev":  { "url": "https://api-dev.example.com/items" }              }            }          }        }      }    }  },  "token_helpers": {    "us": {      "command": "token-helper",      "args": ["issue"]    }  }}

platforms

A hierarchy of platform → region → services → service → env. Each service declares:

FieldNotes
spec_pathRequired. The OpenAPI JSON endpoint relative to the service URL
canonical_envRequired when more than one env is configured — the env whose URL the spec is fetched from
envsRequired. One entry per deployment environment, each carrying a full base url
descOptional. A short description surfaced by list_platforms
token_helperOptional. The token helper this level binds to

The services object may also contain a token_helper default applying to all services in that region. A service or environment can override it.

token_helpers

Named token helpers, in the same shape as an MCP server entry:

FieldRequiredDefaultNotes
commandyes—Resolved on PATH; never run through a shell
argsno[]Passed verbatim
timeoutno60Seconds before the helper's process group is killed; at most 300

The config names a command and nothing else, so config.json holds no secrets. The complete helper invocation and output contract is documented in docs/token-protocol.md.

Which helper a call uses is resolved most-specific-first:

env.token_helper → service.token_helper → services.token_helper→ region.token_helper → platform.token_helper → defaults.token_helper

If no level declares a helper, the deployment is unauthenticated. Omit token_helper for public deployments.

headers

Constant headers added to every API call — for APIs that require a tenant, product or locale header:

json
"headers": { "accept": "application/json", "x-product": "example" }

defaults

Makes every tool argument optional: a call falls back to defaults.platform, .region, .service, .env, .username and .token_helper when they are omitted.

Top-level options

FieldDefaultNotes
truncate_threshold4096Response bytes returned inline before truncating to a preview
response_cache_ttl3600Seconds a truncated body stays readable at its resource URI
spec_refresh{"auto": true, "interval": 7}Background spec refresh; interval is days and MAY be fractional

Splitting the config

A stray comma while editing one platform takes down every platform: a parse failure precedes per-platform validation. The config MAY therefore be split into drop-in files under config.d/, in the style of an nginx conf.d. The recommended layout keeps server-wide settings in config.json and gives each platform its own file, named after it:

~/.config/mcp-openapix/├── config.json      # defaults, headers, token_helpers, top-level options└── config.d/    ├── acme.json    # {"platforms": {"acme": …}}    └── public.json  # {"platforms": {"public": …}}

A typo then costs one platform, and a platform can be handed over, or removed, as a single file. Token helpers stay in config.json because they are usually shared across platforms; a helper only one platform uses MAY live beside it in that platform's file.

The layout is a convention, not a rule:

  • config.json is read first, then every *.json directly in config.d/ in sorted order. Subdirectories, .bak and editor swap files are ignored; no config.d/ means no change in behavior.
  • A drop-in MAY declare anything config.json may, and config.json MAY be nearly empty.
  • Files merge as if pasted into one config in that order: objects merge key by key, and a later scalar or list replaces the earlier one. A later file can therefore override a single envs.prod.url or one defaults field.

A file that fails to parse costs only what it declares; the rest keep working. A malformed platform, in any file, MUST NOT stop the others loading, and neither does a missing token helper it names: its error lists any files that were skipped, since the helper may be declared in one. list_platforms shows a platform that failed with no regions and the loader's error, and a skipped file as {"file", "error"}; calling into a failed platform returns the same message. Defaults that point into a failed platform are ignored. An invalid setting outside platforms still stops the server, and the message names the file that set it.

A fix needs a restart. Check the config first, without starting the server; it also lists every value a later file overrode:

bash
uvx mcp-openapix --check-config

Tools

ToolPurpose
list_platformsEvery platform with its regions, services, and envs
list_endpointsA service's operations, filtered by query, tag or method
describe_endpointOne operation plus the transitive closure of the schemas it references
call_endpointExecute an operation, or a raw method + path absent from the spec

Operation ids

Many OpenAPI documents omit operationId, so the server synthesizes one as "<METHOD> <path>":

POST /api/items└─┬─┘ └───┬───┘method  path as the spec declares it

Where a spec does declare an operationId, that value wins.

Specs

Specs are not bundled. Each deployment's document is fetched on demand — an unauthenticated GET — and cached under ~/.cache/mcp-openapix/{platform}/{region}/{service}.json.

A document MUST declare at least one operation before it is installed, so a deployment answering 200 with an error body cannot replace a working snapshot with one that serves nothing.

Cached specs refresh in the background: once at startup, then every spec_refresh.interval days. Set auto to false to stop it; the manual lever still works:

bash
uvx mcp-openapix --refresh

MCP resources

Resource URIDescription
openapi://responses/{request_id}Full body of a truncated call_endpoint response
openapi://curl/{request_id}Equivalent curl command for a call_endpoint request

Both expire response_cache_ttl seconds after the call. The curl command may embed a short-lived token.

Tokens at rest

Tokens are cached in memory and, when expiry metadata is available, under ~/.cache/mcp-openapix/tokens/ (mode 0600) keyed by the token-helper declaration and username. This lets client sessions share a login without spawning a helper each. A 401 retires the cached token so the next call obtains a fresh one. To clear them all:

bash
uvx mcp-openapix --logout

MCP host examples

Cursor / Claude Code
json
{  "mcpServers": {    "openapi": { "command": "uvx", "args": ["mcp-openapix"] }  }}
Codex
toml
[mcp_servers.openapi]command = "uvx"args = ["mcp-openapix"]

Development

bash
uv sync --extra devuv run ruff check .uv run ruff format --check .uv run pyrightuv run pytest

All four MUST pass; see AGENTS.md. Tests use respx to mock HTTP and real subprocesses for token helpers, so no live API access is required.

License

MIT.

来源:README.md,提交 7f06aab

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

4
  1. v0.2.1最新Sep 30, 2026
  2. v0.2.0Sep 29, 2026
  3. v0.1.1Sep 28, 2026
  4. v0.1.0Sep 21, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分