Skip to main content
Glama
bvenkata

mcp-api-connect

mcp-api-connect

License: MIT Python 3.10+

Ein Payload rein, jede API raus. mcp-api-connect ist eine protokoll- und auth-agnostische Connector-Engine: Beschreibe einen Zielservice (URL, Protokoll, Auth, Request-/Response-Form) einmal, sende dann einen normalisierten Payload und erhalte eine normalisierte Antwort zurück – egal ob das Ziel eine REST/JSON-API, ein Legacy-SOAP-Service, geschützt durch einen API-Schlüssel, Basic Auth, ein Bearer-Token oder OAuth2-Client-Credentials ist.

Es wird als drei Dinge geliefert, die auf derselben Kern-Engine basieren, sodass du es nutzen kannst, wie du willst:

  • Eine Python-Bibliothek – pip install mcp-api-connect, rufe MCPAPIConnectEngine direkt auf, kein Server erforderlich.

  • Eine eigenständige HTTP-API – pip install mcp-api-connect[api], führe mcp-api-connect-api aus, POST an /invoke.

  • Ein MCP-Server – pip install mcp-api-connect[mcp], führe mcp-api-connect aus, richte jeden MCP-Client (Claude usw.) darauf aus, damit ein Agent registrierte Connectors – oder beliebige Dienste spontan – als Tools aufrufen kann.

Warum

Jedes Integrationsprojekt erfindet das Rad neu: hier ein REST-Client, dort ein SOAP-Client, ein Auth-Flow pro Dienst, Ad-hoc-Request-/Response-Mapping über die gesamte Codebasis verstreut. mcp-api-connect zentralisiert das in einer deklarativen Spezifikation (InvokeSpec) und einer Ausführungs-Engine, sodass das Hinzufügen eines neuen Zielservices Konfiguration und nicht Code ist.

Related MCP server: Universal API Connector MCP

Schnellstart (Bibliothek)

pip install mcp-api-connect
import asyncio
from mcp_api_connect import MCPAPIConnectEngine, InvokeSpec, Target, AuthSpec, AuthType, RequestFormat, ResponseFormat

spec = InvokeSpec(
    target=Target(base_url="https://api.example.com"),
    auth=AuthSpec(type=AuthType.API_KEY, config={"api_key": "secret", "header_name": "X-API-Key"}),
    request_format=RequestFormat(method="POST", path="/v1/orders", content_type="json"),
    response_format=ResponseFormat(content_type="json"),
)

async def main():
    async with MCPAPIConnectEngine() as engine:
        result = await engine.invoke(spec, {"customer": "jane"})
        print(result.success, result.data)

asyncio.run(main())

Schnellstart (HTTP-API)

pip install "mcp-api-connect[api]"
mcp-api-connect-api   # serves on :8000, interactive docs at /docs
curl -X POST http://localhost:8000/invoke -H 'content-type: application/json' -d '{
  "spec": {
    "target": {"base_url": "https://api.example.com"},
    "auth": {"type": "api_key", "config": {"api_key": "secret"}},
    "request_format": {"method": "POST", "path": "/v1/orders"},
    "response_format": {"content_type": "json"}
  },
  "payload": {"customer": "jane"}
}'

Registriere einen wiederverwendbaren Connector einmal und rufe ihn dann per Namen auf:

curl -X POST http://localhost:8000/connectors -d '{"name": "orders-api", "spec": {...}}'
curl -X POST http://localhost:8000/connectors/orders-api/invoke -d '{"customer": "jane"}'

Schnellstart (MCP)

pip install "mcp-api-connect[mcp]"
{
  "mcpServers": {
    "mcp-api-connect": { "command": "/path/to/.venv/bin/mcp-api-connect" }
  }
}

Stellt Tools bereit: invoke (zustandslos, einmalig), register_connector, list_connectors, invoke_connector (per Name), delete_connector. Ein Agent kann einmal einen Connector für „die Salesforce-API“ registrieren und dann einfach sagen „ruf sie mit diesem Payload auf“.

➜ Vollständige Einrichtung für Claude Desktop / Claude Code / Cursor, Persistenz, Sicherheitshinweise und ein durchgearbeitetes Beispiel: docs/mcp-integration.md.

Kernkonzepte

  • Target – Basis-URL, Protokoll (rest | soap), Timeout, Standard-Header.

  • AuthSpec – type (none, api_key, basic, bearer, oauth2_client_credentials) plus ein config-Dict, das für diesen Typ geformt ist. OAuth2-Tokens werden automatisch abgerufen und zwischengespeichert.

  • RequestFormat / ResponseFormat – Inhaltstyp (json, xml, soap) plus eine deklarative field_map ({"target.path": "$.source.jsonpath"}) zum Umformen von Payloads ohne Code, oder ein Jinja2-body_template für volle Kontrolle (erforderlich für SOAP-Envelopes).

  • InvokeSpec – bündelt die drei oben genannten; die Einheit von „wie man einen Dienst erreicht“. Speichere es als benannten Connector oder übergib es inline pro Aufruf.

Siehe src/mcp_api_connect/core/models.py für das vollständige Schema und docs/auth-reference.md für die config-Form, die jeder Auth-type erwartet.

Dokumentation

  • docs/mcp-integration.md – vollständige MCP-Client-Einrichtung (Claude Desktop, Claude Code, Cursor), Persistenz, Sicherheit, Tool-Referenz, durchgearbeitetes Beispiel, Fehlerbehebung

  • docs/auth-reference.md – config-Felder für jeden Auth-Typ

  • CONTRIBUTING.md – Entwickler-Setup, Tests ausführen, PR-Erwartungen

Erweitern

  • Neuer Auth-Typ: Implementiere AuthStrategy, registriere über engine.register_auth_strategy(...).

  • Neues Protokoll (z. B. GraphQL): Implementiere ProtocolAdapter, registriere über engine.register_adapter(...).

  • Neues Connector-Speicher-Backend: Implementiere ConnectorStore (wird mit InMemoryConnectorStore und SqliteConnectorStore geliefert, Anmeldedaten werden im Ruhezustand per Fernet verschlüsselt).

Roadmap

  • OAuth2-Autorisierungscode-Flow, mTLS, AWS-SigV4-Auth-Strategien

  • WSDL-gesteuertes SOAP (optionaler zeep-basierter Adapter, kein handgeschriebenes Envelope nötig)

  • GraphQL-Adapter

  • Postgres-basiertes ConnectorStore

  • Retry/Backoff- und Rate-Limiting-Richtlinien pro Connector

  • SSRF-sichere Ziel-Allowlist für öffentliche Bereitstellungen

Entwicklung

python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev,api,storage,mcp]"
pytest

Lizenz

MIT – siehe LICENSE.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables AI agents to connect to any API by loading OpenAPI, GraphQL, gRPC, or SOAP specs, with a built-in catalog of 2500+ public APIs, supporting secure execution, response filtering, chaining, and parallel calls.
    34 PyPI
    4
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables importing OpenAPI, Swagger, Google Discovery, GraphQL, and HTTP MCP definitions and generating typed agent tools whose calls map to HTTP endpoints under explicit execution policies such as allow, approval, or block. A hosted runtime adds credentials, OAuth scopes, request validation, approvals, and execution traces for safely exposing those endpoints to agents.
    741 npm
    4
    MIT
  • A
    license
    Not graded
    quality
    A
    maintenance
    Enables AI agents to discover and call existing OpenAPI services through governed tools, enforcing policy, approval for destructive operations, and credential handling before requests execute.
    1
    Apache 2.0