A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/GongRzhe/APIWeaver below:

GongRzhe/APIWeaver: A FastMCP server that dynamically creates MCP (Model Context Protocol) servers from web API configurations. This allows you to easily integrate any REST API, GraphQL endpoint, or web service into an MCP-compatible tool that can be used by AI assistants like Claude.

A FastMCP server that dynamically creates MCP (Model Context Protocol) servers from web API configurations. This allows you to easily integrate any REST API, GraphQL endpoint, or web service into an MCP-compatible tool that can be used by AI assistants like Claude.

APIWeaver supports three different transport types to accommodate various deployment scenarios:

STDIO Transport (Default) Streamable HTTP Transport (Recommended)
# Clone or download this repository
cd ~/Desktop/APIWeaver

# Install dependencies
pip install -r requirements.txt
{
  "mcpServers": {
    "apiweaver": {
      "command": "uvx",
      "args": ["apiweaver", "run"]
    }
  }
}

There are several ways to run the APIWeaver server with different transport types:

1. After installation (recommended):

If you have installed the package (e.g., using pip install . from the project root after installing requirements):

# Default STDIO transport
apiweaver run

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

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

2. Directly from the repository (for development):

# From the root of the repository
python -m apiweaver.cli run [OPTIONS]

Transport Options:

Run apiweaver run --help for all available options.

Using with AI Assistants (like Claude Desktop)

APIWeaver is designed to expose web APIs as tools for AI assistants that support the Model Context Protocol (MCP). Here's how to use it:

  1. Start the APIWeaver Server:

    For modern MCP clients (recommended):

    apiweaver run --transport streamable-http --host 127.0.0.1 --port 8000

    For legacy compatibility:

    apiweaver run --transport sse --host 127.0.0.1 --port 8000

    For local desktop applications:

    apiweaver run  # Uses STDIO transport
  2. Configure Your AI Assistant: The MCP endpoint will be available at:

  3. Register APIs and Use Tools: Once connected, use the built-in register_api tool to define web APIs, then use the generated endpoint tools.

The server provides these built-in tools:

  1. register_api - Register a new API and create tools for its endpoints
  2. list_apis - List all registered APIs and their endpoints
  3. unregister_api - Remove an API and its tools
  4. test_api_connection - Test connectivity to a registered API
  5. call_api - Generic tool to call any registered API endpoint
  6. get_api_schema - Get schema information for APIs and endpoints
{
  "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,
          "description": "Number of users to return"
        }
      ]
    }
  ]
}
Example 1: OpenWeatherMap API
{
  "name": "weather",
  "base_url": "https://api.openweathermap.org/data/2.5",
  "description": "OpenWeatherMap API",
  "auth": {
    "type": "api_key",
    "api_key": "your-api-key",
    "api_key_param": "appid"
  },
  "endpoints": [
    {
      "name": "get_current_weather",
      "description": "Get current weather for a city",
      "method": "GET",
      "path": "/weather",
      "params": [
        {
          "name": "q",
          "type": "string",
          "location": "query",
          "required": true,
          "description": "City name"
        },
        {
          "name": "units",
          "type": "string",
          "location": "query",
          "required": false,
          "default": "metric",
          "enum": ["metric", "imperial", "kelvin"]
        }
      ]
    }
  ]
}
{
  "name": "github",
  "base_url": "https://api.github.com",
  "description": "GitHub REST API",
  "auth": {
    "type": "bearer",
    "bearer_token": "ghp_your_token_here"
  },
  "headers": {
    "Accept": "application/vnd.github.v3+json"
  },
  "endpoints": [
    {
      "name": "get_user",
      "description": "Get a GitHub user's information",
      "method": "GET",
      "path": "/users/{username}",
      "params": [
        {
          "name": "username",
          "type": "string",
          "location": "path",
          "required": true,
          "description": "GitHub username"
        }
      ]
    }
  ]
}
{
  "auth": {
    "type": "bearer",
    "bearer_token": "your-token-here"
  }
}
{
  "auth": {
    "type": "api_key",
    "api_key": "your-key-here",
    "api_key_header": "X-API-Key"
  }
}
API Key (Query Parameter)
{
  "auth": {
    "type": "api_key",
    "api_key": "your-key-here",
    "api_key_param": "api_key"
  }
}
{
  "auth": {
    "type": "basic",
    "username": "your-username",
    "password": "your-password"
  }
}
{
  "auth": {
    "type": "custom",
    "custom_headers": {
      "X-Custom-Auth": "custom-value",
      "X-Client-ID": "client-123"
    }
  }
}
{
  "timeout": 60.0  // Timeout in seconds
}
{
  "name": "status",
  "type": "string",
  "enum": ["active", "inactive", "pending"]
}
{
  "name": "page",
  "type": "integer",
  "default": 1
}
Claude Desktop Configuration For Streamable HTTP Transport (Recommended)
{
  "mcpServers": {
    "apiweaver": {
      "command": "apiweaver",
      "args": ["run", "--transport", "streamable-http", "--host", "127.0.0.1", "--port", "8000"]
    }
  }
}
For STDIO Transport (Traditional)
{
  "mcpServers": {
    "apiweaver": {
      "command": "apiweaver",
      "args": ["run"]
    }
  }
}

The server provides detailed error messages for:

  1. Choose the Right Transport: Use streamable-http for modern deployments, stdio for local tools
  2. Test First: Always use test_api_connection after registering an API
  3. Start Simple: Begin with GET endpoints before moving to complex POST requests
  4. Check Auth: Ensure your authentication credentials are correct
  5. Use Descriptions: Provide clear descriptions for better AI understanding
  6. Handle Errors: The server will report HTTP errors with details
  1. 401 Unauthorized: Check your authentication credentials
  2. 404 Not Found: Verify the base URL and endpoint paths
  3. Timeout Errors: Increase the timeout value for slow APIs
  4. SSL Errors: Some APIs may require specific SSL configurations

Run with verbose logging (if installed):

Transport-Specific Issues

Feel free to extend this server with additional features:

MIT License - feel free to use and modify as needed.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4