Skip to content

MCP Server

Overview

Floopy exposes an MCP (Model Context Protocol) server at /mcp. Any MCP-compatible client — Claude Desktop, Cursor, Windsurf, or a custom agent — can connect to it and use Floopy tools directly within an agentic loop.

This means your AI assistant can route LLM requests through Floopy, inspect usage analytics, estimate costs, and list available models — all via standard MCP tool calls.


Authentication

Authenticate with an MCP Token passed as a Bearer token in the Authorization header:

Authorization: Bearer mcp_tbac_your_token_here

Generate MCP Tokens in the dashboard under MCP > MCP Tokens. Each token is scoped to specific permissions (e.g., read-only analytics, model listing only) and tied to your organization. No API key is needed — the MCP Token identifies your org automatically.

See MCP Tokens for details on scopes, expiration, and revocation.


Available Tools

route_llm_request

Routes an LLM completion request through Floopy’s gateway. Applies your configured routing rules, caching, rate limits, and firewall.

Input schema:

{
"model": "gpt-4o",
"messages": [
{ "role": "user", "content": "Explain async/await in Rust." }
],
"temperature": 0.7,
"max_tokens": 1024,
"stream": false
}

Output schema:

{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"model": "gpt-4o",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "..." },
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 18,
"completion_tokens": 312,
"total_tokens": 330
}
}

list_models

Returns all AI models available through your Floopy account, filtered by provider and capability.

Input schema:

{
"provider": "openai",
"capability": "chat"
}

Both fields are optional. Omit them to list all models.

Output schema:

{
"models": [
{
"id": "gpt-4o",
"provider": "openai",
"capabilities": ["chat", "vision", "tool_use"],
"context_window": 128000,
"cost_per_million_input_tokens": 2.50,
"cost_per_million_output_tokens": 10.00
}
]
}

estimate_cost

Estimates the cost of a completion request before sending it. Useful for budget-aware agents.

Input schema:

{
"model": "gpt-4o",
"messages": [
{ "role": "user", "content": "Summarize this 10-page document..." }
],
"max_tokens": 500
}

Output schema:

{
"model": "gpt-4o",
"estimated_input_tokens": 2048,
"estimated_output_tokens": 500,
"estimated_cost_usd": 0.0256,
"cheaper_alternatives": [
{
"model": "gpt-4o-mini",
"estimated_cost_usd": 0.00040,
"savings_pct": 98.4
}
]
}

get_analytics

Fetches usage analytics for your account over a specified time range.

Input schema:

{
"from": "2026-04-01T00:00:00Z",
"to": "2026-04-07T23:59:59Z",
"group_by": "model"
}

group_by accepts: model, provider, api_key, day.

Output schema:

{
"total_requests": 14820,
"total_tokens": 9420000,
"total_cost_usd": 23.55,
"cache_hit_rate": 0.34,
"rows": [
{
"key": "gpt-4o",
"requests": 4200,
"tokens": 3100000,
"cost_usd": 12.40
}
]
}

Connecting Your Client

Claude Code supports HTTP Streamable natively:

Terminal window
claude mcp add floopy \
--transport http \
--url https://api.floopy.ai/mcp \
--header "Authorization: Bearer mcp_tbac_your_token_here"

Replace mcp_tbac_your_token_here with an MCP Token generated in the dashboard.


Connecting Programmatically

import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
const client = new Client({ name: "my-agent", version: "1.0.0" });
await client.connect(
new StreamableHTTPClientTransport(
new URL("https://api.floopy.ai/mcp"),
{
headers: {
Authorization: `Bearer ${process.env.FLOOPY_API_KEY}`,
},
}
)
);
const result = await client.callTool({
name: "estimate_cost",
arguments: {
model: "gpt-4o",
messages: [{ role: "user", content: "Hello, world!" }],
max_tokens: 100,
},
});
console.log(result.content);

Error Codes

HTTP StatusMeaning
401Missing or invalid API key / MCP Token
403Token lacks required scope for this tool
429Rate limit exceeded
400Invalid tool input (see error message for details)
500Gateway error — open a support ticket