> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flexinference.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP 服务器

> 通过模型上下文协议将 Claude、Cursor 和其他代理连接到 FlexInference。

使用 FlexInference 模型上下文协议 (MCP) 服务器，让编码代理能够阅读文档并执行经批准的账户操作。它是一个远程、可流式传输的 HTTP 服务器，地址为：

```
https://mcp.flexinference.com/mcp
```

该服务器公开了两个工具组。文档工具无需登录即可运行。账户工具需要 OAuth 授权，每个工具对应一个范围，代理才能读取使用情况或管理密钥。

<Note>
  MCP 服务器独立于 `https://api.flexinference.com/v1` 处的推理 API。它从不运行推理，也从不查看您的提示或回复。它只处理文档和账户操作。
</Note>

## 连接

将服务器添加到任何支持远程 HTTP 服务器的 MCP 客户端，包括 Claude 和 Cursor。使用以下配置：

<CodeGroup>
  ```json mcp.json theme={null}
  {
    "mcpServers": {
      "flexinference": {
        "type": "http",
        "url": "https://mcp.flexinference.com/mcp"
      }
    }
  }
  ```

  ```bash Claude Code theme={null}
  claude mcp add --transport http flexinference https://mcp.flexinference.com/mcp
  ```
</CodeGroup>

首次调用账户工具时，会打开浏览器进行仪表板登录，然后显示一个包含请求范围的同意屏幕。批准或缩小范围后，客户端会存储令牌。文档工具不需要身份验证。

## 工具

### 文档工具（无需登录）

| 工具                    | 参数           | 功能                                                |
| --------------------- | ------------ | ------------------------------------------------- |
| `search_docs`         | `query` (必填) | 搜索 FlexInference 文档和完整的错误目录，并返回最佳匹配项及链接。          |
| `get_error_reference` | `code` (可选)  | 查找 FlexInference 错误代码的含义以及如何修复。省略 `code` 可列出所有代码。 |

### 账户工具（OAuth，每个工具一个范围）

| 工具                   | 范围             | 参数           | 功能                                  |
| -------------------- | -------------- | ------------ | ----------------------------------- |
| `get_usage_summary`  | `usage:read`   | 无            | 您的 flex 使用情况和节省金额，按模型细分。            |
| `list_api_keys`      | `keys:read`    | 无            | 您按名称、后四位和创建日期列出的活动 API 密钥。绝不显示完整密钥。 |
| `create_api_key`     | `keys:write`   | `name` (必填)  | 创建一个新的 `flex_live_` 密钥。完整密钥将返回一次。   |
| `revoke_api_key`     | `keys:write`   | `keyId` (必填) | 按 ID 撤销密钥。                          |
| `get_byok_status`    | `byok:status`  | 无            | 哪些提供商有密钥存档，每个提供商显示“是”或“否”。绝不显示密钥。   |
| `get_billing_status` | `billing:read` | 无            | 您的支付方式（仅品牌和后四位）、账户状态、累计佣金和下次账单日期。   |

## 身份验证和范围

服务器针对与仪表板相同的身份系统实现 OAuth 2.1，因此代理映射到同一个组织。每个账户工具都需要一个且仅一个范围。同意屏幕允许您批准或缩小请求的范围。

服务器不使用 cookie 或服务器端会话。每次工具调用都携带自己的令牌，每个工具在读取或更改数据之前都会检查其范围。

| 范围             | 授予                      |
| -------------- | ----------------------- |
| `docs:read`    | 搜索文档并阅读错误目录。授予所有人，无需登录。 |
| `usage:read`   | 读取您的使用情况和节省金额。          |
| `keys:read`    | 列出您的 API 密钥。            |
| `keys:write`   | 创建和撤销 API 密钥。           |
| `byok:status`  | 读取哪些提供商有密钥存档。           |
| `billing:read` | 读取您的账单状态。               |

<Warning>
  MCP 服务器绝不接受原始提供商密钥。BYOK 密钥以加密形式存储，不会按请求发送。BYOK 没有写入范围，也没有工具接受 `sk-...`、`AIza...` 或 `sk-ant-...` 值。`get_byok_status` 仅报告每个提供商的“是”或“否”。请在[仪表板](https://www.flexinference.com/dashboard)上添加或轮换提供商密钥。
</Warning>
