Skip to main content
Glama

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.


Related MCP server: ai-workers-mcp

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

Tier

Claude effort

When

fast

none

Factual, conversational, simple edits

think

medium

Architecture, debugging, multi-step analysis

ultrathink

max / high

System design, proofs, open-ended complexity

Profiles (model mapping)

Set THINKGATE_PROFILE or pass { profile } to classifyPrompt:

Profile

fast

think

ultrathink

claude (default)

claude-haiku-4-5-...

claude-sonnet-4-6

claude-opus-4-6

openrouter-cost

google/gemini-2.5-flash

anthropic/claude-sonnet-4.5

anthropic/claude-opus-4.6

openrouter-balanced

anthropic/claude-haiku-4.5

anthropic/claude-sonnet-4.5

anthropic/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):

{
  "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: think
Effort: medium
Suggested model: claude-sonnet-4-6
Confidence: 92%
Why: Requires structured design reasoning and trade-off analysis, but has well-defined scope.

Use as a library (agent frameworks)

Install:

npm install mcp-thinkgate

Import and use:

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

git clone https://github.com/tjp2021/mcp-thinkgate
cd mcp-thinkgate
npm install
npm test
npm run build

Contributing

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

Security

See SECURITY.md for vulnerability reporting.

License

MIT — see LICENSE

Available Tools

1 tool
classify_complexityA

Classify a prompt's complexity and return the optimal model tier + thinking effort. Active profile: claude (Anthropic native model IDs (haiku / sonnet / opus)). Profiles: claude, openrouter-cost, openrouter-balanced. Returns tier (fast/think/ultrathink), effort, suggested model, confidence, and reasoning.

ParametersJSON Schema
NameRequiredDescriptionDefault
promptYesThe prompt or task to classify
profileNoOptional tier profile override: claude | openrouter-cost | openrouter-balanced

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must carry the burden of behavioral disclosure. It does so by specifying the active profile (claude) and the list of available profiles, as well as the return fields (tier, effort, suggested model, confidence, reasoning). This gives the agent insight into the tool's behavior and output structure. It does not explicitly state side effects (e.g., read-only, cost implications), but for a classification tool this is largely implied. The description adds meaningful behavioral context beyond a simple statement of purpose.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences, front-loaded with the primary purpose, then efficiently lists profiles and return fields. Every clause adds useful information: the active profile, alternative profiles, and what the tool returns. There is no redundant phrasing or filler. It is concise yet comprehensive for the tool's scope.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, the description appropriately lists the return fields (tier, effort, suggested model, confidence, reasoning). It also covers the profile parameter and its active default. While it doesn't explain the meaning of each return field in depth or describe edge cases, it is complete enough for an agent to understand what the tool does and what it will receive. The given context (2 parameters, 1 required) is well covered, making this a solid 4.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3. The description adds significant value by explaining the profile parameter's semantics: 'Active profile: claude (Anthropic native model IDs (haiku / sonnet / opus)). Profiles: claude, openrouter-cost, openrouter-balanced.' This clarifies the enum values and the meaning of the active profile, which the schema only lists as names. The prompt parameter is self-explanatory. The description enhances parameter understanding beyond the schema, justifying a 4.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's primary function: 'Classify a prompt's complexity and return the optimal model tier + thinking effort.' This is a specific verb (classify) with a specific resource (prompt complexity) and a well-defined outcome, making the purpose unmistakable. Even without sibling tools to differentiate, the description is precise and covers both the action and the deliverable.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage—classifying a prompt to determine model tier and effort—but does not explicitly state when to use it versus alternatives or when not to use it. It provides context about profiles and return fields, but there is no direct guidance on deployment scenarios or exclusions. The usage is implied rather than explicitly instructed, yielding a score of 3.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

A4.2/5.0
Disambiguation5/5

With only one tool exposed, there is no possibility of confusion or misselection between overlapping tools. The single classify_complexity tool has a unique and unambiguous purpose.

Naming Consistency5/5

The single tool name follows a clear verb_noun pattern, which is internally consistent. Even though there are no other tools to compare, the naming convention is well-formed and predictable.

Tool Count2/5

A server with a single tool is under-scoped for a general 'ThinkGate' concept, which implies a broader set of operations like managing profiles or evaluating multiple aspects. The tool count is too low to constitute a well-rounded tool set.

Completeness5/5

For its stated purpose of classifying prompt complexity and returning model suggestions, the tool covers its domain completely. There are no obvious missing operations or dead ends within this narrow scope.

Maintenance

ActivitySlowing
ResponsivenessUnresponsive

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/tjp2021/mcp-thinkgate'

If you have feedback or need assistance with the MCP directory API, please join our Discord server