SuperAPIAI Directory

rest_api_mcp

github.com · AI coding

Authenticated calls to any REST API: auto-login, token caching, 2FA/OTP support, Swagger spec fetching and fuzzy endpoint search.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsAPI

About this tool

rest_api_mcp is a Model Context Protocol (MCP) server used to let AI agents call REST APIs that require authentication. Its core goal is to eliminate the need to write authentication code: put the server into any project, point it at the target API, and the agent can automatically complete login and call endpoints.

Main capabilities

  • Automatic login: The server automatically scans the Swagger specification, looks for the first POST path containing "login" as the login endpoint, and transparently logs in again when the token expires.
  • 2FA/OTP support: When the API requires two-step verification, the verification endpoint and OTP can be configured, and the server will automatically execute the two-step login and verification flow, and automatically detect and forward the session identifier returned by the first step (such as session_token, requestId, temp_token, nonce, transactionId, etc.).
  • Swagger specification retrieval: Can pull the complete OpenAPI/Swagger JSON specification for schema inspection, DTO discovery, or understanding available endpoints.
  • Fuzzy endpoint search: Searches the API specification by keyword and returns the method, path, summary, tags, and required parameters of matching endpoints.
  • Automatic token path detection: Tries common paths in order such as data.access_token, access_token, data.token, token, data.accessToken, accessToken, data.data.access_token, result.access_token, result.token, etc.

Provided tools

  • search_endpoints: Fuzzy-searches the API specification by keyword and returns the method, path, summary, tags, and required parameters of matching endpoints. When the exact path is unknown, use this tool first.
  • describe_endpoint: Returns the complete OpenAPI schema of a single endpoint, including parameters, request body schema (with types, required flags, enums, examples), response schema, and a generated example request body. Use it before calling request() to clarify request body fields and response structure.
  • request: Makes an authenticated API call, automatically handles login, and transparently logs in again when the token expires. The response includes login_data, which is the complete loginRecord responses, usable for obtaining IDs needed by subsequent requests such as userId, orgId, tenantId, etc. Supports GET, POST, PATCH, and public endpoints that require no authentication, and also supports custom token_path and custom 2FA session fields.
  • fetch_spec: Fetch the complete OpenAPI/Swagger JSON specification, used for schema checking, DTO discovery, or learning about available endpoints. Returns the raw OpenAPI JSON, truncated according to REST_RESPONSE_SIZE_LIMIT when too large.
  • inspect_login: Execute the login flow (and optionally 2FA verification), returning the raw server response without extracting tokens, while also returning heuristic suggestions, including suspected token paths (fields that look like JWTs or long authentication strings) and session fields (fields that look like 2FA verification session identifiers). Use when automatic detection fails, so that the AI can identify the correct token_path and verify_session_fields and pass them to request(). The server caches the token_path and verify_session_fields provided by the AI, so that re-login after token expiration automatically uses them.

Usage Method A (recommended) - use via npx: no installation required. Add the configuration to the project's .vscode/mcp.json, and VS Code will automatically download and run the package, always using the latest published version on npm. Method B - local use (for development/offline): after building locally, point VS Code to the local build artifact, with the configuration written to the project's .vscode/mcp.json. All configuration is done through environment variables in mcp.json, with no need to modify code.

Authentication flow

  • Standard login: the most common case, email plus password, directly returning a token. The server automatically discovers the login endpoint by scanning the Swagger specification, and it can also be manually overridden.
  • Login with additional credentials: some APIs require fields beyond email and password in the login request body, such as role, source, channel, tenantId, etc. API_LOGIN_CREDENTIALS can be set to a JSON object string, and these fields will be merged together with the email and password into the login POST request body. The field names depend entirely on your API, you need to consult its Swagger specification or documentation.
  • Two-factor authentication (2FA): Some APIs require a second verification step after the initial login. The server returns a one-time verification code to the user's email or phone, which must be submitted to a separate endpoint to obtain the real JWT. Three environment variables drive this process: API_VERIFY_ENDPOINT (the path for the second step; once set, the server will automatically perform both steps and then attach the token), API_OTP (the OTP value to submit; in test environments this is usually a fixed test code provided by the API team, while in production you need to obtain a real-time verification code from email and set it), and session continuation (the session identifier returned by the first login step will be automatically detected and forwarded to the verification endpoint, with no manual configuration required). If the verification endpoint requires additional fields beyond the session identifier or OTP, they can be added via API_VERIFY_CREDENTIALS.

Multiple API setup Multiple independent server instances can be run in the same mcp.json, one instance per API. Each instance independently runs its own authentication session, token cache, and specification cache.

Use cases

  • You need to let an AI agent call an authenticated REST API, but do not want to write authentication code.
  • You need to explore or debug API endpoints, request body structures, and response patterns.
  • You need to handle automated scenarios for authentication flows such as login, token refresh, and 2FA.

Limitations and notes

  • When automatic detection fails (for example, the login response uses an uncommon token path), use inspect_login() to view the raw response and heuristic suggestions, then pass the correct path to request(), or set it explicitly via API_TOKEN_PATH.
  • When 2FA verification returns 401, the verification endpoint may require a different OTP field name. You can use API_VERIFY_CREDENTIALS, and do not set API_OTP when the field name is not otp.
  • When search_endpoints has no matches, confirm that API_SWAGGER_URL is set and accessible, try broader keywords, and note that the specification may be truncated; use fetch_spec to check.
  • Oversized responses will be truncated; the limit can be adjusted via REST_RESPONSE_SIZE_LIMIT.
  • More information about fees, pricing, platform support scope, etc. is not currently provided.
Up/Down to navigate · Enter to open · ESC to closeBrowse all tools