Code Reasoning MCP Server

Code Reasoning MCP Server

An enhanced sequential thinking tool optimized for programming tasks that helps break down complex coding problems into structured, self-auditing thought steps with branching and revision capabilities.

Category
访问服务器

README

Code Reasoning MCP Server

An enhanced fork of the Sequential Thinking MCP server, optimized for programming tasks and complex problem-solving through a structured thinking process.

Quick Start

# Install globally
npm install -g code-reasoning

# Configure Claude Desktop
# Edit ~/Library/Application Support/Claude-Desktop/claude_desktop_config.json:
{
  "mcpServers": {
    "sequential-thinking": {
      "command": "code-reasoning",
      "args": []
    }
  }
}

# Start Claude Desktop and enjoy enhanced sequential thinking!

Why This Fork?

This fork was created to enhance the original Sequential Thinking server with several key improvements:

  1. Programming Focus: Optimized for coding tasks and programming problem-solving
  2. Improved Parameter Naming: Consistent snake_case naming convention (e.g., thought_number instead of thoughtNumber)
  3. Enhanced Prompting: Clearer, more structured guidance in the tool description
  4. Enforcement of Best Practices: Automatically aborts chains after 20 steps to prevent excessive recursion
  5. Local Development: Designed to work seamlessly with Claude Desktop for programming tasks

Key Differences from Original

Feature Original Code Reasoning
Parameter Style camelCase snake_case
Max Steps Not enforced Enforced (max 20)
Tool Description Basic Enhanced markdown with examples
Primary Focus General problem-solving Programming/code tasks
Error Handling Basic Improved with status codes

Enhanced Prompt

This fork features a significantly improved prompt that provides clearer guidance and examples:

🧠 **Sequential Thinking Tool**

Purpose → break complex problems into **self-auditing, exploratory** thought steps that can *branch*, *revise*, or *back-track* until a **single, well-supported answer** emerges.

---

## WHEN TO CALL
• Multi-step planning, design, debugging, or open-ended analysis  
• Whenever *further private reasoning* or *hypothesis testing* is required **before** replying to the user

---

## ENCOURAGED PRACTICES
🔍 **Question aggressively** – ask "What am I missing?" after each step  
🔄 **Revise freely** – mark `is_revision=true` even late in the chain  
🌿 **Branch often** – explore plausible alternatives in parallel; you can merge or discard branches later  
↩️ **Back-track** – if a path looks wrong, start a new branch from an earlier thought  
❓ **Admit uncertainty** – explicitly note unknowns and schedule extra thoughts to resolve them

---

## MUST DO
✅ Put **every** private reasoning step in `thought`  
✅ Keep `thought_number` correct; update `total_thoughts` when scope changes  
✅ Use `is_revision` & `branch_from_thought`/`branch_id` precisely  
✅ Set `next_thought_needed=false` *only* when **all** open questions are resolved  
✅ Abort and summarise if `thought_number > 20`  

---

## DO NOT
⛔️ Reveal the content of `thought` to the end-user  
⛔️ Continue thinking once `next_thought_needed=false`  
⛔️ Assume thoughts must proceed strictly linearly – *branching is first-class*

---

### PARAMETER CHEAT-SHEET
• `thought` (string) – current reasoning step  
• `next_thought_needed` (boolean) – request further thinking?  
• `thought_number` (int ≥ 1) – 1-based counter  
• `total_thoughts` (int ≥ 1) – mutable estimate  
• `is_revision`, `revises_thought` (int) – mark corrections  
• `branch_from_thought`, `branch_id` – manage alternative paths  
• `needs_more_thoughts` (boolean) – optional hint that more thoughts may follow  

_All JSON keys **must** use `lower_snake_case`._

---

### EXAMPLE ✔️
```json
{
  "thought": "List solution candidates and pick the most promising",
  "thought_number": 1,
  "total_thoughts": 4,
  "next_thought_needed": true
}

EXAMPLE ✔️ (branching late)

{
  "thought": "Alternative approach: treat it as a graph-search problem",
  "thought_number": 6,
  "total_thoughts": 8,
  "branch_from_thought": 3,
  "branch_id": "B1",
  "next_thought_needed": true
}

Features

  • Break down complex programming problems into manageable steps
  • Revise and refine thoughts as understanding deepens
  • Branch into alternative paths of reasoning
  • Adjust the total number of thoughts dynamically
  • Generate and verify solution hypotheses
  • Enforce a maximum of 20 thought steps to prevent excessive reasoning

Tool

sequentialthinking

Facilitates a detailed, step-by-step thinking process for programming and technical problem-solving.

Inputs:

  • thought (string): The current thinking step
  • next_thought_needed (boolean): Whether another thought step is needed
  • thought_number (integer): Current thought number
  • total_thoughts (integer): Estimated total thoughts needed
  • is_revision (boolean, optional): Whether this revises previous thinking
  • revises_thought (integer, optional): Which thought is being reconsidered
  • branch_from_thought (integer, optional): Branching point thought number
  • branch_id (string, optional): Branch identifier
  • needs_more_thoughts (boolean, optional): If more thoughts are needed

Important: All parameters must use snake_case format (e.g., thought_number, not thoughtNumber). The server will reject requests using camelCase parameters.

Usage

The Code Reasoning tool is designed for:

  • Breaking down complex programming problems into steps
  • Algorithm design and optimization
  • Debugging and error analysis
  • Code architecture planning
  • Technical decision-making when multiple approaches exist
  • Understanding complex codebases

Configuration

Usage with Claude Desktop

Add this to your claude_desktop_config.json:

{
  "mcpServers": {
    "sequential-thinking": {
      "command": "code-reasoning",
      "args": []
    }
  }
}

Location of Claude Desktop config file on macOS:

~/Library/Application Support/Claude-Desktop/claude_desktop_config.json

Usage with VS Code

For manual installation, add the following JSON block to your User Settings (JSON) file in VS Code. You can do this by pressing Ctrl + Shift + P and typing Preferences: Open Settings (JSON).

Optionally, you can add it to a file called .vscode/mcp.json in your workspace. This will allow you to share the configuration with others.

{
  "mcp": {
    "servers": {
      "sequential-thinking": {
        "command": "code-reasoning",
        "args": []
      }
    }
  }
}

Installation

# Create the directory
mkdir -p ~/Sites/code-reasoning

# Copy files from original repository (if you have it)
cp -r /path/to/mcp-servers/src/sequentialthinking/* ~/Sites/code-reasoning/

# Navigate to the directory
cd ~/Sites/code-reasoning

# Update package.json and index.ts with the custom changes

# Install dependencies
npm install

# Build the package
npm run build

# Install globally
npm link

Troubleshooting

TypeScript Configuration Error

If you encounter an error like:

error TS5083: Cannot read file '/tsconfig.json'.

This is because the original tsconfig.json extends a parent configuration. Update your tsconfig.json to be self-contained:

{
  "compilerOptions": {
    "target": "ES2022",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "skipLibCheck": true,
    "outDir": "./dist",
    "rootDir": ".",
    "declaration": true
  },
  "include": ["./**/*.ts"]
}

Parameter Naming Errors

If Claude receives errors from the server, ensure all parameters use snake_case:

  • Use thought_number instead of thoughtNumber
  • Use next_thought_needed instead of nextThoughtNeeded
  • Use total_thoughts instead of totalThoughts

Keeping Up-to-Date with Upstream

This is a fork of the original Sequential Thinking server. To incorporate updates from the original while maintaining our customizations:

  1. Check for updates to the original repository:

    cd /path/to/original/mcp-servers
    git pull
    
  2. Compare the changes to our fork:

    diff -r /path/to/original/mcp-servers/src/sequentialthinking/ ~/Sites/code-reasoning/
    
  3. Selectively incorporate updates:

    • Update dependencies to match the original (especially important for SDK updates)
    • Add new features or bug fixes while maintaining our snake_case naming conventions
    • Update the tool description if improvements are made to the original
  4. Rebuild and reinstall after updating:

    npm install
    npm run build
    npm link
    

License

This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选
mcp-server-qdrant

mcp-server-qdrant

这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。

官方
精选
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选