Free-AI Gateway MCP Server
⚡ Free-AI Gateway
エンタープライズグレードの機能ベースルーティングAI Gatewayモノレポ。無料階層のAI APIを再利用可能なライブラリ、Model Context Protocol (MCP) サーバー、OpenAI互換のHTTPプロキシに集約します。
📚 Free-AI Gatewayに初めての方は? 詳細な深掘り解説、チュートリアル、統合パターンについては、包括的な アーキテクチャ&開発者ガイド (LEARN.md) をご覧ください。
📖 アーキテクチャとモノレポ概要
free-ai-gateway は、純粋なAIオーケストレーション基盤と、プロトコル固有の配信メカニズム (HTTP Fastify Proxy & MCP Server) を分離したエンタープライズモノレポとして構成されています。
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モノレポワークスペースマトリックス
パッケージ / アプリ | 場所 | 目的 | 依存関係 |
|
| プロトコルに依存しない機能ルーター、レジリエンスエンジン、19のプロバイダアダプター。 |
|
|
| AIエージェント (Claude Desktop, Cursor) に機能ツールを公開するModel Context Protocolサーバー。 |
|
|
| Antigravity、Claude、Cursor、Copilot向けのエージェンシックIDEスキル ( | スタンドアロンCLI & API |
|
| ターミナルAIアシスタント、対話型チャットREPL、モデルカタログ、診断ツール。 |
|
|
| 自動検出機能を備えたOpenAI互換エンドポイントを提供する高スループットFastify HTTPプロキシ。 |
|
✨ 主要機能
🎯 機能ベースルーティング: 必要なものをリクエスト (
model: "auto:tool_calling+structured_output") し、ルーターが最速の正常な無料プロバイダを選択します。📐 ストラテジパターンエンジン: プラグイン可能なロードバランシング戦略 (
AdaptiveHealthStrategy,LowestLatencyStrategy、またはカスタムIRoutingStrategy)。🔄 自律フェイルオーバー: アップストリームの
429(レート制限) や5xxエラーが発生した場合、ランク付けされた候補プロバイダを透過的に巡回し、成功するまで試行します。🛡️ サーキットブレーカー: 障害が発生しているプロバイダを検出し、指数的なクールダウンバックオフを実行してカスケード障害を防止します。
⏱️ スライディングウィンドウクォータトラッキング: RPM、TPM、RPDのインメモリ追跡と、予防的な制限保護機能。
🔌 動的プロバイダオートローダー:
packages/core/src/providers/にBaseProviderを拡張するクラスを追加するだけで、新しいプロバイダを追加できます。📡 型付きイベントバス: OpenTelemetry および Prometheus での可観測性のためのライフサイクルイベント (
request:start,request:success,request:fallback,provider:rate_limited)。🤖 Model Context Protocol (MCP) 対応: Claude Desktop、Cursor、またはエージェントワークフローで直接使用可能。
🧩 サポート対象プロバイダマトリックス (19アダプター)
プロバイダ | モダリティ / 機能 | 認証 | 制限範囲 |
Google AI Studio |
|
| モデル別 |
Groq |
|
| アカウント |
SambaNova Cloud |
|
| アカウント |
NVIDIA NIM |
|
| アカウント |
Cohere |
|
| アカウント |
OpenRouter |
|
| アカウント |
OpenCode Zen |
|
| アカウント |
Bazaarlink.ai |
|
| アカウント |
aimlapi.com |
|
| アカウント |
OVHcloud AI |
|
| モデル別 |
Voyage AI |
|
| アカウント |
Jina AI |
|
| アカウント |
Hugging Face |
|
| 共有プール |
Cloudflare Workers AI |
|
| 共有プール |
Google Cloud Platform |
|
| アカウント |
MyMemory |
|
| アカウント |
Unstructured.io |
|
| アカウント |
Exa AI |
|
| アカウント |
Tavily |
|
| アカウント |
🚀 クイックスタート
1. インストール
# 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 install2. 環境設定
.env.example を .env にコピーし、有効にしたいプロバイダのキーを設定します。
cp .env.example .envPORT=3000
GROQ_API_KEY=gsk_...
GOOGLE_API_KEY=AIza...
NVIDIA_API_KEY=nvapi-...
COHERE_API_KEY=...3. ビルドと実行
# 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💻 使用方法
オプションA: HTTPゲートウェイ (OpenAI互換)
任意のOpenAI SDKまたは curl でローカルプロキシを呼び出します。
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);オプションB: @free-ai-gateway/core をTypeScriptライブラリとして埋め込む
HTTPサーバーを起動せずに、アプリケーションに直接機能ルーターを埋め込みます。
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);オプションC: Model Context Protocol (MCP) サーバー
Free-AI Gateway を Claude Desktop または 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..."
}
}
}
}公開されるMCPツール:
freeai_generate: 自動フェイルオーバーによるテキスト、推論、コードの生成。freeai_search: Exa / Tavily を使用したウェブ検索クエリ。freeai_embed: Voyage、Jina、Gemini を使用したベクトル埋め込みの生成。freeai_rerank: 検索拡張生成 (RAG) のための文書の再ランク付け。freeai_analyze_image: マルチモーダルビジョン分析。
オプションD: エージェンシックIDEスキル (@free-ai-gateway/skills)
Free-AI Gateway のエージェントスキルをIDEまたは自律コーディングアシスタントに直接インストールします。
# 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オプションE: ターミナルCLIツール (@free-ai-gateway/cli)
ターミナルまたはコマンドラインスクリプトから直接 Free-AI を使用します。
# 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🏛️ モノレポ構造
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🤝 コミュニティとガバナンス
📖 アーキテクチャ設計書: 内部システム設計とデータフローの深掘り解説。
🎓 開発者&学習ガイド: チュートリアル、プログラムによる使用方法、SDKパターン。
🗺️ 製品ロードマップ: 計画されたマイルストーン、分散状態、今後の機能。
💬 サポートガイド: トラブルシューティング、コミュニティディスカッション、ヘルプチャンネル。
🏛️ プロジェクトガバナンス: 意思決定プロセス、メンテナー役割、リリースポリシー。
✍️ 貢献ガイド: 新しいプロバイダアダプターを追加するためのステップバイステップの手順。
🔒 セキュリティポリシー: 脆弱性開示ガイドライン。
📜 行動規範: コミュニティ基準と期待事項。
👤 作者
開発・保守: ❤️を込めて Md. Mahedi Zaman Zaber。
📄 ライセンス
このプロジェクトはオープンソースであり、MITライセンスの下で利用可能です。
This server cannot be installed
Maintenance
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.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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