llmkit-mcp-server
@f3d1/llmkit-mcp-server
针对 Claude Code、Cline、Cursor 和 Claude Desktop 的 AI 成本跟踪工具。提供 11 种工具,用于跨 11 家 LLM 提供商进行支出查询、预算管理、本地会话成本统计和代理归因分析。
这是 LLMKit 的一部分,LLMKit 是一个具有成本跟踪和预算执行功能的开源 API 网关。
快速开始
添加到你的 .mcp.json (Claude Code) 或 .cursor/mcp.json (Cursor) 中:
{
"mcpServers": {
"llmkit": {
"command": "npx",
"args": ["@f3d1/llmkit-mcp-server"],
"env": {
"LLMKIT_API_KEY": "llmk_your_key_here"
}
}
}
}本地工具 (llmkit_local_*) 无需 API 密钥即可立即使用。它们会自动检测你机器上的 Claude Code、Cline 和 Cursor 数据。对于代理工具,请在 仪表板 创建一个免费密钥。
Related MCP server: Langfuse MCP Server
工具
代理工具(需要 API 密钥)
工具 | 功能 |
| 指定时间段内的支出、请求数和热门模型 |
| 按提供商、模型、会话或日期分组的成本查询 |
| 预算限额和剩余余额 |
| 包含成本、持续时间和模型的近期会话摘要 |
| 所有密钥的状态和创建日期 |
| 带有响应时间的代理 ping 测试 |
本地工具(无需密钥)
自动检测已安装的 AI 编码工具并汇总所有数据。
工具 | 功能 |
| 所有已检测工具的当前会话成本 |
| 所有项目和会话的累计成本 |
| 提示词缓存节省分析 |
| 月度预测与最大订阅额度对比 |
| 子代理成本归因 (Claude Code) |
SessionEnd 钩子
在 Claude Code 退出时自动记录会话成本:
{
"hooks": {
"SessionEnd": [
{
"type": "command",
"command": "npx @f3d1/llmkit-mcp-server --hook"
}
]
}
}环境变量
变量 | 必需 | 描述 |
| 否 | 代理工具的 API 密钥。本地工具无需此项即可工作。 |
| 否 | 代理 URL(默认为托管服务) |
| 否 | 覆盖 Cline 数据目录路径 |
支持的工具
本地工具可检测以下数据:
Claude Code (
~/.claude/projects/)Cline (VS Code, Insiders, VSCodium, Cursor, Windsurf globalStorage)
WSL 安装(通过 Windows 上的 UNC 路径扫描所有发行版)
VS Code Server / Cursor Server (远程 SSH/WSL 扩展)
许可证
MIT
Available Tools
11 toolsllmkit_budget_statusARead-onlyIdempotent
Check budget limits and remaining balance
Inputs: budgetId. Returns: budgets
llmkit_cost_queryBRead-onlyIdempotent
Query cost breakdown grouped by provider, model, session, or day
Inputs: groupBy (required), days, provider, model. Returns: groupBy, days, breakdown
llmkit_healthARead-onlyIdempotent
Check proxy health and response time
Inputs: no named parameters. Returns: status, responseTimeMs
llmkit_list_keysARead-onlyIdempotent
List all API keys with status and creation date
Inputs: no named parameters. Returns: keys
llmkit_local_agentsARead-onlyIdempotent
Subagent cost attribution for the current Claude Code session. Shows which agents cost the most.
Inputs: no named parameters. Returns: sessionId, totalCostUsd, mainConversationCostUsd, subagentsTotalCostUsd, +2 more
llmkit_local_cacheARead-onlyIdempotent
Cache savings analysis across all detected AI coding tools. Shows how much prompt caching saved.
Inputs: no named parameters. Returns: savings, totalSavedUsd
llmkit_local_forecastARead-onlyIdempotent
Monthly cost projection based on local AI tool usage. Compares to Max subscription.
Inputs: no named parameters. Returns: projectedMonthlyUsd, dailyAverageUsd, totalTrackedUsd, totalSessions, +1 more
llmkit_local_projectsARead-onlyIdempotent
Cumulative cost across all projects and sessions from all detected AI coding tools, ranked by spend.
Inputs: no named parameters. Returns: projects, totalCostUsd
llmkit_local_sessionARead-onlyIdempotent
Current session cost across all detected AI coding tools (Claude Code, Cline). No API key needed.
Inputs: no named parameters. Returns: sessions, totalCostUsd, sourceCount
llmkit_session_summaryARead-onlyIdempotent
Get recent proxy sessions with cost, duration, and models used
Inputs: sessionId, limit. Returns: sessions
llmkit_usage_statsCRead-onlyIdempotent
Get usage statistics (spend, requests, top models) for a time period
Inputs: period. Returns: period, requests, totalSpendUsd, inputTokens, +4 more
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 11 tools
Tools are mostly distinct, targeting different aspects like budget, cost breakdown, health, keys, local session, etc. However, llmkit_cost_query, llmkit_usage_stats, and llmkit_session_summary have overlapping purposes (cost/spend/usage data) which could cause some confusion.
All tools follow a consistent pattern with the 'llmkit_' prefix and descriptive noun phrases separated by underscores, e.g., llmkit_budget_status, llmkit_cost_query. No mixing of conventions.
With 11 tools, the count is well within the recommended 3-15 range. Each tool covers a distinct aspect of proxy cost monitoring and management, justifying its inclusion.
The tool surface covers major monitoring needs: health, budget, cost, keys, sessions, and local attribution. However, it lacks management capabilities (e.g., create/update keys or budgets) and could include actions like setting usage limits, which are minor gaps for a read-only analytics server.
Maintenance
Related MCP Connectors
Query cloud, AI and SaaS spend across 25+ providers: costs, budgets, anomalies, unit economics.
AI spend by team, developer and API key for Claude, OpenAI, Gemini and coding agents.
Track API spend, credit balances and runway across OpenAI, Anthropic, OpenRouter and 25 more.
FinOps assistant: query AWS, GCP and Azure cost, commitments, budgets and reports.
Related MCP Servers
- AlicenseCqualityDmaintenanceEnables interaction with Google Cloud services including billing cost analysis, log querying, and metrics monitoring through natural language commands. Provides comprehensive tools for managing GCP resources, analyzing costs, detecting anomalies, and retrieving operational insights.401Apache 2.0
- AlicenseBqualityDmaintenanceEnables querying Langfuse analytics, cost metrics, and usage data across multiple projects. Provides tools for trace analysis, model/service cost breakdowns, and daily usage trends through natural language queries.2473 npmMIT
- FlicenseNot gradedqualityDmaintenanceEnables querying and analyzing AWS cost and usage data through the AWS Cost Explorer API. Supports cost comparisons, forecasting, dimension filtering, and cost change driver analysis with streamable HTTP deployment to Amazon Bedrock Agentcore Runtime.-
- AlicenseBqualityCmaintenanceAn MCP server for unified cost tracking and analysis across AWS, OpenAI, and Anthropic. It enables users to query expenditures, compare costs across providers, and analyze usage trends through natural language.10MIT