Transforming the Open‑Source SequentialThinking MCP Server to HTTP SSE Mode
This article walks through converting the open‑source SequentialThinking MCP Server from its default Stdio interface to an HTTP Server‑Sent Events (SSE) implementation using TypeScript, Express, and the MCP SDK, detailing configuration, code changes, route setup, and testing procedures.
Overview
The SequentialThinking MCP Server is an official MCP implementation that structures complex problem solving into incremental, reflective steps. It provides features such as task decomposition, dynamic step adjustment, and hypothesis validation, making it useful for AI‑assisted planning and analysis.
Original Stdio‑based Server
In earlier tutorials the server was run via a local stdio transport, configured with a JSON block like:
{
"mcpServers": {
"sequential-thinking": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-sequential-thinking"]
}
}
}This configuration launches the server as a child process that communicates over standard input/output.
Goal: HTTP SSE Mode
The aim is to expose the same functionality through HTTP using Server‑Sent Events (SSE), which enables real‑time, one‑way communication from server to client.
Step‑by‑Step Conversion
Project Setup Create a new directory and initialise a Node.js project:
mkdir sequential-thinking-httpsse-mcpserver
cd sequential-thinking-httpsse-mcpserverpackage.json Add the following manifest (trimmed for brevity):
{
"name": "@wuchubuzai/sequential-thinking-httpsse",
"version": "0.0.1",
"description": "MCP server for sequential thinking and problem solving",
"type": "module",
"main": "dist/index.js",
"bin": { "sequential-thinking-httpsse-mcpserver": "dist/index.js" },
"scripts": { "build": "tsc && shx chmod +x dist/*.js", "prepare": "npm run build", "watch": "tsc --watch" },
"dependencies": {
"@modelcontextprotocol/sdk": "1.10.2",
"express": "^4.18.2",
"node-fetch": "^3.3.2",
"chalk": "^5.3.0",
"yargs": "^17.7.2"
},
"devDependencies": {
"@types/express": "^5.0.1",
"@types/node": "^22.15.3",
"shx": "^0.3.4",
"typescript": "^5.8.3"
}
}tsconfig.json
{
"compilerOptions": {
"target": "ES2022",
"module": "Node16",
"moduleResolution": "Node16",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"outDir": "./dist",
"rootDir": "."
},
"include": ["./**/*.ts"],
"exclude": ["node_modules"]
}Download the original source Fetch index.ts from the official repository:
curl -O https://github.com/modelcontextprotocol/servers/raw/main/src/sequentialthinking/index.tsModify imports for SSE Replace the Stdio transport import with the SSE transport and add Express:
#!/usr/bin/env node
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
// import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
import express from "express";Encapsulate server creation Wrap the original server‑initialisation code in a helper function:
function createAndGetServer() {
const server = new Server({
name: "sequential-thinking-httpsse-mcpserver",
version: "0.0.1",
capabilities: { tools: {} }
});
const thinkingServer = new SequentialThinkingServer();
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [SEQUENTIAL_THINKING_TOOL] }));
server.setRequestHandler(CallToolRequestSchema, async (request) => {
if (request.params.name === "sequentialthinking") {
return thinkingServer.processThought(request.params.arguments);
}
return { content: [{ type: "text", text: `Unknown tool: ${request.params.name}` }], isError: true };
});
return server;
}Define HTTP routes Set up an Express app that creates an SSEServerTransport for each client and forwards messages to the MCP server:
const app = express();
app.use(express.json());
const transports = { sse: {} as Record<string, SSEServerTransport> };
app.get('/sse', async (req, res) => {
console.log('http /sse request start.......');
const transport = new SSEServerTransport('/messages', res);
transports.sse[transport.sessionId] = transport;
res.on('close', () => { delete transports.sse[transport.sessionId]; });
const server = createAndGetServer();
await server.connect(transport);
console.log('http sse request connect');
});
app.post('/messages', async (req, res) => {
console.log('http /sse request receive message');
const sessionId = req.query.sessionId as string;
const transport = transports.sse[sessionId];
if (transport) {
await transport.handlePostMessage(req, res, req.body);
} else {
res.status(400).send('No transport found for sessionId');
}
});
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log('Sequential Thinking MCP Server HTTP SSE MODE Started.....');
console.log(`Sequential Thinking MCP Server running on port ${PORT}`);
}).on('error', err => console.error('Sequential Thinking MCP Server error', err));Build and Run Install dependencies, compile, and start the server:
npm install
npm run build
node dist/index.jsThe console shows that the server is listening on the chosen port and ready to accept SSE connections.
Client Test Using the Trae client (or any SSE‑capable tool), connect to /sse , send a task description, and observe the step‑by‑step reasoning output. Screenshots in the original article demonstrate successful execution and generation of a styled HTML report.
Discussion
The article also contrasts the MCP approach with native large‑model reasoning (e.g., DeepSeek R1, Claude 3.7). MCP provides an external protocol that offers fine‑grained control over the reasoning process, while built‑in model inference is a black‑box. Integration with MCP may require additional plumbing, but it enables structured task decomposition, dependency tracking, and multi‑step context preservation across domains such as research planning, code analysis, and project management.
Conclusion
By following the steps above, developers can migrate an existing Stdio‑based SequentialThinking MCP Server to an HTTP SSE service, gaining real‑time streaming capabilities and easier integration with web front‑ends or other HTTP clients. The transformation showcases practical use of the MCP SDK, TypeScript, and Express for building modular, extensible AI‑assisted back‑end services.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Ubiquitous Tech
A ubiquitous public account for pirate enthusiasts, regularly sharing curated experiences, tech learning, and growth insights. Currently publishing articles on AI RAG customer service, AI MCP technology, and open-source design. Personal free Knowledge Planet: Awakening New World Programmer.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
