{"modulePath":"github.com/modelcontextprotocol/go-sdk","version":"v1.8.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package main\n\n## Functions\n\n```go\nfunc ContinueThinking(ctx context.Context, req *mcp.CallToolRequest, args ContinueThinkingArgs) (*mcp.CallToolResult, any, error)\n```\nContinueThinking adds the next thought step, revises a previous step, or creates a branch in the thinking process.\n\n```go\nfunc ReviewThinking(ctx context.Context, req *mcp.CallToolRequest, args ReviewThinkingArgs) (*mcp.CallToolResult, any, error)\n```\nReviewThinking provides a complete review of the thinking process for a session.\n\n```go\nfunc StartThinking(ctx context.Context, _ *mcp.CallToolRequest, args StartThinkingArgs) (*mcp.CallToolResult, any, error)\n```\nStartThinking begins a new sequential thinking session for a complex problem.\n\n```go\nfunc ThinkingHistory(ctx context.Context, req *mcp.ReadResourceRequest) (*mcp.ReadResourceResult, error)\n```\nThinkingHistory handles resource requests for thinking session data and history.\n\n## Types\n\n```go\ntype ContinueThinkingArgs struct {\n\tSessionID      string `json:\"sessionId\"`\n\tThought        string `json:\"thought\"`\n\tNextNeeded     *bool  `json:\"nextNeeded,omitempty\"`\n\tReviseStep     *int   `json:\"reviseStep,omitempty\"`\n\tCreateBranch   bool   `json:\"createBranch,omitempty\"`\n\tEstimatedTotal int    `json:\"estimatedTotal,omitempty\"`\n}\n```\nContinueThinkingArgs are the arguments for continuing a thinking session.\n\n```go\ntype ReviewThinkingArgs struct {\n\tSessionID string `json:\"sessionId\"`\n}\n```\nReviewThinkingArgs are the arguments for reviewing a thinking session.\n\n```go\ntype SessionStore struct {\n\t// contains filtered or unexported fields\n}\n```\nA SessionStore is a global session store (in a real implementation, this might be a database).\n\nLocking Strategy: The SessionStore uses a RWMutex to protect the sessions map from concurrent access. All ThinkingSession modifications happen on deep copies, never on shared instances. This means: - Read locks protect map access. - Write locks protect map modifications (adding/removing/replacing sessions) - Session field modifications always happen on local copies via CompareAndSwap - No shared ThinkingSession state is ever modified directly\n\n```go\nfunc NewSessionStore() *SessionStore\n```\nNewSessionStore creates a new session store for managing thinking sessions.\n\n```go\nfunc (s *SessionStore) CompareAndSwap(sessionID string, updateFunc func(*ThinkingSession) (*ThinkingSession, error)) error\n```\nCompareAndSwap atomically updates a session if the version matches. Returns true if the update succeeded, false if there was a version mismatch.\n\nThis method implements optimistic concurrency control: 1. Read lock to safely access the map and copy the session 2. Deep copy the session (all modifications happen on this copy) 3. Release read lock and apply updates to the copy 4. Write lock to check version and atomically update if unchanged\n\nThe read lock in step 1 is necessary to prevent map access races, not to protect ThinkingSession fields (which are never modified in-place).\n\n```go\nfunc (s *SessionStore) Session(id string) (*ThinkingSession, bool)\n```\nSession retrieves a thinking session by ID, returning the session and whether it exists.\n\n```go\nfunc (s *SessionStore) SessionSnapshot(id string) (*ThinkingSession, bool)\n```\nSessionSnapshot returns a deep copy of a session for safe concurrent access. The second return value reports whether a session with the given id exists.\n\n```go\nfunc (s *SessionStore) Sessions() []*ThinkingSession\n```\nSessions returns all thinking sessions in the store.\n\n```go\nfunc (s *SessionStore) SessionsSnapshot() []*ThinkingSession\n```\nSessionsSnapshot returns a deep copy of all sessions for safe concurrent access.\n\n```go\nfunc (s *SessionStore) SetSession(session *ThinkingSession)\n```\nSetSession stores or updates a thinking session in the store.\n\n```go\ntype StartThinkingArgs struct {\n\tProblem        string `json:\"problem\"`\n\tSessionID      string `json:\"sessionId,omitempty\"`\n\tEstimatedSteps int    `json:\"estimatedSteps,omitempty\"`\n}\n```\nStartThinkingArgs are the arguments for starting a new thinking session.\n\n```go\ntype ThinkingHistoryArgs struct {\n\tSessionID string `json:\"sessionId\"`\n}\n```\nThinkingHistoryArgs are the arguments for retrieving thinking history.\n\n```go\ntype ThinkingSession struct {\n\t// Globally unique ID of the session.\n\tID string `json:\"id\"`\n\t// Problem to solve.\n\tProblem string `json:\"problem\"`\n\t// Thoughts in the session.\n\tThoughts []*Thought `json:\"thoughts\"`\n\t// Current thought index.\n\tCurrentThought int `json:\"currentThought\"`\n\t// Estimated total number of thoughts.\n\tEstimatedTotal int `json:\"estimatedTotal\"`\n\t// Status of the session.\n\tStatus string `json:\"status\"` // \"active\", \"completed\", \"paused\"\n\t// Time the session was created.\n\tCreated time.Time `json:\"created\"`\n\t// Time the session was last active.\n\tLastActivity time.Time `json:\"lastActivity\"`\n\t// Branches in the session. Alternative thought paths.\n\tBranches []string `json:\"branches,omitempty\"`\n\t// Version for optimistic concurrency control.\n\tVersion int `json:\"version\"`\n}\n```\nA ThinkingSession is an active thinking session.\n\n```go\ntype Thought struct {\n\t// Index of the thought within the session (1-based).\n\tIndex int `json:\"index\"`\n\t// Content of the thought.\n\tContent string `json:\"content\"`\n\t// Time the thought was created.\n\tCreated time.Time `json:\"created\"`\n\t// Whether the thought has been revised.\n\tRevised bool `json:\"revised\"`\n\t// Index of parent thought, or nil if this is a root for branching.\n\tParentIndex *int `json:\"parentIndex,omitempty\"`\n}\n```\nA Thought is a single step in the thinking process.\n\n","path":"github.com/modelcontextprotocol/go-sdk/examples/server/sequentialthinking","name":"main","synopsis":"","isRedistributable":true}
