anyapi-mcp-server

anyapi-mcp-server

A universal MCP server that connects any REST API to AI assistants via OpenAPI or Postman specifications. It enables dynamic tool creation with GraphQL-style field selection and automatic schema inference for efficient data retrieval.

Category
访问服务器

README

anyapi-mcp-server

If it has an API, you can MCP it.

<img src="public/datadog.gif" alt="anyapi-mcp-server demo — Datadog API" width="1200" />

Traditional MCP servers hand-pick a handful of endpoints and call it a day — locking you into whatever subset someone decided was "enough." Why settle for a fraction of an API when you can have all of it?

anyapi-mcp-server is a universal MCP server that connects any REST API to AI assistants like Claude, Cursor, and other LLM-powered tools — just point it at an OpenAPI spec or Postman collection. Every endpoint the API provides becomes available instantly, with GraphQL-style field selection and automatic schema inference. No custom server code, no artificial limits.

Works with services like Datadog, PostHog, Metabase, Cloudflare, Stripe, GitHub, Slack, Twilio, Shopify, HubSpot, and anything else with a REST API — if it has an API, it just works.

Features

  • Works with any REST API — provide an OpenAPI (JSON/YAML) or Postman Collection v2.x spec
  • GraphQL-style queries — select only the fields you need from API responses
  • Automatic schema inference — calls an endpoint once, infers the response schema, then lets you query specific fields
  • Multi-sample merging — samples up to 10 array elements to build richer schemas that capture fields missing from individual items
  • Mutation support — POST/PUT/DELETE/PATCH endpoints with OpenAPI request body schemas get GraphQL mutation types with typed inputs
  • Smart query suggestionscall_api returns ready-to-use GraphQL queries based on the inferred schema
  • Response caching — 30-second TTL cache prevents duplicate HTTP calls across consecutive call_apiquery_api flows
  • Retry with backoff — automatic retries with exponential backoff and jitter for 429/5xx errors, honoring Retry-After headers
  • Multi-format responses — parses JSON, XML, CSV, and plain text responses automatically
  • Built-in pagination — API-level pagination via params; client-side slicing with top-level limit/offset
  • Spec documentation lookupexplain_api returns rich endpoint docs (parameters, response codes, deprecation, request body schema) without making HTTP requests
  • Concurrent batch queriesbatch_query fetches data from up to 10 endpoints in parallel, returning all results in one tool call
  • Per-request headers — override default headers on individual call_api/query_api/batch_query calls
  • Environment variable interpolation — use ${ENV_VAR} in base URLs and headers
  • Request logging — optional NDJSON request/response log with sensitive header masking

npm

Installation

npm install -g anyapi-mcp-server

Required arguments

Flag Description
--name Server name (e.g. petstore)

Either one of

Flag Description
--spec Path to OpenAPI spec file (JSON or YAML) or Postman Collection
--base-url API base URL (e.g. https://api.example.com). Supports ${ENV_VAR} interpolation.

You can provide both --spec and --base-url together. If only --spec is given, the base URL is read from the spec. If only --base-url is given, endpoints are discovered dynamically.

Optional arguments

Flag Description
--header HTTP header as "Key: Value" (repeatable). Supports ${ENV_VAR} interpolation in values.
--log Path to request/response log file (NDJSON format). Sensitive headers are masked automatically.

Example: Cursor / Claude Desktop configuration

Add to your MCP configuration (e.g. ~/.cursor/mcp.json or Claude Desktop config):

Cloudflare API

{
  "mcpServers": {
    "cloudflare": {
      "command": "npx",
      "args": [
        "-y",
        "anyapi-mcp-server",
        "--name", "cloudflare",
        "--spec", "/path/to/cloudflare-openapi.json",
        "--base-url", "https://api.cloudflare.com/client/v4",
        "--header", "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}"
      ],
      "env": {
        "CLOUDFLARE_API_TOKEN": "your-cloudflare-api-token"
      }
    }
  }
}

Datadog API

{
  "mcpServers": {
    "datadog": {
      "command": "npx",
      "args": [
        "-y",
        "anyapi-mcp-server",
        "--name", "datadog",
        "--spec", "/path/to/datadog-openapi.json",
        "--base-url", "https://api.datadoghq.com/api/v1",
        "--header", "DD-API-KEY: ${DD_API_KEY}",
        "--header", "DD-APPLICATION-KEY: ${DD_APP_KEY}"
      ],
      "env": {
        "DD_API_KEY": "your-datadog-api-key",
        "DD_APP_KEY": "your-datadog-app-key"
      }
    }
  }
}

Metabase API

{
  "mcpServers": {
    "metabase": {
      "command": "npx",
      "args": [
        "-y",
        "anyapi-mcp-server",
        "--name", "metabase",
        "--base-url", "https://your-metabase-instance.com/api",
        "--header", "x-api-key: ${METABASE_API_KEY}"
      ],
      "env": {
        "METABASE_API_KEY": "your-metabase-api-key"
      }
    }
  }
}

Tools

The server exposes five MCP tools:

list_api

Browse and search available API endpoints from the spec.

  • Call with no arguments to see all categories/tags
  • Provide category to list endpoints in a tag
  • Provide search to search across paths and descriptions
  • Results are paginated with limit (default 20) and offset
  • GraphQL selection for categories:
    {
      items {
        tag
        endpointCount
      }
      _count
    }
    
  • GraphQL selection for endpoints:
    {
      items {
        method
        path
        summary
      }
      _count
    }
    

call_api

Inspect an API endpoint by making a real request and returning the inferred GraphQL schema (SDL). No response data is returned — use query_api to fetch actual data.

  • Returns the full schema SDL showing all available fields and types
  • Returns accepted parameters (name, location, required) from the API spec
  • Returns suggestedQueries — ready-to-use GraphQL queries generated from the schema
  • Accepts optional headers to override defaults for this request
  • For write operations (POST/PUT/DELETE/PATCH) with request body schemas, the schema includes a Mutation type

query_api

Fetch data from an API endpoint, returning only the fields you select via GraphQL.

  • Object responses:
    {
      id
      name
      collection {
        id
        name
      }
    }
    
  • Array responses:
    {
      items {
        id
        name
      }
      _count
    }
    
  • Mutation syntax for writes:
    mutation {
      post_endpoint(input: { ... }) {
        id
        name
      }
    }
    
  • Supports limit and offset for client-side slicing of already-fetched data
  • For API-level pagination, pass limit/offset inside params instead
  • Accepts optional headers to override defaults for this request

explain_api

Get detailed documentation for an endpoint directly from the spec — no HTTP request is made.

  • Returns summary, description, operationId, deprecation status, tag
  • Lists all parameters with name, location (path/query/header), required flag, and description
  • Shows request body schema with property types, required fields, and descriptions
  • Lists response status codes with descriptions (e.g. 200 OK, 404 Not Found)
  • Includes external docs link when available

batch_query

Fetch data from multiple endpoints concurrently in a single tool call.

  • Accepts an array of 1–10 requests, each with method, path, params, body, query, and optional headers
  • All requests execute in parallel via Promise.allSettled — one failure does not affect the others
  • Each request follows the query_api flow: HTTP fetch → schema inference → GraphQL field selection
  • Returns an array of results: { method, path, data } on success or { method, path, error } on failure
  • Run call_api first on each endpoint to discover the schema field names

Workflow

  1. Discover endpoints with list_api
  2. Understand an endpoint with explain_api to see its parameters, request body, and response codes
  3. Inspect a specific endpoint with call_api to see the inferred response schema and suggested queries
  4. Query the endpoint with query_api to fetch exactly the fields you need
  5. Batch multiple queries with batch_query when you need data from several endpoints at once

How It Works

OpenAPI/Postman spec
        │
        ▼
   ┌─────────┐  ┌─────────────┐  ┌──────────┐  ┌───────────┐  ┌─────────────┐
   │list_api │  │ explain_api │  │ call_api │  │ query_api │  │ batch_query │
   │(browse) │  │   (docs)    │  │ (schema) │  │  (data)   │  │ (parallel)  │
   └─────────┘  └─────────────┘  └──────────┘  └───────────┘  └─────────────┘
        │          │ no HTTP          │               │             │
        ▼          ▼ request          ▼               ▼             ▼
   Spec index   Spec index     REST API call    REST API call  N concurrent
   (tags,       (params,       (with retry      (cached if     REST API calls
    paths)       responses,     + caching)       same as        + GraphQL
                 body schema)       │            call_api)      execution
                                    ▼               │
                               Infer GraphQL        ▼
                               schema from     Execute GraphQL
                               JSON response   query against
                                               response data
  1. The spec file is parsed at startup into an endpoint index with tags, paths, parameters, and request body schemas
  2. call_api makes a real HTTP request, infers a GraphQL schema from the JSON response, and caches both the response (30s TTL) and the schema
  3. query_api re-uses the cached response if called within 30s, executes your GraphQL field selection against the data, and returns only the fields you asked for
  4. Write operations (POST/PUT/DELETE/PATCH) with OpenAPI request body schemas get a Mutation type with typed GraphQLInputObjectType inputs

Supported Spec Formats

  • OpenAPI 3.x (JSON or YAML)
  • OpenAPI 2.0 / Swagger (JSON or YAML)
  • Postman Collection v2.x (JSON)

$ref resolution is supported for OpenAPI request body schemas. Postman :param path variables are converted to OpenAPI-style {param} automatically.

License

Proprietary Non-Commercial. Free for personal and educational use. Commercial use requires written permission. See LICENSE for details.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选