io.github.timmx7/styx-mcp-server

平台与服务

by timmx7

用于 Styx 的 MCP server,可在 OpenAI、Anthropic、Google 和 Mistral 之间进行智能路由。

什么是 io.github.timmx7/styx-mcp-server

用于 Styx 的 MCP server,可在 OpenAI、Anthropic、Google 和 Mistral 之间进行智能路由。

README

<div align="center"> <h1>⚡ Styx</h1> <p><strong>The MCP-Native AI Gateway</strong></p> <p>Route requests to any AI provider through one universal endpoint.<br/> Self-hosted. Open source. BYOK.</p> <!-- Badges -->

<a href="LICENSE"><img src="https://img.shields.io/badge/license-Apache%202.0-blue.svg" /></a> <a href="https://github.com/timmx7/styx/stargazers"><img src="https://img.shields.io/github/stars/timmx7/styx" /></a> <a href="https://github.com/timmx7/styx/issues"><img src="https://img.shields.io/github/issues/timmx7/styx" /></a>

</div>

What is Styx?

Styx is an open-source AI gateway that sits between your app and AI providers. Send requests to OpenAI, Anthropic, Google, or Mistral — all through one OpenAI-compatible endpoint. Bring your own API keys, self-host on your infra, and get full visibility into every request.

The first AI gateway with native MCP (Model Context Protocol) support.

python
from openai import OpenAI

client = OpenAI(
    api_key="your-styx-api-key",
    base_url="http://localhost:8080/v1",  # ← Only change needed
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello from Styx"}],
)

Features

  • 🔌 MCP Native — Built-in MCP server. Connect Claude Code or Cursor in one command
  • 🔀 Universal Routing — One OpenAI-compatible endpoint for all providers
  • 🤖 styx:auto — Intelligent model routing: use "model": "styx:auto" and let Styx pick the right model based on request complexity
  • 🔑 BYOK — Bring your own API keys, encrypted at rest (Fernet/AES)
  • 📊 Dashboard — Track requests, costs, latency per project and model
  • 🔄 Fallbacks — Auto-failover between providers with circuit breakers
  • 💰 Billing — Built-in subscription and credit-based billing (Stripe)
  • 🧠 Semantic Cache — Similar questions return cached responses instantly
  • Smart Routing — ML classifier routes to the optimal model for each request
  • 🐳 Self-Hosted — Docker Compose, 5-minute setup
  • 🔒 Secure — HMAC key hashing, Fernet encryption, rate limiting, TLS

Prerequisites

  • Docker Engine 24+ and Docker Compose v2
  • At least one AI provider API key (OpenAI, Anthropic, Google, or Mistral)
  • Supabase account (free tier) — only for production mode (not needed for dev mode)

Quick Start

Option A: Setup Wizard (recommended)

bash
git clone https://github.com/timmx7/styx.git
cd styx
./setup.sh                 # interactive wizard, generates .env
docker compose up -d --build   # first build: ~15-20 min; subsequent starts: ~60s

The wizard lets you choose between:

  • Dev mode — No Supabase needed, no authentication, instant start
  • Production mode — Full Supabase auth, account creation, API keys

Option B: Manual Setup

bash
git clone https://github.com/timmx7/styx.git
cd styx
cp .env.example .env

Edit .env with:

  1. Set SKIP_AUTH=true for dev mode, or configure Supabase for production
  2. At least one AI provider key (e.g., OPENAI_API_KEY)
bash
docker compose up -d --build   # first build: ~15-20 min; subsequent starts: ~60s

Access Points

Connect Claude Code

bash
claude mcp add styx -- npx styx-mcp

Connect Cursor

Add to .cursor/mcp.json:

json
{
  "styx": {
    "command": "npx",
    "args": ["styx-mcp"],
    "env": { "STYX_API_KEY": "your-key" }
  }
}

Send your first request

bash
curl -X POST http://localhost:8080/v1/chat/completions \
  -H "Authorization: Bearer YOUR_STYX_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [{"role": "user", "content": "Hello from Styx"}]
  }'

Dev mode: skip the Authorization header — requests are accepted without an API key.

Use with any OpenAI SDK

typescript
// Node.js / TypeScript
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "your-styx-key",
  baseURL: "http://localhost:8080/v1",
});
python
# Python
from openai import OpenAI

client = OpenAI(
    api_key="your-styx-key",
    base_url="http://localhost:8080/v1",
)

Supported Providers

ProviderModelsStatus
OpenAIgpt-4.1, gpt-4.1-mini, gpt-4o, gpt-4o-mini, o3, o4-mini
Anthropicclaude-sonnet-4, claude-3-5-sonnet, claude-3-5-haiku, claude-3-haiku
Googlegemini-2.5-pro, gemini-2.5-flash, gemini-2.5-flash-lite, gemini-2.0-flash
Mistralmistral-large, mistral-medium-3, mistral-small, codestral
Azure OpenAISame as OpenAI models, via Azure deployments

Auto-routing: Any model matching the provider prefixes above (gpt-*, claude-*, gemini-*, mistral-*, o3*, o4*) is routed automatically — even models released after your last config update.

Architecture

code
┌─────────┐     ┌──────────────┐     ┌───────────────┐
│  Client  │────▶│  Go Router   │────▶│  AI Provider  │
│  (app)   │◀────│  (port 8080) │◀────│  (OpenAI...)  │
└─────────┘     └──────┬───────┘     └───────────────┘
                       │
                ┌──────▼───────┐
                │ Python API   │
                │ (port 8000)  │
                │ Auth/Billing │
                └──────┬───────┘
                       │
          ┌────────────┼────────────┐
          │            │            │
    ┌─────▼──┐  ┌──────▼──┐  ┌─────▼──┐
    │Postgres│  │  Redis   │  │ Next.js│
    │  (DB)  │  │ (cache)  │  │ (UI)   │
    └────────┘  └─────────┘  └────────┘

Request flow:

code
Client request
    │
    ▼
Go Router (:8080) ──▶ Cache check ──▶ HIT? Return instantly
    │                                   MISS? Continue...
    ▼
Budget check ──▶ OVER LIMIT? Block + alert
    │              OK? Continue...
    ▼
Route to best provider (OpenAI / Anthropic / Google / Mistral)
    │
    ▼
Provider error? ──▶ Automatic fallback (circuit breaker)
    │
    ▼
Response to client + log to ClickHouse + update Redis counters

Project Structure

code
styx/
├── router/          # Go reverse proxy — the fast path (<10ms overhead)
├── backend/         # Python FastAPI — auth, billing, business logic
├── dashboard/       # Next.js + Tailwind — web dashboard
├── classifier/      # ML request classifier (complexity scoring)
├── cache-service/   # Semantic cache (Qdrant + sentence-transformers)
├── sdk/             # Python & Node.js client SDKs
├── packages/        # MCP server, gateway CLI
├── infra/           # Docker, Helm, K8s, k6 load tests, Prometheus
└── docker-compose.yml

Comparison

FeatureStyxOpenRouterLiteLLMPortkey
MCP Native
Self-Hosted
Open Source✅ Apache 2.0
Dashboard✅ FullBasic
BYOK✅ Encrypted
Semantic Cache
Smart Routing✅ ML
Circuit Breaker
One-Command InstallN/AN/A

Claude Code Plugin

Install the Styx plugin directly in Claude Code:

code
/plugin install styx@claude-plugin-directory

Or browse: /plugin > Discover > styx

This gives you /styx:setup, /styx:status, and the @styx-ops agent for managing your gateway from Claude Code.

MCP Connector

Styx includes a native MCP server. Connect it to Claude, Cursor, or any MCP-compatible client.

Local (stdio — requires npx)

Claude Code:

bash
claude mcp add styx -- npx styx-mcp

Cursor: Add to .cursor/mcp.json:

json
{
  "styx": {
    "command": "npx",
    "args": ["styx-mcp"],
    "env": { "STYX_API_KEY": "your-key" }
  }
}

Remote MCP Server

Connect to a hosted Styx instance without local installation:

Claude.ai / Claude Desktop: Settings > Connectors > Add custom connector > URL: https://mcp.styxhq.com/mcp

Claude Code:

bash
claude mcp add --transport http styx https://mcp.styxhq.com/mcp

See docs/DEPLOY_MCP_REMOTE.md for self-hosting the remote MCP server.

Examples

Check gateway health

Prompt: "Check if my AI gateway is healthy and which providers are connected" → Styx checks all provider connections, returns status and latency per provider, flags any issues.

Analyze spending

Prompt: "How much have I spent on AI APIs this month?" → Styx aggregates usage across providers, returns cost breakdown by model, shows cache savings.

Create a scoped API key

Prompt: "Create an API key for the marketing team limited to 1000 requests/day" → Styx generates a rate-limited key, returns the key and its configuration.

Contributing

We welcome contributions! Please see CONTRIBUTING.md.

License

Apache 2.0 — see LICENSE for details.

Links

常见问题

io.github.timmx7/styx-mcp-server 是什么?

用于 Styx 的 MCP server,可在 OpenAI、Anthropic、Google 和 Mistral 之间进行智能路由。

相关 Skills

Slack动图

by anthropics

Universal
热门

面向Slack的动图制作Skill,内置emoji/消息GIF的尺寸、帧率和色彩约束、校验与优化流程,适合把创意或上传图片快速做成可直接发送的Slack动画。

帮你快速做出适配 Slack 的动图,内置约束规则和校验工具,少踩上传与播放坑,做表情包和演示都更省心。

平台与服务
未扫描165.3k

MCP构建

by anthropics

Universal
热门

聚焦高质量 MCP Server 开发,覆盖协议研究、工具设计、错误处理与传输选型,适合用 FastMCP 或 MCP SDK 对接外部 API、封装服务能力。

想让 LLM 稳定调用外部 API,就用 MCP构建:从 Python 到 Node 都有成熟指引,帮你更快做出高质量 MCP 服务器。

平台与服务
未扫描165.3k

接口测试套件

by alirezarezvani

Universal
热门

扫描 Next.js、Express、FastAPI、Django REST 的 API 路由,自动生成覆盖鉴权、参数校验、错误码、分页、上传与限流场景的 Vitest 或 Pytest 测试套件。

帮你把API与集成测试自动化跑顺,减少回归漏测;能力全面,尤其适合复杂接口场景的QA团队。

平台与服务
未扫描23.5k

相关 MCP Server

Slack 消息

编辑精选

by Anthropic

热门

Slack 是让 AI 助手直接读写你的 Slack 频道和消息的 MCP 服务器。

这个服务器解决了团队协作中需要 AI 实时获取 Slack 信息的痛点,特别适合开发团队让 Claude 帮忙汇总频道讨论或发送通知。不过,它目前只是参考实现,文档有限,不建议在生产环境直接使用——更适合开发者学习 MCP 如何集成第三方服务。

平台与服务
89.1k

by netdata

热门

io.github.netdata/mcp-server 是让 AI 助手实时监控服务器指标和日志的 MCP 服务器。

这个工具解决了运维人员需要手动检查系统状态的痛点,最适合 DevOps 团队让 Claude 自动分析性能数据。不过,它依赖 NetData 的现有部署,如果你没用过这个监控平台,得先花时间配置。

平台与服务
79.9k

by d4vinci

热门

Scrapling MCP Server 是专为现代网页设计的智能爬虫工具,支持绕过 Cloudflare 等反爬机制。

这个工具解决了爬取动态网页和反爬网站时的头疼问题,特别适合需要批量采集电商价格或新闻数据的开发者。不过,它依赖外部浏览器引擎,资源消耗较大,不适合轻量级任务。

平台与服务
71.9k

评论