@lobstack/mcp
OfficialBased on the provided schema, this server lets an MCP client inspect Lobstack routing/models, run paid chat completions with receipts, and read spend/usage.
Preview how a prompt would be routed, including served model, tier, complexity, estimated cost, and named-model baseline comparison — no inference, no key, no cost.
List gateway models with tier, provider, context window, managed status, and USD per-million-token prices, flagging unpriced models as null.
Send a single prompt or full conversation through the gateway with optional model, system prompt, max tokens, and temperature; get the reply plus served/requested model, usage, receipt, quota, and dropped parameters.
Read organizational spend over 7d/14d/30d/90d, grouped by day/model/key/agent, with an
is_floorflag when totals are lower bounds.Note: the README also documents
lobstack_embeddingsandlobstack_web_search, but those tools are absent from the supplied server schema.
Click on "Deploy 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., "@@lobstack/mcp preview routing and cost for: summarise this changelog into three bullets"
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.
@lobstack-ai/mcp
An MCP server for the Lobstack API. One API key reaches chat models from Anthropic, OpenAI, Google and xAI, plus embeddings and web search, and every call comes back with a receipt: which model served it, how many tokens, what it cost.
Works in Claude Desktop, Claude Code, Cursor, Zed, or anything else that speaks the Model Context Protocol over stdio.
Try it without a key
lobstack_route_preview is unauthenticated. Install the server with no
credential at all and an agent can still ask "which model would this prompt go
to, and what would it cost":
npx -y @lobstack-ai/mcpAdd it to your client using one of the blocks below, leave env out, and ask:
Preview how Lobstack would route: "summarise this changelog into three bullets"
lobstack_models also works without a key on www.lobstack.ai. The other four
tools need one, minted in Console → API keys.
Related MCP server: io.github.0xzr/freellmpool
Install
Claude Desktop
~/Library/Application Support/Claude/claude_desktop_config.json on macOS,
%APPDATA%\Claude\claude_desktop_config.json on Windows:
{
"mcpServers": {
"lobstack": {
"command": "npx",
"args": ["-y", "@lobstack-ai/mcp"],
"env": {
"LOBSTACK_API_KEY": "lsk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
}
}
}Restart Claude Desktop. The six lobstack_* tools appear under the tools menu.
Cursor
~/.cursor/mcp.json for every project, or .cursor/mcp.json for one:
{
"mcpServers": {
"lobstack": {
"command": "npx",
"args": ["-y", "@lobstack-ai/mcp"],
"env": {
"LOBSTACK_API_KEY": "lsk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
}
}
}Claude Code
claude mcp add lobstack --env LOBSTACK_API_KEY=lsk_live_... -- npx -y @lobstack-ai/mcpZed
In settings.json, under context_servers:
{
"context_servers": {
"lobstack": {
"source": "custom",
"command": "npx",
"args": ["-y", "@lobstack-ai/mcp"],
"env": {
"LOBSTACK_API_KEY": "lsk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
}
}
}Tools
Tool | Costs money | Needs a key | Endpoint |
| No | No |
|
| No | No |
|
| Yes, per token |
|
|
| Yes, per input token |
|
|
| Yes, per search |
|
|
| No |
|
|
The intended order for an agent: lobstack_route_preview with the prompt it is
about to send (free), then lobstack_chat. lobstack_models when it needs a
model id or a rate. lobstack_spend to check what has already been spent.
Every tool description states its cost, what it needs, when to use a sibling
instead, and how to read its output, and every parameter has a description with
its range, default and an example. The annotations are accurate: the three
spending tools are readOnlyHint: false, idempotentHint: false (a repeat is
billed again), the other three are read-only and idempotent, and none is
destructive.
There is no tool for creating, rotating or revoking API keys. That stays in the
Console. There is also no "who am I" tool, because no key-authenticated
endpoint reports it; the allowance comes back as quota on every spending call
and as credit on lobstack_spend.
There is no streaming switch either. The server streams from the API (that is how the chat receipt arrives), but an MCP tool result is one message, so the agent gets the whole answer at once.
lobstack_route_preview
Scores a prompt against the same router the paid path uses and reports the model that would serve it, the capability tier, the complexity score, and the estimated cost. Runs no inference and spends nothing. Needs no API key. Rate-limited to ten a minute per IP address.
argument | type | notes |
| string, required | The prompt you are about to send. 1 to 8000 characters. Scored, never sent to a model. |
| string | A chat model id to compare against. Default |
| enum |
|
| integer 1 to 200000 | Default half the prompt's estimated tokens, at least 64. |
| integer ≥ 0 | Messages already in the conversation. Default 0. |
Token counts are estimates, roughly four characters per token. The billed
figure always comes from the provider's own usage block on the real request,
and the tool says so in every answer. A baseline is returned only when you
named a model and the router moved away from it; on auto it is null.
lobstack_models
The catalogue: model id, type (chat or embedding), label, tier, provider,
context window, embedding dimensions, and USD per million input and output
tokens.
argument | type | notes |
|
| Default both: chat rows first, embedding rows last. |
|
| Chat models only. |
|
|
|
The first entry is auto, which is Nex 1, the router. It carries
tier: "router" and a null price on purpose: its cost is whichever model it
picks. It is not counted in unpriced_count. Every other null price is a gap:
the registry cannot price that model, and it renders as —, not as free.
Embedding rows have an output price of 0 because embeddings have no output
tokens. The full catalogue is also public at https://www.lobstack.ai/models.
lobstack_chat
Sends a prompt or a conversation and returns the reply plus the receipt. Costs money on input and output tokens.
argument | type | notes |
| string | A single user message. Use this or |
| array |
|
| string | Default |
| string | Sent first, ahead of the conversation. |
| integer 1 to 200000 | Default 4096 (8192 for OpenAI GPT-5 and o-series models). Caps the worst-case cost. |
| number 0 to 2 | Not sent unless set. Some models do not accept it; |
| string | Who the call is for, for cost attribution. See Client tags. |
The reply and the receipt come back as two separate content blocks, so whatever consumes the answer does not get a price line concatenated onto it. The structured result carries:
{
"text": "...",
"model": { "requested": "claude-opus-5", "served": "claude-haiku-4-5", "routed": true },
"usage": { "prompt_tokens": 400, "completion_tokens": 140, "total_tokens": 540 },
"receipt": {
"request_id": "req_...",
"cost_usd": 0.0011,
"cost_display": "$0.001100",
"priced": true,
"savings": {
"amount_usd": 0.0044,
"label": "saved",
"named": true,
"baseline_model": "claude-opus-5",
"baseline_reason": "named"
}
},
"quota": { "meter": "spend", "remaining_usd": 16.75 },
"dropped_params": []
}lobstack_embeddings
Vectors for text, from OpenAI text-embedding-3-small (default, 1536
dimensions) or text-embedding-3-large (3072). Costs money on input
tokens. Not routed: auto means the small model, because vectors from
different models cannot be compared.
argument | type | notes |
| string, or array of 1 to 64 strings | Required. Each string is embedded separately and returned in the same order. |
|
| Default the small model. |
| integer | Shorten each vector. At most the model's own length; refused before any call if larger. |
| string | See Client tags. |
The API takes up to 2,048 inputs per call. This tool takes 64, because every
vector comes back into the agent's context. For bulk indexing, call the HTTP API
directly. The receipt is read from the x-lobstack-* headers: an empty
x-lobstack-cost-usd is reported as cost_usd: null, never 0.
lobstack_web_search
Web results from Brave Search's index through the Lobstack API: title, URL and a plain-text snippet each. Costs money, per search, not per token or per result: Brave's published price inside your plan's included usage and on the Free plan's credit, and that times the Lobstack rate past it. The current figure is on https://www.lobstack.ai/docs/gateway/search.
argument | type | notes |
| string, required | 1 to 400 characters after trimming. Lobstack logs its length, not its text. |
| integer 1 to 10 | Default 5. Fewer may come back. |
| string | See Client tags. |
The same query and count from the same organization within ten minutes may be
answered from a short cache: receipt.cache is "hit" and the cost is 0. A
402 or 503 means search will not run on Lobstack right now; the error text
tells the agent to use another search rather than retry in a loop.
lobstack_spend
What the organization has spent. Read-only and free. Requires a key holding the
usage:read scope.
argument | type | notes |
|
| Default |
|
| Default |
| string | Only calls for this client tag. |
Use it for budget monitoring (how much of the month is gone, which model or key drives it) and for cost attribution (spend per client tag or per agent).
The total is the Console's figure. /api/v1/usage returns two totals from
two tables: spend.cost_usd, from the billing ledger that the allowance and
invoices are read from and that the Console's Spend shows, and
summary.cost_usd, the request trace's own copy of each price, kept for older
callers. They are written separately and can disagree. This tool reports
spend.cost_usd (and each group's ledger_cost_usd) as cost_usd, with
cost_source: "ledger". Only when the ledger figure is null or missing does it
fall back to summary.cost_usd, set cost_source: "trace", and say so in the
output.
is_floor means "at least". Unpriced rows sum as zero, the only arithmetic
available, so a total that includes one is a lower bound. So is a total whose
read hit the row cap. When is_floor is true, report the figure as "at least
$X", never as the bill.
Routing savings are two figures, never one. When the API sends savings,
the tool shows named (saved on models you asked for, measured) and
plan_ceiling (what auto requests would have cost on the best model your
plan allows: a comparison, not a saving) on separate lines. It never adds them
together, and it never computes a saving client-side from a copy of the rate
card.
credit is passed through from the API: on a spend-metered plan, the Free
plan's weekly credit, any welcome credit and when it expires, included usage
this period, and purchased credit left.
Client tags
lobstack_chat, lobstack_embeddings and lobstack_web_search take an
optional client_tag: who the call is for, sent as x-lobstack-client-tag.
1 to 64 characters of lowercase a-z, 0-9, ., _ or -, starting with a
letter or digit. Read it back with lobstack_spend group_by: "client". A tag
set on the API key itself wins over the argument. A client with a hard monthly
budget that is spent refuses the call with 402 CLIENT_BUDGET_EXHAUSTED.
Errors
A failed call returns isError: true with the API's message, then a line
naming the error class, the HTTP status, the error_code when there is one,
and whether a retry can help:
monthly allowance exhausted
Error class: quota (HTTP 402, ALLOWANCE_EXHAUSTED). Do not retry: the allowance or a budget is spent until it is raised or resets.
The plan's included usage and credit are used. Top up or upgrade in Console → Billing.
Request id: 8f2b1e0c-...Class | Status | Retry? |
| 401, 403 | No. Fix the key or its scopes. |
| 402, 429 | 402 no. 429 yes, after |
| 400, 409, 422 | No. Fix the arguments. |
| 502, 503, other 5xx | Yes, with backoff, except |
| 408, 504 | Yes. The first attempt may have completed and been billed. |
| 500 | Once, then report the request id. |
The full list is at https://www.lobstack.ai/docs/gateway/errors.
Two rules about the numbers
A null cost is not zero. cost_usd: null means the API could not price
the call. It renders as unpriced, never as $0.00. Rendering it as $0.00
writes off a real charge, and that exact substitution ran for three months in
production.
baseline_reason decides what a saving may be called.
named— you asked for a model and got something cheaper. Like-for-like, and the only case labelledsaved.plan_ceiling— you sentauto, so the comparison is against the most expensive model your plan allows. Real, and not something you asked for: labelledvs ceiling, with the baseline model named next to it.missing — treated as unnamed. A receipt that does not say where its baseline came from does not get the flattering reading.
Configuration
variable | default | notes |
| none | Read once at startup. Never logged, never in a tool result. |
|
| The Lobstack API base URL. Change it only to point at a staging deployment. |
Use www, not the bare apex. lobstack.ai redirects to www.lobstack.ai,
and RFC 9110 §15.4
requires a client to drop Authorization across a host change — so the API
answers a perfectly good key with "missing credentials". This server rewrites
the apex and tells you it did, and refuses to follow any other 3xx rather than
send a request whose credential has been stripped.
The key
LOBSTACK_API_KEY is read from this process's environment and from nowhere
else. No tool takes a key, a token, or a base URL as an argument: a base URL
that can arrive as a tool argument is a credential that can be redirected by
whoever wrote the argument. Error text is scrubbed on the way out, including
text that came back from upstream.
This process holds a live credential for as long as your MCP client runs. The dependency list is the MCP SDK, zod, and what those two bring with them.
Development
npm install
npm run build
npm testThe tests run a real MCP client against the server over an in-memory transport,
and the server against a fake gateway over real HTTP. The fake gateway writes
its SSE stream in two pieces with the cut landing mid-frame, serves a model with
no price, and refuses any request to /route-preview that arrives carrying an
Authorization header — so a client that leaks a credential to a public
endpoint fails a test rather than shipping.
Publishing to the MCP Registry
server.json is what the Official MCP Registry
stores. PulseMCP lists a server once that registry accepts it, so this is the
publish that puts @lobstack-ai/mcp there. The registry stores metadata only.
.github/workflows/release.yml publishes the npm tarball when a v* tag is
pushed, and the registry then reads mcpName out of that tarball.
The registry name is io.github.Lobstack-ai/lobstack-mcp in both places GitHub
authentication checks: name in server.json, and mcpName in package.json.
A GitHub login can only publish under io.github.Lobstack-ai/. version in
server.json, the npm package entry inside it, and package.json are the same
string. The package is @lobstack-ai/mcp on https://registry.npmjs.org,
stdio, invoked as npx -y @lobstack-ai/mcp. LOBSTACK_API_KEY is optional
(isRequired: false, isSecret: true) because lobstack_route_preview runs
with no key.
One click
.github/workflows/publish-mcp.yml runs when a GitHub Release is published, and
from the Actions tab with Run workflow. It refuses to publish when the
versions disagree, waits until that version is on npm, then runs:
curl -L "https://github.com/modelcontextprotocol/registry/releases/latest/download/mcp-publisher_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz" | tar xz mcp-publisher
./mcp-publisher login github-oidc
./mcp-publisher publishlogin github-oidc is why the workflow has id-token: write. There is no
registry token to store.
On a laptop the publisher commands are the same, with the device-code login in place of OIDC:
./mcp-publisher login github
./mcp-publisher publishThe registry reads mcpName from the tarball already on npm, not from this
checkout. 0.1.3 was published before mcpName existed, and npm will not
accept a second upload of that version, so the first publish that succeeds is
the next one: bump package.json and server.json together, push the v* tag,
then publish the GitHub Release.
Licence
MIT
Available Tools
4 toolslobstack_chatChat through the gatewayA
Send a prompt or conversation through the Lobstack Gateway and get the reply plus a receipt: the model that actually served it, token counts, USD cost, and any saving with the reason it may be claimed. Model "auto" (the default) lets the router pick the cheapest model that can handle the prompt. This call spends money against the configured key's allowance.
Inputs: model, prompt, system, messages, +2 more. Returns: text, model, quota, usage, +2 more
lobstack_modelsList gateway modelsARead-onlyIdempotent
The models the Lobstack Gateway serves, with capability tier, provider, context window and USD price per million input and output tokens. A model the registry cannot price shows a null price, not zero.
Inputs: tier, provider. Returns: count, models, unpriced_count
lobstack_route_previewPreview routing and costARead-onlyIdempotent
Score a prompt and report which model the Lobstack router would serve it with, and what that would cost. Runs no inference, spends nothing, and NEEDS NO API KEY — use it to pick a model before calling lobstack_chat, or to show what the gateway does on a machine with no key configured. Token counts are estimates; the billed figure comes from the provider's usage block on the real call.
Inputs: prompt (required), plan_tier, requested_model, conversation_length, +1 more. Returns: tier, reason, routed, baseline, +10 more
lobstack_spendRead spend and usageARead-onlyIdempotent
What this organization has spent through the gateway over a range, broken down by day, model, key or agent, with request counts, tokens, error counts and latency percentiles. Requires an API key with the usage:read scope. Reports how many requests could not be priced, because a total that includes them is a floor.
Inputs: range, group_by. Returns: range, groups, enabled, message, +3 more
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool targets a clearly distinct concern: route_preview scores/routes without spending, models lists the catalog, chat performs the actual paid call, and spend reports usage. The overlap risk between route_preview and chat is explicitly resolved by descriptions clarifying one runs no inference while the other spends money.
All tools share a consistent 'lobstack_' prefix and are snake_case, so they scan as one family. Suffix styles vary though — route_preview is verb_noun while models, chat and spend are bare nouns/verbs — a minor inconsistency but still readable and predictable.
Four tools is on the lean side but each earns its place and maps to a real workflow stage (discover, preview, execute, audit). Slightly thin, though appropriate for a focused gateway server.
The surface covers the core lifecycle: model discovery, routing/cost preview, the paid completion call, and spend auditing. Minor gaps exist (e.g. no embeddings, streaming controls, or key/scope management), but agents can accomplish the primary gateway tasks without dead ends.
Maintenance
Related MCP Connectors
Hosted MCP server for LLM cost estimation, model comparison, and budget-aware routing.
Connect MCP clients to 2,000+ AI models without managing provider API keys.
AI gateway FinOps, live model pricing, balance alerts, usage exports, and reseller ops via MCP.
LLM cost optimization gateway, repo token-waste auditor & model arbitrage MCP server.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables MCP clients to browse a live catalog of 100+ models with pricing, rankings and measured uptime, check credits and spend, and send chat completions through an OAuth-authenticated, per-connection key capped by a spend limit. Read tools are free, and paid calls are priced and approved before any credit is used.MIT
- FlicenseNot gradedqualityAmaintenanceEnables MCP clients to discover and use pooled free LLM chat routes and models across multiple providers through an OpenAI-compatible gateway, with automatic failover and keyless operation when available. It supports routing for coding agents and other tools without requiring separate provider integrations.-
- FlicenseNot gradedqualityAmaintenanceExposes an MCP interface that lets agents route chat requests across a pooled catalog of free LLM provider routes through a single OpenAI-compatible endpoint, with automatic failover, usage tracking, and keyless start when an enabled route is available. It also lets clients query live capacity and provider health, capacity status, and available models without leaving the agent workflow.-
- FlicenseNot gradedqualityAmaintenanceEnables MCP clients to query and chat through a pool of free LLM providers behind a single OpenAI-compatible gateway. It exposes routing across enabled keyless, free-tier, and pinned provider routes, with automatic failover and model catalog access.-