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
| Transport | Best for | Endpoint / Notes |
|---|---|---|
| stdio | Local CLI and desktop apps | Default. Uses process stdin/stdout — no HTTP URL. |
| sse (legacy) | Old MCP clients supporting Server-Sent Events | HTTP endpoint: http://host:port/mcp (one-way server->client streaming). Deprecated. |
| streamable-http (recommended) | Modern MCP clients, cloud deployments | HTTP endpoint: http://host:port/mcp (bidirectional streaming, better error handling). |
Installation / Configuration
Clone and install dependencies:
# Clone the repository
# Install Python dependencies
# Optional: install the package locally
Run the server (examples):
# Default STDIO transport
# Streamable HTTP transport (recommended)
# SSE transport (legacy)
CLI development mode:
# Run directly from the repo (dev)
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:
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
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.
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.
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.
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.