Mcp Thinkgate

io.github.tjp2021由 GitHub 账号 tjp2021 发布v0.1.1更新于 Oct 24, 2026

Auto-classifies prompt complexity and routes to the right Claude thinking mode. No API key needed.

已验证STDIO仅桌面开发者工具AI 与机器学习

概览

AI 生成的概览

一个本地 MCP 服务器,在助手回答前判断提示词的复杂度,并建议 Claude 的思考层级、推理强度和模型。

可以做什么
把提示词复杂度分为 fast、think、ultrathink 三档,并给出推理强度、建议模型、置信度和一句话理由,可通过 MCP 工具或导出的库函数调用。无密钥时使用基于规则的分类,也可选用 Haiku 调用获得更准确的分类。支持 claude、openrouter-cost、openrouter-balanced 等模型配置,并可按档位覆盖模型。
适用场景
适合在 Claude 上同时处理简单与复杂请求的智能体开发者,希望自动决定思考深度而不必手动标注提示词。也适合运行常驻助手的团队,其消息的延迟与 token 成本差异较大。
运行要求
通过 stdio 在本地运行,通常用 npx 启动 npm 包 mcp-thinkgate。需要 Node.js 20 或更高版本。ANTHROPIC_API_KEY 环境变量为可选项,未提供时回退到基于规则的分类。
安装前请注意
可选的 ANTHROPIC_API_KEY 是会产生费用的 Anthropic 凭据,Haiku 分类调用每条消息有少量花费。该工具仅提供建议:宿主必须真正切换模型和推理强度,否则不会生效。启用基于密钥的分类时,提示词会发送给 Anthropic。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Mcp Thinkgate,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

ThinkGate

[CI]

Automatic reasoning mode selection for Claude agents.


The problem

You built an AI agent. It handles everything — status checks, quick lookups, complex architecture questions, deep debugging sessions. But under the hood it runs every single message through the same model with the same thinking settings.

That means you're burning extended thinking tokens on "what time is it in Tokyo?" and getting shallow answers on "help me design the entire auth system."

You could manually tag requests — ULTRATHINK: before the hard ones. But you forget. Your users definitely won't do it. And if you're building agents for other people, you can't train every end user to manage thinking modes.

ThinkGate fixes this at the infrastructure layer. It sits between the incoming message and your model call, classifies the complexity in ~200ms, and returns exactly which model and thinking depth to use. Automatically. Every time.


Who this is for

  • Agent builders running Claude on a mix of simple and complex tasks who are tired of one-size-fits-all model settings
  • Teams running 24/7 agents (WhatsApp bots, Slack assistants, Telegram agents) where message complexity varies wildly and cost/latency actually matters
  • Anyone who's ever typed ULTRATHINK manually and thought: this should just happen on its own

How it works

Incoming message      ↓  Haiku call (~200ms, ~$0.0001)  "How complex is this?"      ↓  fast → no extended thinking  think → medium effort  ultrathink → max effort      ↓  Claude runs with the right settings

A cheap, fast Haiku call reads your prompt and decides which tier it needs. Then your main Claude call runs with the right effort level. You pay almost nothing for the classification, and save real money (and latency) on the 60%+ of messages that don't need extended reasoning.

The classifier is the IP here — not which model runs it. Three tiers. A system prompt trained on the boundary between "this needs thinking" and "this doesn't." Works out of the box.


Tiers

TierClaude effortWhen
fastnoneFactual, conversational, simple edits
thinkmediumArchitecture, debugging, multi-step analysis
ultrathinkmax / highSystem design, proofs, open-ended complexity

Profiles (model mapping)

Set THINKGATE_PROFILE or pass { profile } to classifyPrompt:

Profilefastthinkultrathink
claude (default)claude-haiku-4-5-...claude-sonnet-4-6claude-opus-4-6
openrouter-costgoogle/gemini-2.5-flashanthropic/claude-sonnet-4.5anthropic/claude-opus-4.6
openrouter-balancedanthropic/claude-haiku-4.5anthropic/claude-sonnet-4.5anthropic/claude-opus-4.6

Per-tier overrides: THINKGATE_FAST_MODEL, THINKGATE_THINK_MODEL, THINKGATE_ULTRA_MODEL.

Cost note: the MCP tool is advisory. Hosts must actually switch models. Pi does this via ~/.pi/agent/extensions/thinkgate-router.ts + thinkgate.json.

Rule mode (no API key) is free and preferred for auto-routing. Long checklist pastes no longer auto-upgrade to THINK.


Use as an MCP tool (Claude Desktop / Claude Code)

Add to ~/.claude/settings.json (Claude Code) or ~/Library/Application Support/Claude/claude_desktop_config.json (Claude Desktop):

json
{  "mcpServers": {    "thinkgate": {      "command": "npx",      "args": ["-y", "mcp-thinkgate"],      "env": {        "ANTHROPIC_API_KEY": "your-api-key-here"      }    }  }}

Restart Claude. Now you can ask it to classify before it answers:

"Before responding, classify the complexity of this task: design a rate limiter for a public API"

Tier: thinkEffort: mediumSuggested model: claude-sonnet-4-6Confidence: 92%Why: Requires structured design reasoning and trade-off analysis, but has well-defined scope.

Use as a library (agent frameworks)

Install:

bash
npm install mcp-thinkgate

Import and use:

typescript
import { classifyPrompt, setLogLevel } from 'mcp-thinkgate';
// Optional: silence logs (default level is 'info', writes to stderr)setLogLevel('error');
const result = await classifyPrompt(userMessage, process.env.ANTHROPIC_API_KEY!);
// result.tier       → 'fast' | 'think' | 'ultrathink'// result.effort     → 'none' | 'medium' | 'max'// result.confidence → 0.0 - 1.0// result.reasoning  → one sentence explanation
// Works without an API key too (rule-based fallback):const quickResult = await classifyPrompt(userMessage);

Reference implementation: TinyClaw

TinyClaw is an open-source multi-agent framework for Claude. ThinkGate is wired into its invokeAgent() function — every message is automatically classified before the Claude CLI runs, and --effort is set accordingly.

Three lines added. Zero config required. Every agent in every team automatically gets the right thinking depth.

See the integration at src/lib/invoke.ts.


Requirements

  • Node.js 20+
  • Anthropic API key (optional — falls back to rule-based classification)

Local development

bash
git clone https://github.com/tjp2021/mcp-thinkgatecd mcp-thinkgatenpm installnpm testnpm run build

Contributing

See CONTRIBUTING.md for dev setup, commands, and PR process.

Security

See SECURITY.md for vulnerability reporting.

License

MIT — see LICENSE

来源:README.md,提交 2b7e5d2

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.1.1最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分