Documentation
¶
Overview ¶
Package sequentialthinking implements an MCP source that exposes a dynamic, reflective problem-solving tool. The single tool (`sequentialthinking`) lets the LLM break a problem into steps, revise earlier thoughts, and branch into alternative reasoning paths while keeping the reasoning state across calls in the same source instance.
This is a Go port of the upstream `@modelcontextprotocol/server-sequential-thinking` (MIT, modelcontextprotocol org): tool name, input/output schema, annotations, and core semantics are kept 1:1 with upstream. The only behavioral change is that the upstream chalk-colored ASCII box written to stderr is replaced by a structured slog record so it composes with the meta-server's LOG_LEVEL / LOG_JSON switches.
Per-type Connect accepts an optional `disable_thought_logging` flag via the `connect:` map and returns a single tool. State is created once at Connect time and captured in the tool handler's closure; two `sequentialthinking` sources in the same config get independent state. A single source's state is mutex-protected because the MCP Go SDK handles tool calls concurrently.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Connect ¶
func Connect( _ context.Context, connect map[string]any, opts ...tool.Option, ) (tool.Response, error)
Connect decodes the source's `connect:` map, builds the per-source state, and returns the single `sequentialthinking` tool. The tool advertises ReadOnlyHint=true, DestructiveHint=false, IdempotentHint=true, OpenWorldHint=false — matching upstream's annotations 1:1.
Types ¶
type ThoughtData ¶
type ThoughtData struct {
Thought string `json:"thought"`
ThoughtNumber int `json:"thought_number"`
TotalThoughts int `json:"total_thoughts"`
IsRevision bool `json:"is_revision,omitzero"`
RevisesThought int `json:"revises_thought,omitzero"`
BranchFromThought int `json:"branch_from_thought,omitzero"`
BranchID string `json:"branch_id,omitzero"`
NeedsMoreThoughts bool `json:"needs_more_thoughts,omitzero"`
NextThoughtNeeded bool `json:"next_thought_needed"`
}
ThoughtData is the structured form of a single call to the sequentialthinking tool. It mirrors the upstream TypeScript `ThoughtData` interface 1:1; field names use snake_case because that is what the wire JSON uses (per the input schema).
type ThoughtResponse ¶
type ThoughtResponse struct {
ThoughtNumber int `json:"thought_number"`
TotalThoughts int `json:"total_thoughts"`
NextThoughtNeeded bool `json:"next_thought_needed"`
Branches []string `json:"branches"`
ThoughtHistoryLength int `json:"thought_history_length"`
}
ThoughtResponse is the structured form of the tool's response. It mirrors the upstream outputSchema 1:1; field names use snake_case to match the JSON contract.