Any API MCP Server
Dynamically converts any API with an OpenAPI v3 specification into MCP tools for AI assistants. It supports multiple authentication methods including OAuth2, Bearer tokens, and API keys for flexible integration.
README
ANY API MCP Server
An MCP (Model Context Protocol) server designed to interact with any API that exposes an OpenAPI v3 specification. The server dynamically parses the OpenAPI spec and exposes the API endpoints as tools usable by AI assistants.
Features
- Compatible with any API: Just provide your API's OpenAPI spec file.
- Multiple authentication methods: Supports the most common auth systems.
- Flexible configuration: Via JSON file or environment variables.
- Dynamic tool generation: Automatically converts endpoints into MCP tools.
Architecture
The project is built using the following technologies and patterns:
- Node.js & TypeScript: The runtime environment and base language.
- Model Context Protocol (MCP) SDK: Uses
@modelcontextprotocol/sdkto implement the MCP server overstdio. - Modular Authentication System: Adapter-based architecture supporting multiple authentication types.
- Dynamic Tool Generation: Reads the OpenAPI file and converts each operation into an MCP Tool.
Prerequisites
- Node.js (v16 or higher)
- The API to expose must be network accessible.
- Your API's OpenAPI spec file (JSON or YAML).
Installation and Build
-
Install dependencies:
npm install -
Compile the TypeScript code:
npm run build
Configuration
Configuration can be done in two ways:
Option 1: Configuration file (Recommended)
Create a config.json file in the project root:
{
"apiUrl": "https://api.example.com",
"openApiSpecPath": "./open-api.json",
"serverName": "my-api-mcp",
"serverVersion": "1.0.0",
"auth": {
"type": "bearer-endpoint",
"endpoint": "/auth/token",
"method": "POST",
"body": {
"key": "${API_KEY}",
"secret": "${API_SECRET}"
},
"tokenPath": "token"
}
}
See
config.example.jsonfor more configuration examples.
Option 2: Environment variables
Create a .env file in the project root:
API_URL=http://localhost:8080/api
AUTH_TYPE=bearer-endpoint
AUTH_ENDPOINT=/auth/token
AUTH_TOKEN_PATH=token
API_KEY=your_api_key
API_SECRET=your_api_secret
Supported Authentication Types
1. No Authentication (none)
{
"auth": {
"type": "none"
}
}
2. HTTP Basic Auth (basic)
{
"auth": {
"type": "basic",
"username": "myuser",
"password": "mypassword"
}
}
3. API Key (api-key)
Supports sending via header, query param, or cookie:
{
"auth": {
"type": "api-key",
"keyName": "X-API-Key",
"keyValue": "your-api-key",
"location": "header",
"prefix": ""
}
}
4. Static Bearer Token (bearer-token)
For tokens that don't expire or are managed externally:
{
"auth": {
"type": "bearer-token",
"token": "your-static-bearer-token"
}
}
5. Bearer Token from Endpoint (bearer-endpoint)
Obtains the token from an authentication endpoint:
{
"auth": {
"type": "bearer-endpoint",
"endpoint": "/auth/token",
"method": "POST",
"body": {
"key": "${API_KEY}",
"secret": "${API_SECRET}"
},
"tokenPath": "token",
"expiresIn": 3600
}
}
Note: Use
${VAR_NAME}to reference environment variables in the body.
6. OAuth2 Client Credentials (oauth2-client-credentials)
{
"auth": {
"type": "oauth2-client-credentials",
"tokenUrl": "https://auth.example.com/oauth/token",
"clientId": "your-client-id",
"clientSecret": "your-client-secret",
"scopes": ["read", "write"],
"credentialsInBody": false
}
}
Environment Variables
| Variable | Description |
|---|---|
CONFIG_PATH |
Path to configuration file |
API_URL |
API base URL |
OPENAPI_SPEC_PATH |
Path to OpenAPI spec file |
SERVER_NAME |
MCP server name |
AUTH_TYPE |
Authentication type |
API_KEY |
API Key (for bearer-endpoint) |
API_SECRET |
API Secret (for bearer-endpoint) |
Usage in MCP Clients
To use this server in tools like Claude Desktop or VS Code extensions that support MCP:
{
"mcpServers": {
"any-api": {
"command": "node",
"args": ["/absolute/path/to/any-api-mcp/build/index.js"]
}
}
}
Make sure to replace /absolute/path/to/any-api-mcp/ with the actual path where you cloned this repository.
Extending the Authentication System
To add a new authentication type:
- Create a new adapter in
src/auth/adapters/that extendsBaseAuthAdapter - Add the new type to
AuthTypeinsrc/auth/types.ts - Create the corresponding configuration interface
- Register the adapter in
AuthFactory.createAdapter()insrc/auth/factory.ts
Development
To make changes to the server:
- Modify the code in
src/. - Recompile with
npm run build. - Restart your MCP client to reload the changes.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。