Mcp Thinkgate

io.github.tjp2021Published by GitHub account tjp2021v0.1.1Updated Oct 24, 2026

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

VerifiedSTDIODesktop onlyDeveloper ToolsAI & ML

Overview

AI-generated overview

A local MCP server that classifies a prompt's complexity and recommends a Claude thinking tier, effort level and model before the assistant answers.

What you can do
Classify a prompt's complexity into fast, think or ultrathink tiers, with effort level, suggested model, confidence and a one-sentence reason, either through the MCP tool or the exported library function. Use a rule-based classifier without a key, or an optional Haiku call for more accurate classification. Apply model profiles such as claude, openrouter-cost or openrouter-balanced, with per-tier model overrides.
When to use it
Useful for agent builders running Claude on a mix of trivial and hard requests who want thinking depth chosen automatically instead of tagging prompts by hand. Also fits teams running always-on assistants where latency and token cost vary by message.
Requirements
Runs locally over stdio, typically launched with npx from the npm package mcp-thinkgate. Needs Node.js 20 or newer. The ANTHROPIC_API_KEY environment variable is optional; without it the server falls back to rule-based classification.
Before you install
The optional ANTHROPIC_API_KEY is a billable Anthropic credential, and the Haiku classification call costs a small amount per message. The tool is advisory only: the host must actually switch models and effort, so nothing changes unless the client acts on the result. Prompts are sent to Anthropic when key-based classification is enabled.

Installation

In SourceWeft

  1. Open Mcp Thinkgate in the dashboard and add it to a workspace.
  2. Enable the server for the chats that should use its tools.

Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.

Other MCP clients

Follow the launch instructions in the repository.

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

Source: README.md at commit 2b7e5d2

Tools

0
SourceWeft has not started this package in its sandbox yet, so its tools are not known.

Version history

1
  1. v0.1.1LatestSep 16, 2026

Score

50% of the applicable checks met

How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.

  • Reached in the last 30 days25 pts

    Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.

  • Auth declared10 pts

    Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.

  • Tools listed15 pts

    Answer tools/list without a credential, or ship a package that starts in a sandbox without one.

  • DescriptionRequired15 pts
  • Logo10 pts
  • Documentation15 pts
  • License10 pts