liveBook · Manning

Sequential thinking server

As explained in AI Agents in Action, Second Edition

A sequential thinking server is an MCP server that provides a structured workflow for explicit multistep planning and reasoning.

A sequential thinking server is an MCP server that gives an agent a scratchpad for multistep work. The agent writes intermediate thoughts, then reads them on later steps to maintain continuity, revise a plan, or explore another approach. The server itself does not think: the agent does the reasoning, and the server tracks its outputs. section 5.4

A useful way to separate the roles is:

  • The agent decides what to reason about and calls the server’s single SequentialThinking tool to record a step. section 5.4.1
  • The agent can revisit or revise earlier thoughts as the task changes. Prompt instructions can direct it to use patterns such as ReAct or tree-of-thought; the server does not supply those strategies on its own. section 5.4.1
  • Other tools perform actions. The thinking tool keeps track of reasoning around those actions. section 5.4.2
Listing 5.9 04_sequential_thinking_agent.py
thinking_srv = MCPServerStdio(    #1
    name="sequential-thinking",
    params={
        "command": "npx",
        "args": [
            "-y", 
            "@modelcontextprotocol/server-sequential-thinking"
            ],
    },
)

instructions = """
You are helpful planning assistant.
"""
agent = Agent(
    name="Assistant",
    instructions=instructions,
    mcp_servers=[thinking_srv],    #2
)
async with thinking_srv:
    tools = await thinking_srv.list_tools()
    print("Available tools:", tools)    #3
    goal = """
Discover and output the tool and functions you have available.
"""
    print("Running...", goal)
    result = await Runner.run(agent, goal)
    print(result.final_output)

The minimal setup starts the server with npx, attaches it to an agent through MCPServerStdio, and lists the tools the agent can access. It is a practical first check before assigning a planning task. section 5.4.1

Reason, act, observe, repeat

For a time-travel problem, an agent can record a reasoning step, call travel_back or travel_forward, inspect the result, and record another step to decide whether it is finished. Traces reveal this ReAct loop more clearly than the final answer alone. The agent can still answer incorrectly, depending on the model, so tool use is not proof of correctness. section 5.4.2 section 5.4.2

Use the scratchpad when a problem needs several steps, an adjustable plan, or course correction. For harder tasks, instructions can combine step-by-step planning, ReAct actions, tree-of-thought branches, and Reflexion feedback. This can take time and consume many tokens; reserve elaborate combinations for complex, ambiguous tasks rather than quick answers. Check results and validate reasoning outputs to prevent errors from carrying into later steps. section 5.4.3 section 5.6

How AI Agents in Action, Second Edition covers it

How deep it goes
Shows server attachment, its single tool, and traced agent behavior, while distinguishing stored thoughts from reasoning performed by the agent.
Examples
Uses a minimal agent setup, time-travel tools, execution traces, and an exercise counting SequentialThinking and action-tool calls.
What it assumes
Assumes basic familiarity with agents and tools, but begins integration with a minimal server-and-agent setup.
What you can do after
Operate/configure it by attaching the MCP server to an agent, prompting its use, and inspecting tool calls in traces.
How it connects
Connects MCP tool use with chain-of-thought planning, ReAct, tree-of-thought, and Reflexion.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of AI Agents in Action, Second Edition. The section links point to the parts of the book it draws on.