AP

APIWeaver: MCP Server for REST and GraphQL

Integrate any REST API, GraphQL endpoint, or web service into an MCP server with APIWeaver to enable AI assistants like Claude to access your data.

Overview

APIWeaver is an MCP (Model Context Protocol) server that converts web API definitions into MCP-compatible tools at runtime. By registering REST or GraphQL endpoints with APIWeaver, each endpoint becomes a callable tool that MCP-capable AI assistants (for example, Claude Desktop) can invoke to fetch or mutate external data. This makes it straightforward to expose arbitrary web services as toolable context for LLM workflows.

The server supports common authentication schemes, flexible parameter mappings (query, path, headers, body), and multiple transport modes (stdio, SSE, and Streamable HTTP) to match local, legacy, and cloud deployments. APIWeaver is implemented for fast startup and runtime registration so integrations can be added, tested, and removed without restarting the MCP server.

Repository: https://github.com/GongRzhe/APIWeaver

Features

  • Dynamic runtime registration of any web API (REST or GraphQL)
  • Multiple auth schemes: Bearer, API Key (param/header), Basic, OAuth2, and custom headers
  • Support for all HTTP methods: GET, POST, PUT, PATCH, DELETE, etc.
  • Parameter locations: query, path, header, and body
  • Automatic tool generation: each configured endpoint appears as an MCP tool
  • Built-in connection testing for endpoints before use
  • Response handling: JSON parsing with text fallback
  • Multiple transport types: STDIO, SSE (legacy), and Streamable HTTP (recommended)
  • Transport-agnostic operation suitable for desktop apps, legacy clients, and cloud services

Transport Modes

TransportBest forEndpoint / Notes
stdioLocal CLI and desktop appsDefault. Uses process stdin/stdout — no HTTP URL.
sse (legacy)Old MCP clients supporting Server-Sent EventsHTTP endpoint: http://host:port/mcp (one-way server->client streaming). Deprecated.
streamable-http (recommended)Modern MCP clients, cloud deploymentsHTTP endpoint: http://host:port/mcp (bidirectional streaming, better error handling).

Installation / Configuration

Clone and install dependencies:

# Clone the repository
git clone https://github.com/GongRzhe/APIWeaver.git
cd APIWeaver

# Install Python dependencies
pip install -r requirements.txt

# Optional: install the package locally
pip install .

Run the server (examples):

# Default STDIO transport
apiweaver run

# Streamable HTTP transport (recommended)
apiweaver run --transport streamable-http --host 127.0.0.1 --port 8000

# SSE transport (legacy)
apiweaver run --transport sse --host 127.0.0.1 --port 8000

CLI development mode:

# Run directly from the repo (dev)
python -m apiweaver.cli run --transport streamable-http --host 127.0.0.1 --port 8000

Common options:

  • –transport: stdio | sse | streamable-http
  • –host: host for HTTP transports (default 127.0.0.1)
  • –port: port for HTTP transports (default 8000)
  • –path: URL path for MCP endpoint (default /mcp)

Run apiweaver run --help for full CLI flags.

API Configuration Format

Register APIs by supplying a JSON configuration describing base URL, auth, headers, and endpoints. Example structure:

{
  "name": "my_api",
  "base_url": "https://api.example.com",
  "description": "Example API integration",
  "auth": {
    "type": "bearer",
    "bearer_token": "your-token-here"
  },
  "headers": {
    "Accept": "application/json"
  },
  "endpoints": [
    {
      "name": "list_users",
      "description": "Get all users",
      "method": "GET",
      "path": "/users",
      "params": [
        {
          "name": "limit",
          "type": "integer",
          "location": "query",
          "required": false,
          "default": 10
        }
      ]
    }
  ]
}

Use the built-in register_api tool to add this configuration at runtime.

Available Tools

APIWeaver exposes a set of core MCP tools for managing integrations:

  • register_api — Register a new API and generate endpoint tools
  • list_apis — List registered APIs and their endpoints
  • unregister_api — Remove an API and its generated tools
  • test_api_connection — Validate connectivity and authentication for an API
  • call_api — Generic caller to invoke an arbitrary registered endpoint
  • get_api_schema — Retrieve schema/metadata for a registered API

These tools let AI assistants discover and invoke external services without manual adapter code.

Use Cases

  1. Fetch public weather data (OpenWeatherMap)

    • Register an API with base_url https://api.openweathermap.org/data/2.5 and an api_key auth.
    • Create an endpoint get_current_weather with query params (q, units, appid).
    • Use test_api_connection to confirm access, then allow an assistant to call get_current_weather for a city.
  2. Query a REST backend (internal company API)

    • Register internal service with Basic or Bearer auth, map path params and query params for resources like /projects/{id}.
    • Use call_api to retrieve or update records from a model-aware assistant.
  3. Use GraphQL endpoints

    • Configure a GraphQL endpoint with POST method and a single “query” body parameter.
    • The assistant can send GraphQL queries as tool calls and receive parsed JSON responses.
  4. Integrate GitHub (REST or GraphQL)

    • Register the GitHub API with a personal access token.
    • Expose tools for listing repositories, creating issues, or running GraphQL queries for rich repository metadata.

Getting started typically involves launching APIWeaver, registering an API via the register_api tool (JSON config), testing the connection, and then letting the assistant discover and invoke the generated endpoint tools. This workflow enables secure, on-demand access to external data from MCP-aware assistants.