Enables deployment to Cloudflare Workers with Durable Objects for serverless, globally distributed sequential thinking with persistent state management.
Sequential Thinking MVP Server
A production-ready Model Context Protocol (MCP) server that enables AI assistants to perform structured, step-by-step reasoning through sequential thinking. This server facilitates breaking down complex problems into manageable steps, revising thoughts as understanding deepens, and exploring alternative reasoning paths.
✨ Latest Updates (v1.0.0)
All critical security and architectural issues have been fixed!
✅ Multi-User Support: Fixed shared state bug - each user now has isolated sessions
✅ Modern MCP Protocol: Upgraded to Streamable HTTP transport (MCP 2025-03-26 spec)
✅ Cloudflare Workers: Fully functional with Durable Objects for persistent state
✅ Comprehensive Validation: All inputs validated with proper error handling
✅ Security Hardened: Cryptographically secure session IDs, configurable CORS, rate limiting
✅ Memory Management: Automatic session cleanup with TTL to prevent memory leaks
✅ Production Ready: Proper error handling, graceful shutdown, health checks
See CODE_REVIEW.md for details on all fixes.
Features
Sequential Thinking: Step-by-step problem-solving with numbered thoughts
Thought Revision: Ability to revise and refine previous reasoning steps
Branching Paths: Explore multiple alternative reasoning approaches
Multi-User Session Management: Isolated sessions for concurrent users
Input Validation: Comprehensive validation with helpful error messages
Rate Limiting: DoS protection (100 requests per 15 minutes per IP)
Security: Secure session IDs, configurable CORS, proper authentication headers
Multiple Deployment Options:
Stdio (for Claude Desktop and local MCP clients)
HTTP Server with Streamable HTTP (for remote access)
Cloudflare Workers with Durable Objects (for serverless deployment)
Installation
Usage
Option 1: Stdio Mode (Claude Desktop)
Use with Claude Desktop or any MCP-compatible client:
Or use directly with npx:
Claude Desktop Configuration
Add to your Claude Desktop config file (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
Option 2: HTTP Server Mode
Start the HTTP server for remote access:
By default, the server runs on port 3000. Set a custom port:
Configuration
Environment Variables:
PORT: HTTP server port (default: 3000)NODE_ENV: Environment (development/production)ALLOWED_ORIGINS: Comma-separated list of allowed CORS origins (default: all in dev, none in prod)
Example:
Endpoints
GET /or/info- Server informationGET /health- Health check with session statsPOST /mcp- MCP Streamable HTTP endpoint
Session Management
Send a session ID to maintain state across requests:
Via Header:
Via Query Parameter:
Features
Multi-user support: Each session ID gets isolated state
Rate limiting: 100 requests per 15 minutes per IP
CORS: Configurable via ALLOWED_ORIGINS environment variable
Automatic cleanup: Sessions expire after 1 hour of inactivity
Health monitoring:
/healthendpoint shows active sessions and uptime
Option 3: Cloudflare Workers
Deploy to Cloudflare Workers with Durable Objects for serverless, globally distributed deployment with persistent state:
Cloudflare Workers Features
Persistent State: Uses Durable Objects for reliable data persistence
Global Distribution: Deployed to Cloudflare's edge network
Auto-scaling: Handles traffic spikes automatically
Zero Maintenance: Fully managed infrastructure
REST API Endpoints
GET /or/info- Server informationGET /health- Health checkPOST /think- Add a thought to the sequenceGET /sequence- Get current thought sequencePOST /reset- Reset session
Example:
Durable Objects Configuration
The server uses Cloudflare Durable Objects to persist state across requests. Each Durable Object instance maintains its own session data, which survives worker restarts and is replicated for reliability.
See wrangler.toml for configuration details.
Tools
1. sequential_thinking
The core tool for step-by-step reasoning.
Required Parameters:
thought(string): The current reasoning stepnextThoughtNeeded(boolean): Whether more steps are neededthoughtNumber(number): Sequential number of this thoughttotalThoughts(number): Estimated total thoughts needed
Optional Parameters:
isRevision(boolean): Marks this as a revision of a previous thoughtrevisesThought(number): The thought number being revisedbranchFromThought(number): Starting point for alternative reasoningbranchId(string): Identifier for alternative reasoning branchneedsMoreThoughts(boolean): Signal to expand total thought count
Example:
2. get_thought_sequence
Retrieves the complete sequence of thoughts.
Optional Parameters:
sessionId(string): Specific session ID (defaults to current)
3. get_thought_branch
Retrieves a specific branch of alternative reasoning.
Required Parameters:
branchId(string): The branch identifier
Optional Parameters:
sessionId(string): Specific session ID (defaults to current)
4. reset_thinking_session
Starts a new thinking session, clearing the current sequence.
5. get_session_summary
Gets a summary of the current thinking session.
Optional Parameters:
sessionId(string): Specific session ID (defaults to current)
Use Cases
Example 1: Basic Sequential Reasoning
Example 2: Thought Revision
Example 3: Alternative Reasoning Branches
API Examples (Cloudflare Workers / HTTP)
Add a thought
Get thought sequence
Reset session
Architecture
Development
Watch mode for development:
Build the project:
Benefits of Sequential Thinking
Transparency: See the AI's reasoning process step-by-step
Quality: Encourages thorough analysis and consideration
Revision: Allows the AI to reconsider and improve earlier steps
Exploration: Supports exploring multiple solution paths
Accountability: Clear audit trail of the reasoning process
License
MIT
Contributing
Contributions are welcome! Please feel free to submit issues or pull requests.