Repository navigation
TokenRouter 0.4.0
TokenRouter 0.4.0 adds permission-scoped MCP administration, protocol selection for group availability probes, and a DOMPurify security update.
Upgrade notes
- Upgrade the backend and frontend together. Migrations 300 and 301 add MCP access-token storage and a
skip_browser_confirmationfield that defaults tofalse. Existing administrator accounts, login credentials, and gateway API keys remain valid. Back up PostgreSQL and verify restoration before upgrading. Rolling back the binary leaves the new table in place and makes MCP unavailable; temporary confirmations and files expire automatically. - To use MCP, forward
/mcpto the main application and configure the same fixedTOTP_ENCRYPTION_KEY(ortotp.encryption_key) on every instance. Keep that key with your database backups: it is required to create or copy tokens and recover their encrypted credentials. Configurefrontend_urlfor public browser-confirmation links and allow the intended browser origins. MCP uses dedicated Bearer tokens, with no MCP OAuth authorization server. - Existing availability probes keep automatic protocol selection. When an enabled probe specifies a protocol, that protocol must remain allowed by its group and supported by the probe runner. Re-select the protocol or disable the probe before removing that entry from the group.
- Internal diagnostics, backend error messages, and provider-test output use English. Update log searches or integrations that match the previous Chinese text. Interface notifications continue to use the selected language; raw upstream errors and administrator-defined messages retain their supplied text.
Security updates
- Upgrade DOMPurify from 3.4.14 to 3.4.17 in the frontend dependency and override. This includes the fixes for GHSA-cg2g-xh64-v4q7 and GHSA-mrv2-3pqr-j5jr. TokenRouter uses DOMPurify to sanitize Markdown pages, announcements, payment instructions, and SVG icons.
New features
- Connect management agents through Streamable HTTP at
/mcp. Four tools,search_operations,describe_operation,read_operation, andexecute_operation, discover and run granted management operations using the existing HTTP authorization, validation, rate limiting, and business handlers. Interrupted writes report an unknown outcome and are not automatically retried. - Manage MCP tokens at
/admin/mcp: create, copy, edit, disable, and revoke credentials with expiry dates and exact operation grants. Four permission presets cover read-only queries, gateway operations, users and subscriptions, or all current management operations. Saved grants do not expand when an upgrade adds operations, and concurrent token edits reject stale settings. - Review sensitive MCP actions in the administrator browser before execution. Confirmations expire after ten minutes and bind the requesting token, its settings, and the exact action. A per-token option can skip this confirmation, disabled by default; operations requiring recent two-factor verification or interactive browser authorization still follow those requirements.
- Upload JSON request bodies and receive sensitive exports, generated credentials or codes, binary results, and large responses through protected files. Files expire after ten minutes, check the owner and current token permissions, and retain download filenames. OAuth and similar interactive provider setup continue in the browser; large backup downloads use the existing streaming handler.
- Trace MCP activity in audit logs by token and operation, including browser continuations, credential copies, and protected downloads. Search by token prefix, open the token's audit view, and download an OpenAPI 3.1 description of the registered management API.
- Read stored Anthropic OAuth and SetupToken usage through
GET /api/v1/admin/providers/:id/usage/passiveand theproviders.usage.passive.listMCP operation. Active usage refreshes and Grok quota probes use the execution tool because they can update provider status or scheduling. - Choose an availability-probe entry protocol from Messages, Responses, Chat Completions, Gemini GenerateContent, SystemOne, or image generation, subject to the group's allowed protocols. Provider selection follows the group's model mappings and protocol-conversion rules, and the test uses the resolved upstream endpoint and model attributes.
- Independently show or hide the maximum-discount and multiplier tags in each marketplace group header. Both remain visible by default; the controls affect presentation and retain the group's pricing and discount data.
Improvements
- Update the built-in Grok CLI identity and User-Agent version to
1.0.67. Requests tocli-chat-proxy.grok.comuse the built-in version when anXAI_GROK_CLI_VERSIONoverride is older. - Standardize technical diagnostics in English across backend logs, errors, provider probes, and frontend console output. Explicit log-level prefixes take precedence over keywords in the message, so translated legacy INFO messages retain their severity.
Bug fixes
- Apply the selected group's model attributes to manual provider tests, including batch and decision tests, and carry the group through background availability probes. Attribute lookup uses the final mapped model and selected endpoint, including OpenAI and Grok image tests. Attribute-read failures stop the test, and protocol-specific probes retain their chosen text or image endpoint.
- Keep dialogs open when Escape cancels input-method composition, including the legacy
keyCode=229signal. Ordinary Escape continues to follow the dialog's close setting. - Close the mobile navigation drawer when selecting a destination, including navigation to a different page.
- Let error-detail summaries use the dialog's available width, place response-copy actions beside their expand/collapse controls, and use the established action colors.
- Synchronize audit-page filters with incoming links and later route changes. Responses from older filter requests no longer replace the current results.
- Preserve large integer IDs and decimal values when redacting audit JSON and displaying MCP confirmation previews and results.
- Localize system-log load, save, and reset failure notices and known Codex invitation-unavailable messages using the selected interface language.
📥 Installation
Docker:
# GitHub Container Registry
docker pull ghcr.io/tokenflux/tokenrouter:0.4.0One-line install (Linux):
curl -sSL https://raw.githubusercontent.com/TokenFlux/TokenRouter/main/deploy/install.sh | sudo bashManual download:
Download the appropriate archive for your platform from the assets below.
📚 Documentation
中文翻译
TokenRouter 0.4.0 新增按权限授权的 MCP 管理接口、分组可用性探针的协议选择,并包含 DOMPurify 安全更新。
升级说明
- 后端与前端应一同升级。迁移 300 和 301 新增 MCP 访问令牌存储,以及默认值为
false的skip_browser_confirmation字段。现有管理员账户、登录凭据和网关 API Key 继续有效。升级前请备份 PostgreSQL 并验证可恢复。回退二进制会保留新增表,但 MCP 将不可用;临时确认记录和文件会自动过期。 - 使用 MCP 时,将
/mcp转发到主应用,并在所有实例上配置相同且固定的TOTP_ENCRYPTION_KEY(或totp.encryption_key)。请随数据库备份保存该密钥:创建、复制令牌及恢复加密凭据都需要它。配置frontend_url以生成可公开访问的浏览器确认链接,并允许预期的浏览器来源。MCP 使用专用 Bearer 令牌,服务端未提供 MCP OAuth 授权服务。 - 现有可用性探针继续自动选择协议。已启用的探针若指定了协议,该协议必须仍被分组允许,且受探针执行器支持。从分组移除该入口前,请重新选择探针协议或关闭探针。
- 内部诊断、后端错误消息和提供商测试输出改用英文。若日志查询或集成依赖此前的中文文本,请更新匹配规则。界面通知继续使用所选语言;上游原始错误和管理员自定义消息保留原文。
安全更新
- 前端直接依赖及覆盖规则将 DOMPurify 从 3.4.14 升级到 3.4.17,包含 GHSA-cg2g-xh64-v4q7 和 GHSA-mrv2-3pqr-j5jr 的修复。TokenRouter 使用 DOMPurify 清理 Markdown 页面、公告、支付说明和 SVG 图标。
新功能
- 管理智能体可通过
/mcp的 Streamable HTTP 接口连接。search_operations、describe_operation、read_operation和execute_operation四个工具用于发现和执行获准的管理操作,复用已有 HTTP 认证、校验、限流及业务处理。写操作响应中断时会报告结果未知,不会自动重试。 - 在
/admin/mcp创建、复制、编辑、停用和撤销 MCP 令牌,并设置有效期及具体操作权限。四套权限预设分别覆盖只读查询、网关运维、用户与订阅,或当前全部管理操作。升级新增操作不会扩大已保存的授权范围,并发编辑令牌时会拒绝过期配置。 - 敏感 MCP 操作在执行前由管理员通过浏览器审阅。确认记录十分钟后过期,并绑定请求令牌、令牌配置和具体操作。单个令牌可开启跳过确认选项,默认关闭;需要近期双重验证或交互式浏览器授权的操作仍须完成相应步骤。
- 支持上传 JSON 请求体,并通过受保护文件交付敏感导出、新生成的凭据或兑换码、二进制结果和较大响应。文件十分钟后过期,下载时检查所属管理员及令牌当前权限,并保留下载文件名。OAuth 等交互式提供商配置继续在浏览器中完成;大型备份下载复用已有流式处理。
- 审计日志可按令牌和操作追踪 MCP 活动,包括浏览器接续、凭据复制和受保护文件下载。支持按令牌前缀搜索、从令牌打开对应审计记录,以及下载已注册管理 API 的 OpenAPI 3.1 描述。
- 通过
GET /api/v1/admin/providers/:id/usage/passive和providers.usage.passive.listMCP 操作读取已采集的 Anthropic OAuth 与 SetupToken 用量。主动用量刷新和 Grok 配额探测可能更新提供商状态或调度,因此使用执行工具。 - 可为可用性探针选择 Messages、Responses、Chat Completions、Gemini GenerateContent、SystemOne 或图片生成入口,选项受分组允许的协议限制。提供商选择遵循分组的模型映射和协议转换规则,测试使用解析后的上游端点及模型属性。
- 可分别显示或隐藏模型广场各分组标题中的最高优惠和倍率标签。两者默认显示;开关仅控制展示,保留分组的价格与折扣数据。
改进
- 内置 Grok CLI 身份和 User-Agent 版本更新为
1.0.67。发往cli-chat-proxy.grok.com的请求在XAI_GROK_CLI_VERSION覆盖值较旧时使用内置版本。 - 后端日志、错误、提供商探测和前端控制台中的技术诊断统一使用英文。明确的日志级别前缀优先于消息内的关键词,已翻译的历史 INFO 消息继续保持原有级别。
问题修复
- 手动提供商测试应用所选分组的模型属性,覆盖批量和决策测试,后台可用性探针也携带分组信息。属性查询使用最终映射模型及选定端点,包括 OpenAI 和 Grok 图片测试。属性读取失败时停止测试,指定协议的探针保持所选文字或图片端点。
- 输入法组词期间按 Escape 取消输入时,弹窗保持打开,包括旧式
keyCode=229信号。普通 Escape 仍遵循弹窗的关闭设置。 - 移动端选择导航目标时关闭导航抽屉,包括跳转到其他页面。
- 错误详情摘要使用弹窗的可用宽度,响应复制操作移到展开/收起控件旁,并使用已有的操作颜色。
- 审计页面根据传入链接及后续路由变化同步筛选条件。旧筛选请求的延迟响应不再覆盖当前结果。
- 审计 JSON 脱敏,以及 MCP 确认预览和结果展示保留大整数 ID 与小数的原始表示。
- 系统日志加载、保存、重置失败提示,以及已知的 Codex 邀请不可用消息,使用所选界面语言。
📥 安装
Docker:
# GitHub Container Registry
docker pull ghcr.io/tokenflux/tokenrouter:0.4.0一键安装(Linux):
curl -sSL https://raw.githubusercontent.com/TokenFlux/TokenRouter/main/deploy/install.sh | sudo bash手动下载:
从下方附件下载适合你所用平台的归档。