Skip to main content
Glama
zaber-dev

Free-AI Gateway MCP Server

by zaber-dev

⚡ Free-AI Gateway

Unternehmensgerechtes, fähigkeitsgesteuertes AI-Gateway-Monorepo, das kostenlose KI-APIs in wiederverwendbare Bibliotheken, Model Context Protocol (MCP)-Server und OpenAI-kompatible HTTP-Proxys bündelt.

License: MIT TypeScript Node.js Fastify Docker Learn Guide PRs Welcome

📚 Neu bei Free-AI Gateway? Schauen Sie sich das umfassende Architektur- und Entwicklerhandbuch (LEARN.md) für detaillierte Einblicke, Tutorials und Integrationsmuster an.


📖 Architektur- und Monorepo-Übersicht

free-ai-gateway ist als Enterprise-Monorepo organisiert, das reine KI-Orchestrierungsinfrastruktur von protokollspezifischen Bereitstellungsmechanismen (HTTP Fastify Proxy & MCP Server) trennt:

flowchart TD
    subgraph CoreLayer ["@free-ai-gateway/core (Standalone npm package)"]
        Router["CapabilityRouter & Strategy Engine"]
        Providers["19 Provider Adapters & Dynamic Registry"]
        Resilience["QuotaTracker & CircuitBreaker"]
        Observability["EventBus & MetricsTracker"]
        Transport["HttpClient with Exponential Backoff"]
    end

    subgraph Consumers ["Consumer Applications"]
        GatewayApp["apps/gateway (@free-ai-gateway/gateway)<br/>Fastify HTTP OpenAI Proxy"]
        McpApp["packages/mcp (@free-ai-gateway/mcp)<br/>Model Context Protocol Server"]
        SkillsPkg["packages/skills (@free-ai-gateway/skills)<br/>Agentic IDE Skills & CLI"]
        CliApp["packages/cli (@free-ai-gateway/cli)<br/>Terminal Assistant & Diagnostics"]
        ClientApp["Custom Node.js / TypeScript App<br/>Direct Library Import"]
    end

    GatewayApp -->|consumes| CoreLayer
    McpApp -->|consumes| CoreLayer
    SkillsPkg -->|integrates with| CoreLayer
    CliApp -->|consumes| CoreLayer
    ClientApp -->|consumes| CoreLayer

Monorepo-Arbeitsbereichsmatrix

Paket / App

Standort

Zweck

Abhängigkeiten

@free-ai-gateway/core

packages/core

Protokollneutraler Fähigkeitsrouter, Resilienz-Engine und 19 Provider-Adapter.

ajv, dotenv (Kein HTTP-Server)

@free-ai-gateway/mcp

packages/mcp

Model Context Protocol-Server, der KI-Agenten (Claude Desktop, Cursor) Fähigkeitswerkzeuge bereitstellt.

@free-ai-gateway/core

@free-ai-gateway/skills

packages/skills

Agentische IDE-Fähigkeiten (SKILL.md) und Installations-CLI für Antigravity, Claude, Cursor und Copilot.

Eigenständige CLI & API

@free-ai-gateway/cli

packages/cli

Terminal-KI-Assistent, interaktiver Chat-REPL, Modellkatalog und Diagnosetool.

@free-ai-gateway/core, @free-ai-gateway/skills

@free-ai-gateway/gateway

apps/gateway

Hochdurchsatz-Fastify-HTTP-Proxy, der OpenAI-kompatible Endpunkte mit automatischer Erkennung bereitstellt.

@free-ai-gateway/core, fastify


✨ Hauptfunktionen

  • 🎯 Fähigkeitsbasiertes Routing: Fordern Sie an, was Sie benötigen (model: "auto:tool_calling+structured_output"), und lassen Sie den Router den schnellsten gesunden kostenlosen Anbieter auswählen.

  • 📐 Strategiemuster-Engine: Plugbare Lastausgleichsstrategien (AdaptiveHealthStrategy, LowestLatencyStrategy oder benutzerdefinierte IRoutingStrategy).

  • 🔄 Autonomes Failover: Durchläuft transparent die rangierten Kandidatenanbieter, bis bei Auftreten von upstream 429 (Ratenbegrenzung) oder 5xx-Fehlern Erfolg erzielt wird.

  • 🛡️ Leistungsschalter: Erkennt fehlschlagende Anbieter und tritt in exponentielle Abkühlungs-Backoff ein, um Kaskadenausfälle zu verhindern.

  • ⏱️ Gleitfenster-Kontingentverfolgung: Speicherinterne Buchhaltung von RPM, TPM und RPD mit proaktivem Grenzschutz.

  • 🔌 Dynamischer Provider-Autoloader: Fügen Sie neue Anbieter hinzu, indem Sie eine Klasse, die BaseProvider erweitert, in packages/core/src/providers/ ablegen.

  • 📡 Typisierter Ereignisbus: Lebenszyklusereignisse (request:start, request:success, request:fallback, provider:rate_limited) für OpenTelemetry- und Prometheus-Beobachtbarkeit.

  • 🤖 Model Context Protocol (MCP)-bereit: Direkt in Claude Desktop, Cursor oder Agenten-Workflows verwendbar.


🧩 Unterstützte Anbieter-Matrix (19 Adapter)

Anbieter

Modalitäten / Fähigkeiten

Authentifizierung

Limit-Bereich

Google AI Studio

text, tool_calling, vision, structured_output, embedding, tts

GOOGLE_API_KEY

Pro Modell

Groq

text, tool_calling, structured_output, reasoning, speech_to_text

GROQ_API_KEY

Konto

SambaNova Cloud

text, tool_calling, reasoning, vision

SAMBANOVA_API_KEY

Konto

NVIDIA NIM

text, tool_calling, reasoning, vision, embedding, rerank, moderation

NVIDIA_API_KEY

Konto

Cohere

text, tool_calling, structured_output, reasoning, embedding, rerank

COHERE_API_KEY

Konto

OpenRouter

text, tool_calling, vision, reasoning, embedding, tts, moderation

OPENROUTER_API_KEY

Konto

OpenCode Zen

code, tool_calling, reasoning, text

OPENCODE_API_KEY

Konto

Bazaarlink.ai

text, code

BAZAARLINK_API_KEY

Konto

aimlapi.com

text

AIMLAPI_API_KEY

Konto

OVHcloud AI

text

OVHCLOUD_API_KEY

Pro Modell

Voyage AI

embedding

VOYAGE_API_KEY

Konto

Jina AI

embedding, rerank

JINA_API_KEY

Konto

Hugging Face

text, tool_calling, image_gen

HUGGINGFACE_API_KEY

Gemeinsamer Pool

Cloudflare Workers AI

image_gen, embedding

CLOUDFLARE_API_TOKEN

Gemeinsamer Pool

Google Cloud Platform

translation, speech_to_text, text_to_speech, vision

GCP_API_KEY

Konto

MyMemory

translation

MYMEMORY_API_KEY

Konto

Unstructured.io

document_processing

UNSTRUCTURED_API_KEY

Konto

Exa AI

web_search

EXA_API_KEY

Konto

Tavily

web_search

TAVILY_API_KEY

Konto


🚀 Schnellstart

1. Installation

# Clone the repository
git clone https://github.com/zaber-dev/free-ai-gateway.git
cd free-ai-gateway

# Install dependencies across all monorepo workspaces
npm install

2. Umgebung konfigurieren

Kopieren Sie .env.example zu .env und geben Sie Schlüssel für die Anbieter an, die Sie aktivieren möchten:

cp .env.example .env
PORT=3000
GROQ_API_KEY=gsk_...
GOOGLE_API_KEY=AIza...
NVIDIA_API_KEY=nvapi-...
COHERE_API_KEY=...

3. Bauen & Ausführen

# Compile all workspace packages
npm run build

# Run all 31 automated tests across all packages
npm test

# Start the Fastify HTTP Gateway (Dev mode)
npm run dev

# Start the Gateway in Production
npm start

💻 Nutzungsmodalitäten

Option A: HTTP-Gateway (OpenAI-kompatibel)

Rufen Sie den lokalen Proxy mit einem beliebigen OpenAI SDK oder curl auf:

curl http://localhost:3000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "auto:tool_calling+structured_output",
    "messages": [
      { "role": "user", "content": "Extract name and age from: Alice is 30 years old." }
    ]
  }'
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "http://localhost:3000/v1",
  apiKey: "not-needed",
});

const completion = await client.chat.completions.create({
  model: "auto:reasoning",
  messages: [{ role: "user", content: "Solve: How many r's in strawberry?" }],
});

console.log(completion.choices[0].message.content);

Option B: Einbettung von @free-ai-gateway/core als TypeScript-Bibliothek

Betten Sie den Fähigkeitsrouter direkt in Ihre Anwendung ein, ohne einen HTTP-Server zu starten:

import {
  CapabilityRouter,
  Registry,
  QuotaTracker,
  CircuitBreaker,
  EventBus,
  LowestLatencyStrategy,
} from "@free-ai-gateway/core";

const registry = new Registry();
const quota = new QuotaTracker();
const breaker = new CircuitBreaker();
const eventBus = new EventBus();

// Listen to lifecycle telemetry
eventBus.on("request:fallback", (evt) => {
  console.warn(`[Fallback] Failed on ${evt.attemptedProvider}: ${evt.error}`);
});

const router = new CapabilityRouter(
  registry,
  quota,
  breaker,
  undefined,
  eventBus,
  new LowestLatencyStrategy()
);

const response = await router.route({
  capabilities: ["text", "tool_calling"],
  payload: {
    messages: [{ role: "user", content: "Hello AI!" }],
  },
});

console.log("Served by:", response.servedBy);
console.log("Data:", response.data);

Option C: Model Context Protocol (MCP)-Server

Verbinden Sie Free-AI Gateway mit Claude Desktop oder Cursor:

{
  "mcpServers": {
    "free-ai-gateway": {
      "command": "node",
      "args": ["/path/to/free-ai-gateway/packages/mcp/dist/index.js"],
      "env": {
        "GROQ_API_KEY": "gsk_...",
        "GOOGLE_API_KEY": "AIza..."
      }
    }
  }
}

Bereitgestellte MCP-Tools:

  • freeai_generate: Text, Reasoning oder Code mit automatischem Failover generieren.

  • freeai_search: Websuchanfragen über Exa / Tavily.

  • freeai_embed: Vektoreinbettungen über Voyage, Jina, Gemini generieren.

  • freeai_rerank: Dokumente für Retrieval Augmented Generation (RAG) neu bewerten.

  • freeai_analyze_image: Multimodale Bildanalyse.


Option D: Agentische IDE-Fähigkeiten (@free-ai-gateway/skills)

Installieren Sie Free-AI Gateway-Agentenfähigkeiten direkt in Ihre IDE oder Ihren autonomen Codierungsassistenten:

# Install to Google Antigravity (.agents/skills)
npx @free-ai-gateway/skills install --target=antigravity

# Install to Cursor (.cursor/skills)
npx @free-ai-gateway/skills install --target=cursor

# Install to Claude Code (.claude/skills)
npx @free-ai-gateway/skills install --target=claude

# Install to all supported AI assistants
npx @free-ai-gateway/skills install --target=all

Option E: Terminal-CLI-Tool (@free-ai-gateway/cli)

Verwenden Sie Free-AI direkt von Ihrem Terminal oder Befehlszeilenskripten aus:

# One-off prompt execution with auto-routing
npx @free-ai-gateway/cli "Explain MapReduce in simple terms"

# Interactive chat REPL in terminal
npx @free-ai-gateway/cli chat --capability=reasoning

# Check model catalog across all 19 providers
npx @free-ai-gateway/cli models

# Run system diagnostics
npx @free-ai-gateway/cli doctor

🏛️ Monorepo-Struktur

free-ai-gateway/
├── packages/
│   ├── core/                        # @free-ai-gateway/core
│   │   ├── AGENTS.md                # Agentic guidelines for @free-ai-gateway/core
│   │   ├── src/
│   │   │   ├── capabilities/        # Capability definitions & parsing
│   │   │   ├── config/              # providers.json, schema, config sources
│   │   │   ├── errors/              # ProviderError, NoProviderAvailableError
│   │   │   ├── observability/       # EventBus, MetricsTracker
│   │   │   ├── providers/           # 19 Provider Adapters + Registry + Loader
│   │   │   ├── resilience/          # QuotaTracker, CircuitBreaker
│   │   │   ├── router/              # CapabilityRouter & Strategy Pattern
│   │   │   ├── transport/           # HttpClient with exponential backoff
│   │   │   ├── types/               # Unified contracts & response schemas
│   │   │   └── index.ts             # Public Core API
│   │   ├── tests/                   # 20 Core unit tests
│   │   └── package.json
│   │
│   ├── mcp/                         # @free-ai-gateway/mcp
│   │   ├── AGENTS.md                # Agentic guidelines for @free-ai-gateway/mcp
│   │   ├── src/
│   │   │   ├── tools/               # generate, search, embed, rerank, analyze-image
│   │   │   ├── resources/           # capabilities, models catalog
│   │   │   ├── server.ts            # FreeAiMcpServer handler
│   │   │   └── index.ts
│   │   ├── tests/                   # 3 MCP server tests
│   │   └── package.json
│   │
│   ├── skills/                      # @free-ai-gateway/skills
│   │   ├── AGENTS.md                # Agentic guidelines for @free-ai-gateway/skills
│   │   ├── src/
│   │   │   ├── skills/              # Built-in skills (free-ai-gateway, scaffolding, mcp)
│   │   │   ├── installer.ts         # Multi-target installer
│   │   │   ├── cli.ts               # CLI executable (free-ai-skills)
│   │   │   └── index.ts
│   │   ├── tests/                   # 4 Skills tests
│   │   └── package.json
│   │
│   └── cli/                         # @free-ai-gateway/cli
│       ├── AGENTS.md                # Agentic guidelines for @free-ai-gateway/cli
│       ├── src/
│       │   ├── commands/            # prompt, chat, models, doctor, skills
│       │   ├── cli.ts               # Argument parsing & dispatcher
│       │   ├── bin.ts               # CLI executable (free-ai, freeai)
│       │   └── index.ts
│       ├── tests/                   # 4 CLI tests
│       └── package.json
│
├── apps/
│   └── gateway/                     # @free-ai-gateway/gateway (HTTP App)
│       ├── AGENTS.md                # Agentic guidelines for @free-ai-gateway/gateway
│       ├── src/
│       │   ├── adapters/            # OpenAI chat response normalizer
│       │   ├── api/
│       │   │   ├── routes/          # Fastify route modules & RouteLoader
│       │   │   └── server.ts        # Server factory, timing hooks, 404 handler
│       │   ├── jobs/                # Background JobScheduler & reverify worker
│       │   └── index.ts
│       ├── tests/                   # 5 Gateway HTTP tests
│       ├── Dockerfile               # Monorepo container builder
│       └── package.json
│
├── tests/
│   └── e2e/                         # 5 Cross-package E2E integration tests
│
├── AGENTS.md                        # Monorepo Root Agentic Guidelines
├── CLAUDE.md                        # Claude Code Instructions
├── .agents/                         # Workspace Skills Directory
├── .github/workflows/ci.yml         # Matrix CI workflow
├── docker-compose.yml
├── package.json                     # Root workspace definition
├── tsconfig.base.json               # Shared TypeScript compiler settings
└── README.md


🤝 Community & Governance


👤 Autor

Erstellt und gepflegt mit ❤️ von Md. Mahedi Zaman Zaber.


📄 Lizenz

Dieses Projekt ist Open Source und verfügbar unter der MIT License.

-
license - not tested
-
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

  • Free public MCP for AI agents — 193 tools, 44 workflows. No API key.

  • OCR, transcription, file extraction, and image generation for AI agents via MCP.

  • Hosted MCP with 91 agent tools: X, domains, SEO, Maps, Trends, Search, YouTube, TikTok, and more.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/zaber-dev/free-ai-gateway'

If you have feedback or need assistance with the MCP directory API, please join our Discord server