Metadata-Version: 2.5
Name: redfox-mcp-core
Version: 0.1.7
Summary: Shared runtime for RedFoxHub MCP servers: client management, multi-tenant auth, async task polling, stdio/HTTP serving
Project-URL: Homepage, https://github.com/redfox-data/redfox-mcp
Project-URL: Website, https://redfox.hk/apis/?source=mcp
License-Expression: MIT
Keywords: mcp,redfox
Requires-Python: >=3.10
Requires-Dist: cryptography<49; platform_machine == 'x86_64' and sys_platform == 'darwin'
Requires-Dist: fastmcp>=2.0
Requires-Dist: httpx>=0.24
Requires-Dist: redfox-python-sdk>=0.5.2
Description-Content-Type: text/markdown

# redfox-mcp-core

RedFoxHub 各平台 MCP server 的共享基础包，不直接面向终端用户。

提供能力：

- RedFoxClient 管理：stdio 模式全局单例；HTTP 模式按请求头 API Key 的多租户缓存（LRU，上限 1000）
- 统一异常封装：SDK 异常转为结构化结果（auth_failed / rate_limited / api_error），agent 可直接读取出错引导
- 异步任务辅助：提交后自动轮询至完成，超时返回 taskId 供 result 工具补查
- server 工厂与启动入口：`create_server(name, version)` 注册 `/health` 路由；`serve(mcp, prog, description)` 解析 `--transport stdio|http` / `--host` / `--port` / `--path` 并启动

认证方式：

- stdio：环境变量 `REDFOX_API_KEY`
- HTTP：请求头 `REDFOX_API_KEY: ak_xxx`（或 `Authorization: Bearer ak_xxx` / `X-API-KEY`）
- HTTP 建连：默认无 Key 返回 401、不建 session（`/health` 除外）；`REDFOX_MCP_REQUIRE_API_KEY=0` 可关闭拦截（仍打 `mcp_connect` 日志）
- 日志：`REDFOX_MCP_LOG=1` 时记录 `mcp_connect`（含空连是否带 Key）与 `mcp_call`

API Key 获取：https://redfox.hk/settings/api-keys?source=mcp
