Any-API MCP Server
A configurable MCP server that adapts any HTTP API into an MCP toolset with generic HTTP tools (GET, POST, PUT, DELETE) and pluggable authentication. Includes API discovery scripts and supports dynamic tool generation from OpenAPI specs or wordlist scans.
README
Any-API MCP Server Template
A minimal, configurable Model Context Protocol (MCP) server you can use to adapt any HTTP API into an MCP toolset. It focuses on safety, clarity, and fast onboarding.
What You Get
- Generic HTTP tools:
api_probe,api_get,api_post,api_put,api_delete - Pluggable auth (header, bearer, basic, query param)
- Safe defaults: retries for GET only, rate-limit awareness (Retry-After), STDERR logging with redaction
- Zero-boilerplate startup via STDIO (MCP)
- TypeScript, strict mode, ESM
Quick Start
- Create a new repo and copy this template directory:
- Repo name suggestion:
mcp-any-api - Copy
templates/any-api-mcp/*into the new repo root
- Install and build
npm ci
npm run build
- Configure environment (two simple options)
Option A — API key/token you already have:
Create
.env.local(auto-loaded by scripts) with your API details:
API_BASE=https://api.example.com/v1
AUTH_MODE=bearer # one of: none|bearer|header|basic|query
AUTH_TOKEN=YOUR_TOKEN # bearer token or header value depending on mode
AUTH_HEADER=Authorization # used if AUTH_MODE=header (default Authorization)
AUTH_QUERY_KEY=api_key # used if AUTH_MODE=query
ALLOW_DESTRUCTIVE=false # guard writes
Option B — OAuth 2.0 (automated helpers):
Client Credentials (service-to-service):
TOKEN_URL=https://auth.example.com/oauth/token \
CLIENT_ID=... CLIENT_SECRET=... SCOPE="api.read api.write" \
npm run oauth2:client
This writes AUTH_MODE/AUTH_TOKEN into .env.local.
Device Code (user sign-in on a second device):
DEVICE_AUTH_URL=https://auth.example.com/oauth/device/code \
TOKEN_URL=https://auth.example.com/oauth/token \
CLIENT_ID=... SCOPE="api.read" \
npm run oauth2:device
Follow the printed verification URL and code. Upon success, the script updates .env.local.
4) Run in dev
```bash
npm run dev
- Add to your MCP client (example Claude Desktop)
{
"mcpServers": {
"any-api": {
"command": "node",
"args": ["/absolute/path/to/dist/server.js"],
"env": {
"API_BASE": "https://api.example.com/v1",
"AUTH_MODE": "bearer",
"AUTH_TOKEN": "YOUR_TOKEN",
"ALLOW_DESTRUCTIVE": "false"
}
}
}
}
Tools
api_probe(safe):- Inputs:
path(string),method(string), optionalheaders(record) - Executes a single request and returns status, content-type, body preview (first N bytes)
- Inputs:
api_get(safe):- Inputs:
path, optionalquery(record), optionalheaders - Retries on
429/502/503/504with backoff; honorsRetry-After
- Inputs:
api_post(guarded),api_put(guarded),api_delete(guarded):- Inputs:
path, optionalpayload(any), optionalheaders - DELETE supports optional payload if API expects a body
- Inputs:
All tools auto-join API_BASE with path and attach auth based on AUTH_MODE.
Auth Modes
none: no auth headerbearer:Authorization: Bearer <AUTH_TOKEN>header:<AUTH_HEADER>: <AUTH_TOKEN>basic:Authorization: Basic <AUTH_TOKEN>(you provide base64)query: appends?<AUTH_QUERY_KEY>=<AUTH_TOKEN>(or&when query exists)
Rate Limiting
- GETs retry on
429/502/503/504using exponential backoff with jitter Retry-Afterheader is honored when present- Scripts accept
PROBE_DELAY_MSto pace probes
Examples
Probe a path safely:
{
"path": "/users",
"method": "OPTIONS"
}
GET with query:
{
"path": "/search",
"query": { "q": "widgets", "page": 2 }
}
POST (guarded):
{
"path": "/widgets",
"payload": { "name": "Example", "price": 100 }
}
Customizing
- Add typed, domain-specific tools by creating new handlers in
src/server.ts - Keep
ALLOW_DESTRUCTIVE=falseuntil you’re ready to allow writes - To support OAuth2 flows, fetch tokens outside the server and set
AUTH_MODE=bearerwithAUTH_TOKEN
Scripts
npm run validate:endpoints(safe): probes a set of paths/methods via GET/OPTIONS; pacing + Retry-After; dynamic delay adaptationnpm run probe:get(safe): throttled GET probe for a given listnpm run discover:openapi(safe): tries common OpenAPI/Swagger URLs, lists endpoints/methods, and saves raw specnpm run scan:wordlist(safe): OPTIONS-scan using a small default wordlist or a provided file; dynamic delay adaptationnpm run inventory:api(safe): one-command inventory; tries OpenAPI first, then wordlist; writes JSON toreports/npm run openapi:to:tools(safe): converts an OpenAPI JSON file totools.jsonfor dynamic tool registrationnpm run scan:to:tools(safe): converts a wordlist scan report totools.jsonnpm run oauth2:client/npm run oauth2:device: obtain OAuth tokens and update.env.local
Environment knobs:
PROBE_DELAY_MS: pacing between requests (default 800–1500ms)OUTPUT/OUTPUT_DIR: where to save reportsWORDLIST: path to a custom wordlist (forscan:wordlist)
All scripts auto-load .env.local.
Dynamic Tools (No Code Changes)
This server auto-registers tools from tools.json (if present in the working directory). You can generate tools.json from discovery output:
From OpenAPI:
OPENAPI_FILE=reports/openapi_*.json TOOLS_FILE=tools.json npm run openapi:to:tools
From wordlist scan:
SCAN_FILE=reports/wordlist_*.json TOOLS_FILE=tools.json npm run scan:to:tools
Once tools.json exists, restart the server and the generated tools are available automatically. GET tools are safe; mutating tools are guarded (require ALLOW_DESTRUCTIVE=true).
Example: Hexnode API
Use the provided example tools file and Hexnode credentials:
- Copy example to working tools file
cp templates/any-api-mcp/examples/hexnode.tools.json tools.json
- Configure Hexnode env in
.env.local(header auth)
API_BASE=https://<portal>.hexnodemdm.com/api/v1
AUTH_MODE=header
AUTH_HEADER=Authorization
AUTH_TOKEN=<your-hexnode-api-key>
ALLOW_DESTRUCTIVE=false
- Start the server
npm run build && npm start
Note: Some Hexnode tenants use singular policy paths (/policy/…) and others plural (/policies/…). The example includes both; use whichever works for your tenant or remove non-applicable entries from tools.json.
File Layout
src/server.ts: MCP entrypointsrc/lib/*.ts: helpers (qs, retry, logger)scripts/*: verification probesdist/*: compiled output
License
Add your preferred license before public release.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。