invariant
Provides access to Google's Gemini AI models through the invariant API layer, enabling AI agents to leverage Gemini's capabilities as part of a unified API interface.
Supported deployment platform for self-hosted invariant instances, allowing users to run their own API provisioning layer with custom credentials.
Used via Upstash Redis for per-minute rate limiting and quota enforcement across all API providers in the invariant platform.
Used as the authentication and usage logging backend for the invariant platform, managing accounts, quotas, and user data for the API provisioning layer.
Provides Redis infrastructure for rate limiting and quota management in the invariant platform, ensuring API usage compliance across all integrated services.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@invariantwhat's the weather in Tokyo and current Bitcoin price?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Invariant
The agentic API provisioning layer. Your AI agent gets weather, stocks, health data, maps, and frontier LLMs from a single endpoint. invariant creates the accounts, manages the keys, enforces the quotas, and falls back when something breaks. You never touch a developer portal.
One key in. Every API out.
Why invariant exists
A useful AI agent needs to call ten different services. An LLM, a weather API, a stock ticker, a geocoder, a health database, a charity lookup. Building that today means:
Ten developer portals, ten signup forms, ten email confirmations
Ten API keys to rotate and secure
Ten different auth schemes, rate limits, and error shapes
Ten ways for a single call to fail, and no fallback when one does
invariant collapses all of it into one managed layer. You connect once over MCP or REST, and the provisioning, routing, quota accounting, and failover happen above your agent.
Provider catalog
Provider | Category | Rate Limit | Key needed? |
OpenFDA | Physical Health | 240 req/min | No |
Mental Health Resources | Mental Health | unlimited | No |
CoinGecko | Finance | ~50 req/min | No |
Finnhub | Finance | 60 req/min | Free signup |
Every.org | Social Impact | generous | Free signup |
OpenWeatherMap | Environment | 60 req/min | Free signup |
Anthropic Claude | AI | . | Paid |
Google Gemini | AI | 1,500 req/day | Free (AI Studio) |
HuggingFace | AI | generous | Free signup |
Geoapify | Maps | 3,000 req/day | Free, no card |
On the hosted instance invariant handles every "Free signup" row for you. You never see those portals. Self-hosted instances can bring their own keys via environment variables.
How it works
┌─────────────────────┐
│ Your AI Agent │
│ (Claude, Cursor, │
│ Codex, custom) │
└──────────┬──────────┘
│ MCP (JSON-RPC) or REST
│ single key: x-pl-key
▼
┌─────────────────────────────────┐
│ invariant │
│ ┌───────────────────────────┐ │
│ │ auth + quota │ │
│ │ (Supabase + Upstash) │ │
│ ├───────────────────────────┤ │
│ │ reasoning layer │ │
│ │ (recommend / compare) │ │
│ ├───────────────────────────┤ │
│ │ provider router + fall- │ │
│ │ back + usage logging │ │
│ └───────────────────────────┘ │
└──────────┬──────────────────────┘
│ managed upstream credentials
▼
OpenFDA . Mental Health . CoinGecko . Finnhub . Every.org
OpenWeatherMap . Anthropic . Gemini . HuggingFace . GeoapifyAccess modes
invariant exposes the same engine through two interfaces.
1. MCP (recommended for AI clients). JSON-RPC over HTTP at POST /api/mcp. Works with Claude Desktop, Cursor, Claude Code, Windsurf, Cline, Continue.dev, Codex CLI, Goose, and the OpenAI Responses API.
2. REST (for custom code). Plain HTTP endpoints if you are building your own integration:
Endpoint | Method | Purpose |
| GET | List every provider and its status |
| POST | Execute an action on a provider |
| POST | Ask invariant to pick the best provider for a goal |
| GET | Your current quota, tier, and per-provider breakdown |
| POST | MCP JSON-RPC endpoint (same tools, agent-friendly shape) |
Every endpoint requires an x-pl-key: pl_... header.
Getting started
1. Get your invariant key
Sign up at the hosted instance. You get one pl_... key. That is the only credential you ever see. Behind it, invariant is already holding every upstream account for you.
2. Connect your AI client
All clients connect to the same remote endpoint. No cloning, no building, no Node.js required.
URL: https://pclabs.dev/api/mcp
Header: x-pl-key: pl_your_key_hereClaude Code (CLI)
claude mcp add invariant --transport http https://pclabs.dev/api/mcp --header "x-pl-key: pl_your_key_here"Claude Desktop
Edit ~/Library/Application Support/Claude/claude_desktop_config.json (Mac) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"invariant": {
"type": "http",
"url": "https://pclabs.dev/api/mcp",
"headers": {
"x-pl-key": "pl_your_key_here"
}
}
}
}Restart Claude Desktop after saving.
claude.ai (web)
Settings → Integrations → Add custom integration. Paste the URL and set the x-pl-key header in the form. No file editing.
Cursor
Edit ~/.cursor/mcp.json (global) or .cursor/mcp.json (per project):
{
"mcpServers": {
"invariant": {
"url": "https://pclabs.dev/api/mcp",
"headers": {
"x-pl-key": "pl_your_key_here"
}
}
}
}Or via UI: Settings → Tools & Integrations → MCP → Add Server.
Windsurf
Edit ~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"invariant": {
"url": "https://pclabs.dev/api/mcp",
"headers": {
"x-pl-key": "pl_your_key_here"
}
}
}
}Or via UI: Cascade panel → MCP Servers → Configure.
Cline (VS Code extension)
Open the Cline sidebar
Click the MCP Servers tab (plug icon)
Add Server → HTTP
Paste
https://pclabs.dev/api/mcpas the URLAdd header
x-pl-key: pl_your_key_here
Continue.dev
Edit ~/.continue/config.json:
{
"mcpServers": [
{
"name": "invariant",
"transport": {
"type": "http",
"url": "https://pclabs.dev/api/mcp",
"headers": {
"x-pl-key": "pl_your_key_here"
}
}
}
]
}OpenAI Codex CLI
Edit ~/.codex/config.toml:
[mcp_servers.invariant]
type = "http"
url = "https://pclabs.dev/api/mcp"
[mcp_servers.invariant.headers]
x-pl-key = "pl_your_key_here"OpenAI Responses API
Pass the MCP server directly as a tool:
response = client.responses.create(
model="codex-mini-latest",
tools=[{
"type": "mcp",
"server_url": "https://pclabs.dev/api/mcp",
"headers": { "x-pl-key": "pl_your_key_here" }
}],
input="What crypto prices are available?"
)Goose (Block)
Edit ~/.config/goose/config.yaml:
extensions:
invariant:
type: mcp
enabled: true
transport: http
url: https://pclabs.dev/api/mcp
headers:
x-pl-key: pl_your_key_hereMCP tools
The MCP endpoint exposes four tools.
recommend
Describe what you need. invariant returns ranked providers with scores, reasoning, pricing, and availability. This is the agentic entry point. Agents should start here, not with query.
{
"need": "real-time crypto prices with no signup",
"priorities": ["no-auth", "cost"],
"budget": "free"
}compare
Side-by-side comparison of two or more providers on pricing, rate limits, strengths, and weaknesses.
{ "provider_ids": ["claude", "gemini"] }list_providers
Browse the catalog, optionally filtered by category: physical_health, mental_health, financial, social_impact, environment, ai, maps.
query
Execute a specific action against a specific provider. The low-level primitive that recommend ultimately calls into.
{
"provider_id": "coingecko",
"action": "price",
"params": { "ids": "bitcoin", "vs_currencies": "usd" }
}Self-hosting
You can run your own invariant instance if you want to bring your own upstream credentials or host on your own infrastructure.
Prerequisites
Node.js 18+
A Supabase project for accounts and usage logging. See migration.sql for the schema.
An Upstash Redis instance for per-minute rate limiting
Deploy to Railway
invariant runs as a single Node HTTP server defined in dev-server.ts, which mounts the route handlers in api/ plus the admin, signup, and waitlist routes. Railway auto-detects the start script, so no railway.toml or Procfile is required.
npm install
npm run build
npm start # runs dist/dev-server.js on $PORTPoint Railway at this repo and set the environment variables below in the Railway dashboard.
Environment variables
Platform (required):
Variable | Description |
| Supabase project URL |
| Supabase service role key (server-side only) |
| Upstash Redis REST URL |
| Upstash Redis REST token |
| Password gate for the admin API endpoints |
Upstream providers (optional). Omit a variable to disable that provider:
Variable | Provider |
| Anthropic Claude (console.anthropic.com) |
| Google Gemini (aistudio.google.com) |
| HuggingFace (huggingface.co/settings/tokens) |
| Finnhub (finnhub.io) |
| CoinGecko. Optional, boosts rate limit. |
| Every.org (partners.every.org) |
| OpenWeatherMap (openweathermap.org/api) |
| Geoapify (myprojects.geoapify.com) |
| OpenFDA. Optional, boosts rate limit. |
Providers without a configured key show Status: Not configured in list_providers and return a 503 when queried. OpenFDA and Mental Health Resources work with no key at all.
Provisioning keys
Keys live in Supabase, not in an env var. Apply migration.sql to your project to create the accounts and usage tables, then create accounts through the admin endpoints (gated by ADMIN_PASSWORD) or by inserting rows directly. Each account row holds a pl_... key, a tier, a monthly quota, and a per-minute rate.
Local development
cp .env.example .env # fill in your values
npm install
npx tsx dev-server.ts # HTTP server with hot-restart via tsxThe server listens on $PORT (defaults to 3000). Hit http://localhost:3000/api/providers with your x-pl-key header to sanity check.
To run the stdio MCP fallback instead (see below), use npm run dev.
Fallback: local stdio MCP
For MCP clients that cannot speak HTTP, the repo also ships a thin stdio proxy in src/ that forwards to a remote invariant backend:
npm install
npm run build{
"mcpServers": {
"invariant": {
"command": "node",
"args": ["/absolute/path/to/invariant/dist/index.js"],
"env": {
"PL_API_KEY": "pl_your_key_here",
"PL_BACKEND_URL": "https://pclabs.dev/api/mcp"
}
}
}
}MCP client env vars for the stdio path:
Variable | Required | Description |
| Yes | Your |
| No | Override backend URL. Default: |
Adding a provider
Create
lib/providers/my-provider.tsimplementing theProviderinterface from lib/providers/types.tsRegister it in lib/providers/registry.ts
Add any required env vars to .env.example
Add metadata to lib/reasoning/ so the
recommendtool can surface it
Scripts
npm run dev # stdio MCP server via tsx, no build
npm run build # compile TypeScript → dist/
npm start # run compiled standalone server (dist/dev-server.js)
npm test # run test.ts against local backendBuilt on MCP, Hono, Supabase, and Upstash Redis.
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
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/getinvariant/mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server