MAS sequential thinking server. Agno-based multi-agent system exposed via MCP.
# Sequential Thinking Multi-Agent System (MAS) for MCP 
[](https://smithery.ai/server/@FradSer/mcp-server-mas-sequential-thinking) [](https://twitter.com/FradSer) [](https://www.python.org/downloads/) [](https://github.com/cognitivecomputations/agno)
English | [简体中文](README.zh-CN.md)
This project implements a sophisticated sequential thinking process using a **Multi-Agent System (MAS)**. Built with the **Agno** framework, it's designed to be integrated with **Model Context Protocol (MCP)**. This system represents a significant advancement over simpler state-tracking approaches by leveraging coordinated, specialized agents for in-depth analysis and problem decomposition.
## Overview
This server provides a `sequentialthinking` tool designed for complex problem-solving within an MCP environment. Unlike its predecessor, this version employs a true Multi-Agent System (MAS) architecture where:
- **A Coordinating Agent** (the `Team` object in `coordinate` mode) manages the overall workflow and delegates tasks.
- **Specialized Agents** (Planner, Researcher, Analyzer, Critic, Synthesizer) handle specific sub-tasks based on their defined roles and expertise.
- Incoming thoughts are actively **processed, analyzed, and synthesized** by the agent team, rather than simply being logged.
- The system supports complex thought patterns, including **revisions** of previous steps and **branching** to explore alternative paths.
- Integration with external tools like **Exa** (via the Researcher agent) allows for dynamic information gathering.
- Robust **Pydantic** validation ensures data integrity for thought steps.
- Detailed **logging** tracks the entire process, including agent interactions (handled by the coordinator).
The primary goal is to achieve a higher quality of analysis and a more nuanced thinking process than possible with a single agent or simple state tracking by harnessing the power of specialized roles working collaboratively. This is particularly valuable in the context of MCP, where complex reasoning and iterative refinement are often required.
## Key Differences from Original Version (TypeScript)
This Python/Agno implementation marks a fundamental shift from the original TypeScript version:
| Feature/Aspect | Python/Agno Version (Current) | TypeScript Version (Original) |
| :------------------ | :------------------------------------------------------------------- | :--------------------------------------------------- |
| **Architecture** | **Multi-Agent System (MAS)**; Active processing by a team of agents. | **Single Class State Tracker**; Simple logging/storing. |
| **Intelligence** | **Distributed Agent Logic**; Embedded in specialized agents & Coordinator. | **External LLM Only**; No internal intelligence. |
| **Processing** | **Active Analysis & Synthesis**; Agents *act* on the thought. | **Passive Logging**; Merely recorded the thought. |
| **Frameworks** | **Agno (MAS) + FastMCP (Server)**; Uses dedicated MAS library. | **MCP SDK only**. |
| **Coordination** | **Explicit Team Coordination Logic** (`Team` in `coordinate` mode). | **None**; No coordination concept. |
| **Validation** | **Pydantic Schema Validation**; Robust data validation. | **Basic Type Checks**; Less reliable. |
| **External Tools** | **Integrated (Exa via Researcher)**; Can perform research tasks. | **None**. |
| **Logging** | **Structured Python Logging (File + Console)**; Configurable. | **Console Logging with Chalk**; Basic. |
| **Language & Ecosystem** | **Python**; Leverages Python AI/ML ecosystem. | **TypeScript/Node.js**. |
In essence, the system has evolved from a passive thought *recorder* to an active thought *processor* powered by a collaborative team of AI agents. This enhanced processing capability directly benefits MCP workflows by enabling more sophisticated reasoning and decision-making.
## How it Works (Coordinate Mode) within MCP
This section describes how the `sequentialthinking` tool functions within the MCP framework.
1. **Initiation:** An external LLM, acting as the MCP client, uses a `sequential-thinking-starter` prompt to define the problem and initiate the process. This prompt is external to this server.
2. **Tool Call:** The LLM calls the `sequentialthinking` tool via MCP with the first (or subsequent) thought. The thought is structured according to the `ThoughtData` Pydantic model (see below).
3. **Validation & Logging:** The `sequentialthinking` server receives the call, validates the input using Pydantic, logs the incoming thought, and updates the history/branch state via `AppContext`.
4. **Coordinator Invocation:** The core thought content (along with context about revisions/branches) is passed to the `SequentialThinkingTeam`'s `arun` method.
5. **Coordinator Analysis & Delegation:** The `Team` (acting as Coordinator) analyzes the input thought, breaks it down into sub-tasks, and delegates these sub-tasks to the *most relevant* specialist agents (e.g., Analyzer for analysis tasks, Researcher for information needs).
6. **Specialist Execution:** Delegated agents execute their specific sub-tasks using their instructions, models, and tools (like `ThinkingTools` or `ExaTools`).
7. **Response Collection:** Specialists return their results to the Coordinator.
8. **Synthesis & Guidance:** The Coordinator synthesizes the specialists' responses into a single, cohesive output. This output may include recommendations for revision or branching based on the specialists' findings (especially from the Critic and Analyzer). It also provides guidance for the LLM on formulating the next thought.
9. **Return Value (MCP Response):** The tool returns a JSON string to the MCP client containing the Coordinator's synthesized response, status, and updated context (branches, history length). This JSON response is crucial for the LLM to continue the sequential thinking process.
10. **Iteration:** The calling LLM uses the Coordinator's response and guidance to formulate the next `sequentialthinking` tool call, potentially triggering revisions or branches as suggested. This iterative process continues until the problem is solved or a satisfactory conclusion is reached.
## Token Consumption Warning
⚠️ **High Token Usage:** Due to the Multi-Agent System architecture, this tool consumes significantly **more tokens** than single-agent alternatives or the previous TypeScript version. Each `sequentialthinking` call invokes:
- The Coordinator agent (the `Team` itself).
- Multiple specialist agents (potentially Planner, Researcher, Analyzer, Critic, Synthesizer, depending on the Coordinator's delegation).
This parallel processing leads to substantially higher token usage (potentially 3-6x or more per thought step) compared to single-agent or state-tracking approaches. Budget and plan accordingly. This tool prioritizes **analysis depth and quality** over token efficiency. This is a trade-off to consider when integrating with MCP, especially in resource-constrained environments.
## Prerequisites
- Python 3.10+
- Access to a compatible LLM API (configured for `agno`). The system currently supports:
- **Groq:** Requires `GROQ_API_KEY`.
- **DeepSeek:** Requires `DEEPSEEK_API_KEY`.
- **OpenRouter:** Requires `OPENROUTER_API_KEY`.
- Configure the desired provider using the `LLM_PROVIDER` environment variable (defaults to `deepseek`).
- Exa API Key (required only if using the Researcher agent's capabilities)
- Set via the `EXA_API_KEY` environment variable.
- `uv` package manager (recommended) or `pip`.
## MCP Server Configuration (Client-Side)
This server runs as a standard executable script that communicates via stdio, as expected by MCP. The exact configuration method depends on your specific MCP client implementation. Consult your client's documentation for details on integrating external tool servers.
The `env` section within your MCP client configuration should include the API key for your chosen `LLM_PROVIDER`. This is how the MCP client provides the necessary credentials to the `sequentialthinking` server.
```json
{
"mcpServers": {
"mas-sequential-thinking": {
"command": "uvx", // Or "python", "path/to/venv/bin/python" etc.
"args": [
"mcp-server-mas-sequential-thinking" // Or the path to your main script, e.g., "main.py"
],
"env": {
"LLM_PROVIDER": "deepseek", // Or "groq", "openrouter"
// "GROQ_API_KEY": "your_groq_api_key", // Only if LLM_PROVIDER="groq"
FradSer/mcp-server-mas-sequential-thinking
April 2, 2025
July 6, 2025
Python