WebAPI MCP 服务器

WebAPI MCP 服务器

webapi-mcp-server•byyinzhouzhi

一个将传统 Web API 转换为 MCP 工具的服务器,支持批量注册 API、管理全局请求头并从文件或目录加载 API 定义。

License: Not specified•Runtime: Awaiting documentation review•Category: developer tools

WHAT IT DOES

  • •将任意 Web API 自动转换为可通过 MCP 协议直接调用的 MCP 工具。
  • •支持在运行时动态注册和移除 API,并列出已注册的 API。
  • •集中管理所有 API 请求的默认请求头。
  • •可从指定文件、目录或配置文件批量加载 API 定义。

BEST FOR

  • •为已存在的业务系统 Web API 快速接入大模型,而无需开发额外接口。
  • •需要精细控制 API 请求头和数据权限访问的场景。
  • •希望通过 JSON 或 Markdown 文件批量维护 API 定义的开发者。

ABOUT WEBAPI-MCP-SERVER

WebAPI MCP 服务器 is cataloged as an MCP server attributed to yinzhouzhi. 一个将传统 Web API 转换为 MCP 工具的服务器,支持批量注册 API、管理全局请求头并从文件或目录加载 API 定义。 It is categorized under developer tools. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: Not specified. Check the source repository's current license and terms before using, modifying or distributing this software.

能力检查器

能力定义尚未审核。未核验的采集内容不会作为可信接口展示。

Tools (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Resources (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Prompts (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for WebAPI MCP 服务器 are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

支持哪些格式的 API 定义?

支持 JSON 和 Markdown 两种格式定义 API,也可从文件目录批量导入。

如何从嵌套响应中提取特定数据?

通过 resultPath 字段使用点表示法从响应中提取结果,例如 data.items。

上游原版 README

在 GitHub 查看同一版本原文

README.md · 91a84ac765f7 · 采集于 2026-11-13 10:32:19 UTC

保留上游原文,不做 AI 改写。为安全起见过滤脚本、表单和不安全链接。

当前显示最后一次成功采集的文档快照,请以来源页面为准。

WebAPI MCP 服务器

将传统Web API转换为MCP工具的服务器,支持API接口批量注册,通过MCP工具设置默认请求头。

优势: 1.比传统的RAG模式更简单,部署起来更方便,并且可以实现传统业务系统和大模型的直接对接,无需开发额外接口增加冗余代码和工作量 2.支持json文件或者md文件格式或者文件目录批量导入 3.相较于RAG通过向量库进行数据切片,检索的数据,直接通过模型调用API获取数据可以更精准更可靠 4.数据安全,通过设置转换的mcp工具的请求头参数可以做到更精准的数据权限管理和控制

原文链接:https://blog.csdn.net/qq_39336120/article/details/147537618

功能特点

  • API转换 - 将任何Web API自动转换为MCP工具
  • 动态注册 - 运行时动态注册和移除API
  • 全局请求头 - 集中管理所有API的默认请求头
  • 灵活参数 - 支持多种参数类型和验证
  • 结果路径 - 支持从嵌套响应中提取特定数据
  • 批量加载 - 支持从文件或目录批量加载API定义

Cursor或者其他MCP客户端引入方式

{
  "mcpServers": {

    "webapi-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "@yinzhouzhi/webapi-mcp-server",
        "start"
      ]
    }
  }
}

安装

# 克隆项目
git clone <repository-url>
cd webapi-mcp-server

# 安装依赖
npm install

# 初始化项目目录
npm run setup

使用方法

启动服务器

npm start

# 使用自定义配置启动
npm start -- --config path/to/config.json --apis-dir path/to/apis

# 使用环境变量启动
WEBAPI_CONFIG_FILE=path/to/config.json WEBAPI_APIS_DIR=path/to/apis WEBAPI_DEBUG=true npm start

配置文件选项

配置文件支持JSON、YAML和YML格式,可以包含以下选项:

{
  "apiDirectories": [ // 包含API定义文件的目录列表
    "./apis", 
    "./more-apis"
  ],
  "apiFiles": [ // 单独API定义文件的路径列表
    "./specific-api.json",
    "./another-api.md"
  ],
  "globalHeaders": { // 应用于所有API请求的默认请求头
    "User-Agent": "WebAPI MCP Client/1.0", // 用户代理  
    "Accept": "application/json", // 接受的内容类型
    "Authorization": "Bearer YOUR_TOKEN" // 授权令牌
  },
  "debug": true // 是否启用调试模式
}
配置项类型描述
apiDirectories数组包含API定义文件的目录列表
apiFiles数组单独API定义文件的路径列表
globalHeaders对象应用于所有API请求的默认请求头
debug布尔值是否启用调试模式

运行示例

npm run run-example

通过CLI工具使用

# 启动服务器
npm run start

# 显示示例
npm run example

环境变量配置

服务器也可以通过环境变量进行配置:

环境变量描述
WEBAPI_CONFIG_FILE配置文件的路径
WEBAPI_APIS_DIRAPI定义目录的路径
WEBAPI_DEBUG启用调试模式(设置为 'true')

MCP工具

服务器内置了以下MCP工具:

工具名称描述
register_web_api将Web API注册为MCP工具,使其可以通过MCP协议直接调用。
set_default_headers设置适用于所有API请求的全局默认请求头。
list_registered_apis列出当前已注册的所有Web API及其配置。
unregister_api移除已注册的Web API工具。
load_api_from_file从指定文件加载API定义并注册为MCP工具。
load_apis_from_directory从指定目录加载所有API定义文件并注册为MCP工具。
load_from_config从配置文件加载API定义和设置。

API定义格式

可以使用JSON或Markdown格式定义API:

JSON格式

{
  "name": "weather",
  "description": "获取当前天气信息",
  "url": "https://api.example.com/weather",
  "method": "GET",
  "parameters": {
    "city": {
      "type": "string",
      "required": true, // 是否必填
      "description": "城市名称"
    },
    "units": {
      "type": "string",
      "required": false,
      "description": "温度单位 (celsius, fahrenheit)"
    }
  },
  "headers": {
    "X-API-Key": "your-api-key"
  },
  "resultPath": "data.current"
}

JSON格式字段说明

字段类型必填描述
name字符串是API工具的唯一名称,用于MCP调用
description字符串是API功能的简要描述
url字符串是API的完整URL地址,支持带参数的URL模板
method字符串是HTTP请求方法(GET, POST, PUT, DELETE等)
parameters对象否API参数定义,每个参数包含type, required和description属性
headers对象否特定于此API的请求头(会与全局请求头合并)
resultPath字符串否从响应中提取结果的路径,使用点表示法(如"data.items")
bodyTemplate对象/字符串否POST/PUT请求的请求体模板
responseType字符串否期望的响应类型(json, text, blob等)
transform字符串否用于转换响应的JavaScript代码字符串

Markdown格式

# Weather API

获取当前天气信息

## URL
https://api.example.com/weather

## 方法
GET

## 参数
- city (string, required): 城市名称
- units (string, optional): 温度单位 (celsius, fahrenheit)

## 请求头
- X-API-Key: your-api-key

## 结果路径
data.current

Markdown格式规范

Markdown格式的API定义需遵循以下结构:

  1. 一级标题(#): API的名称,将用作MCP工具名称
  2. 描述: 标题下的文本作为API描述
  3. URL部分: 以## URL开头,下一行为API的完整URL
  4. 方法部分: 以## 方法开头,下一行为HTTP方法(GET, POST等)
  5. 参数部分(可选): 以## 参数开头,每个参数使用列表项格式
    • 格式: 参数名 (类型, required/optional): 描述
  6. 请求头部分(可选): 以## 请求头开头,每个请求头使用列表项格式
    • 格式: 请求头名: 值
  7. 结果路径部分(可选): 以## 结果路径开头,下一行为提取结果的路径
  8. 请求体模板(可选): 以## 请求体开头,后面是JSON格式的请求体模板
  9. 响应类型(可选): 以## 响应类型开头,指定期望的响应类型
  10. 转换函数(可选): 以## 转换函数开头,包含JavaScript转换代码

详细文档

示例

查看API示例了解如何:

  1. 设置全局默认请求头
  2. 注册Web API
  3. 列出已注册的API
  4. 调用注册的API
  5. 移除API

导出的API

const webapi = require('webapi-mcp-server');

// 创建自定义服务器
const server = webapi.createServer({
  debug: true,
  configFile: './config.json',
  apisDir: './apis'
});

// 使用其他导出函数
webapi.registerApi(apiDefinition);
webapi.unregisterApi('apiName');
webapi.getRegisteredApis();
webapi.loadApiFile('./path/to/api.json');
webapi.loadApisFromDirectory('./apis');

许可证

MIT

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for WebAPI MCP 服务器 from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/webapi-mcp-server)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

下载与拉取统计

来源、范围和时段分别列出;不相加,不代表安装人数、活跃用户或安全审核。

尚无已审核的包 / 镜像标识,暂不展示下载统计。

Related developer tools MCP Servers

Alternative and complementary servers in the same category

View all in developer tools →
Postbye
postbye-mcp•postbye-team

A directory listing describing a cancellation-letter and mailing-address service. The configured public GitHub repository returned 404 during source verification.

Repository stats unavailable
Developer Tools
Singapore Proxy MCP
singapore-proxy-mcp•Xavierfok

A hosted MCP service for browsing and searching through Singapore mobile-network proxies.

0
Developer Tools

A directory listing describing a Markdown-to-PDF service. The configured public GitHub repository returned 404 during source verification.

Repository stats unavailable
Developer Tools