> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.alephant.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.alephant.io/_mcp/server.

# 简介

> Alephant MCP 的模式、工具和提示词概览

**Alephant MCP Server** 是面向 Alephant BYO-KEY 的本地 Model Context Protocol 服务器。它让 Cursor、Claude Desktop、Claude Code、Codex、OpenCode 等 AI 客户端及其他 MCP 主机无需离开助手工作流，即可查询 FinOps 数据，并在获得授权后管理工作区密钥和策略。

该软件包以 `@alephantai/mcp` 发布，并提供 `alephant-mcp` 二进制文件。当前实现通过本地 stdio 传输运行。

## Alephant MCP 的功能

Alephant MCP 为 AI 助手提供一个受控接口来访问 Alephant 的 SaaS API：

* **使用量和成本分析**：使用量汇总、每日成本趋势、模型级成本、滚动 24 小时快照和时间序列。
* **预算可见性**：VK 模式下按密钥范围查看预算状态，Manager 模式下查看工作区预算状态。
* **工作区管理**：Manager 模式下的虚拟密钥管理、成员、部门、代理、订阅详情和预算策略。
* **FinOps 工作流**：用于审计、优化、工作区健康检查和成本深度分析的内置提示词。

## 执行模式

Alephant MCP 在启动时根据环境变量选择其权限模式。

| 模式            | 凭据                                       | 范围                      | 工具数量 |
| ------------- | ---------------------------------------- | ----------------------- | ---- |
| **虚拟密钥 (VK)** | `ALEPHANT_VIRTUAL_KEY`                   | 限定为一个虚拟密钥的只读 Cockpit 数据 | 8    |
| **Manager**   | `ALEPHANT_PAT` + `ALEPHANT_WORKSPACE_ID` | 全工作区读写管理                | 27   |

如果设置了 `ALEPHANT_PAT`，则 Manager 模式优先。如果未提供任一凭据集，服务器会报错退出，不会回退到模拟数据。

## MCP 功能面

当前服务器注册了 **工具**和**提示词**。

### 共享工具

两个模式均可用：

* `check_alephant_connection`
* `get_usage_summary`
* `get_daily_costs`
* `get_cost_by_model`
* `list_available_models`

### 仅 VK 模式工具

* `get_my_scope`
* `get_my_budget`
* `get_my_recent_requests`

### 仅 Manager 模式工具

* 虚拟密钥：`list_virtual_keys`、`create_virtual_key`、`update_key_budget`、`revoke_virtual_key`
* 工作区分析：`get_workspace_overview`、`get_workspace_budget_status`、`get_live_24h`、`get_usage_timeseries`、`get_sparklines`
* 实体：`list_agents`、`get_agent_analytics`、`list_members`、`get_member_analytics`、`list_departments`、`get_department_analytics`
* 计费和策略：`get_subscription_info`、`set_budget_policy`
* 复合 FinOps 分析：`diagnose_cost_anomaly`、`get_executive_dashboard`、`drill_down_spend`、`find_idle_resources`、`compare_entity_periods`

此 MCP 构建未包含 `get_request_logs`，因为后端路由仅支持 JWT。

### 提示词

| 提示词                      | 模式           | 用途               |
| ------------------------ | ------------ | ---------------- |
| `cost_audit_report`      | VK + Manager | 结构化的周度、月度或季度成本审计 |
| `cost_optimization`      | Manager      | 按优先级排列的成本优化建议    |
| `workspace_health_check` | Manager      | 快速或彻底的工作区健康评估    |
| `cost_deep_dive`         | Manager      | 工作区、部门或代理支出的根因分析 |

## 典型工作流

向助手提出自然语言问题，并在答案依赖实时使用量、预算、密钥、部门、代理或模型数据时，指示它使用已启用的 Alephant MCP 工具。

示例：

> 使用 Alephant MCP 展示最近 30 天的模型成本，识别任何异常，并推荐前三项行动。

在 Manager 模式下，助手可以组合 `get_cost_by_model`、`diagnose_cost_anomaly`、`drill_down_spend` 和 `find_idle_resources`，生成由数据支撑的 FinOps 报告。