npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@jochenyang/interleaved-thinking

v0.6.0

Published

MCP server for interleaved sequential thinking with dynamic tool calling, host-delegated execution, and self-monitoring quality signals

Readme

Interleaved Sequential Thinking MCP Server

npm version License: MIT MCP Version

English | 中文


An MCP server implementation that enables AI to perform interleaved sequential thinking with dynamic tool calling. This server allows AI to alternate between reasoning, tool execution, and result analysis in a flexible "think-execute-reflect" cycle.

Features

  • Three-Phase Interleaved Execution: Seamlessly switch between thinking, tool calling, and analysis phases
  • Dynamic Tool Calling: Execute external tools during the reasoning process and adjust strategy based on results
  • Context Continuity: Maintain complete context across the entire interleaved cycle
  • Flexible Strategy Adjustment: Support for revisions, branching, and dynamic step count adjustment
  • Complete History Tracking: Record all thinking steps and tool calls with detailed information
  • Resource Control: Built-in limits for tool calls and timeout control to prevent infinite loops
  • Host-Delegated Execution: The server registers tool calls and tracks the interleaving flow; the MCP host is responsible for actually executing tools and passing the result back via previousToolResult

Use Cases

This tool is designed for:

  • Breaking down complex problems that require multiple steps
  • Tasks that need external information during the reasoning process
  • Problems where strategy needs to be adjusted based on intermediate results
  • Situations where the full scope is not clear at the start
  • Tasks requiring iterative verification and information gathering
  • Problems that benefit from "think-execute-reflect" cycles

Tool

interleaved-thinking

Facilitates interleaved sequential thinking with dynamic tool calling.

Core Parameters:

  • thought (string): Your current thinking content
  • stepNumber (integer): Current step number (starts from 1)
  • totalSteps (integer): Estimated total steps needed
  • nextStepNeeded (boolean): Whether another step is needed
  • phase (enum): Current phase - 'thinking', 'tool_call', or 'analysis'

Tool Call Parameters (when phase='tool_call'):

  • toolCall (object):
    • toolName (string): Name of the tool to execute
    • parameters (object): Tool parameters as key-value pairs
    • metadata (object, optional): timeout, retryCount, priority

Optional Parameters:

  • isRevision (boolean): Whether this revises previous reasoning
  • revisesStep (integer): Which step is being reconsidered
  • branchFromStep (integer): Branching point step number
  • branchId (string): Branch identifier
  • needsMoreSteps (boolean): If more steps are needed

When NOT to use this tool

Skip interleaved-thinking for:

  • Single-step questions, pure translations, or lookups where the answer is known up front
  • Tasks that already have a dedicated MCP tool that gets there in one call
  • Mechanical edits where there is zero exploration space
  • Pure chat that does not need any tool at all

In these cases, calling this tool adds latency and noise without improving the answer.

Configuration

Usage with Claude Code CLI

Add this to your Claude Code CLI MCP settings:

{
  "interleaved-thinking": {
    "command": "cmd",
    "args": [
      "/c",
      "npx",
      "@jochenyang/interleaved-thinking@latest"
    ],
    "env": {},
    "type": "stdio"
  }
}

Usage with Cursor

Add this to your Cursor MCP settings:

{
  "mcpServers": {
    "interleaved-thinking": {
      "command": "npx",
      "args": [
        "-y",
        "@jochenyang/interleaved-thinking"
      ]
    }
  }
}

Usage with Kiro

Add this to your Kiro MCP configuration:

{
  "mcpServers": {
    "interleaved-thinking": {
      "command": "npx",
      "args": [
        "-y",
        "@jochenyang/interleaved-thinking"
      ]
    }
  }
}

Usage with VS Code

For manual installation, add the configuration to .vscode/mcp.json in your workspace:

{
  "servers": {
    "interleaved-thinking": {
      "command": "npx",
      "args": [
        "-y",
        "@jochenyang/interleaved-thinking"
      ]
    }
  }
}

Docker

{
  "mcpServers": {
    "interleaved-thinking": {
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "jochenyang/interleaved-thinking"
      ]
    }
  }
}

Environment Variables

  • DISABLE_THOUGHT_LOGGING: Set to true to disable console logging (default: false). Read at server startup; takes effect on the next InterleavedThinkingServer instance construction.

How Tool Execution Works

This server is a flow controller, not a tool executor. It registers tool calls and tracks the interleaved think→tool_call→analysis loop, but it does NOT actually invoke external tools.

Round-trip protocol:

  1. tool_call phase — your model supplies a toolCall (tool name + parameters). The server records the registration and responds with toolResult.status === "pending". The tool itself is NOT executed by the server.
  2. Host dispatches — the MCP host (Claude/Cursor/etc.) takes the registered toolCall, invokes the actual tool on the appropriate provider, and obtains the real result.
  3. analysis phase — the host calls this tool again, now with phase: "analysis" and a previousToolResult field carrying the real payload. The server attaches the result to the in-memory history and exposes it to your model for reflection.

The previousToolResult field carries the standard tool-result shape: toolName, success, executionTime, timestamp, optional result, optional error (with type, message, recoveryStrategy).

This design keeps the reasoning loop and tool execution cleanly separated, so the same thinking flow can drive any tool provider the host supports.

Building

NPM

npm install
npm run build

Docker

docker build -t jochenyang/interleaved-thinking -f Dockerfile .

Example Usage

// Phase 1: Thinking
{
  "thought": "I need to analyze this problem step by step",
  "stepNumber": 1,
  "totalSteps": 5,
  "nextStepNeeded": true,
  "phase": "thinking"
}

// Phase 2: Tool Call
{
  "thought": "Now I need to fetch some data",
  "stepNumber": 2,
  "totalSteps": 5,
  "nextStepNeeded": true,
  "phase": "tool_call",
  "toolCall": {
    "toolName": "fetch_data",
    "parameters": {
      "query": "example"
    }
  }
}

// Phase 3: Analysis
{
  "thought": "Based on the tool results, I can now conclude...",
  "stepNumber": 3,
  "totalSteps": 5,
  "nextStepNeeded": false,
  "phase": "analysis"
}

License

This MCP server is licensed under the MIT License. See the LICENSE file for details.