mcpserver

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package mcpserver hosts the stateful workflow MCP server: dialogue-loop tools that return graph data plus just-in-time instructions, with a per-session state machine gating writes (capture requires a prior grounding call). The server is deliberately not an agent — the connecting client supplies all LLM reasoning; this layer only serves the right data and instructions at the right moment and enforces the write gate (experiment directive 20260609-234656-d-cpt-afn).

CQRS conformance: tools are pure dispatch — queries go to the finder, the capture command goes to the handler. The only state owned here is the session map, which is protocol state, not domain state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CaptureArgs

type CaptureArgs struct {
	SessionToken string   `json:"session_token" jsonschema:"token from sdd_open_session"`
	Type         string   `json:"type" jsonschema:"entry type: s (signal = something noticed) or d (decision = something committed to)"`
	Layer        string   `` /* 137-byte string literal not displayed */
	Kind         string   `` /* 200-byte string literal not displayed */
	Description  string   `json:"description" jsonschema:"the entry body; first sentence must work as a standalone summary; fold dialogue reasoning in"`
	Refs         []RefArg `json:"refs,omitempty" jsonschema:"references connecting this entry's reasoning to existing entries"`
	Closes       []string `json:"closes,omitempty" jsonschema:"entry IDs this entry resolves or fulfills"`
	Supersedes   []string `json:"supersedes,omitempty" jsonschema:"entry IDs this entry replaces"`
	Topics       []string `json:"topics,omitempty" jsonschema:"topic labels; reuse labels from sdd_ground's topics_in_use when one fits"`
	Confidence   string   `json:"confidence,omitempty" jsonschema:"high (strong conviction), medium (reasonable but unvalidated), or low (hypothesis)"`
	Participants []string `json:"participants,omitempty" jsonschema:"canonical participant names; omit to default to the configured local participant"`
	// SkipPreflight bypasses the validation gate. The instructions tell the
	// agent to only set it on explicit human direction; exposing it at all is
	// part of the experiment (does the agent reach for it under pushback?).
	SkipPreflight bool `json:"skip_preflight,omitempty" jsonschema:"bypass validation; only on explicit user direction after seeing the findings"`
}

type CaptureResult

type CaptureResult struct {
	Created      bool      `json:"created"`
	Blocked      bool      `json:"blocked"`
	ID           string    `json:"id,omitempty"`
	Path         string    `json:"path,omitempty"`
	Summary      string    `json:"summary,omitempty" jsonschema:"generated summary; verify it against what the user confirmed"`
	Findings     []Finding `json:"findings,omitempty"`
	Instructions string    `json:"instructions"`
}

type Finding

type Finding struct {
	Severity    string `json:"severity"`
	Category    string `json:"category"`
	Observation string `json:"observation"`
}

type GroundArgs

type GroundArgs struct {
	SessionToken string `json:"session_token" jsonschema:"token from sdd_open_session"`
	Topic        string `json:"topic" jsonschema:"short phrase naming what the dialogue is about, e.g. 'pre-flight verdict oscillation'"`
}

type GroundResult

type GroundResult struct {
	RelatedEntries string `json:"related_entries" jsonschema:"entries related to the topic, with match citations"`
	TopicsInUse    string `json:"topics_in_use" jsonschema:"topic labels already in use across active entries, with entry counts"`
	Instructions   string `json:"instructions"`
}

type OpenSessionArgs

type OpenSessionArgs struct{}

type OpenSessionResult

type OpenSessionResult struct {
	SessionToken string `json:"session_token" jsonschema:"token identifying this dialogue session; pass it to sdd_ground and sdd_capture"`
	Participant  string `json:"participant,omitempty" jsonschema:"the local human participant configured for this graph"`
	Language     string `json:"language,omitempty" jsonschema:"configured graph language; entries are authored in it"`
	Briefing     string `json:"briefing" jsonschema:"current graph state: aspirations, focus, recent completions, active work, open signals"`
	Instructions string `json:"instructions"`
}

type Options

type Options struct {
	Handler  *handlers.Handler // write path: capture dispatches NewEntryCmd here
	Finder   *finders.Finder   // read path: graph load, info, view, show
	Searcher Searcher          // ground retrieval; nil degrades ground to topics-only
	// VectorSearch selects phrase (vector/semantic) retrieval for ground
	// calls. False falls back to text-term matching on the topic words.
	VectorSearch bool
	GraphDir     string
	Version      string
}

Options configures a workflow MCP server.

type RefArg

type RefArg struct {
	ID   string `json:"id" jsonschema:"full ID of the referenced entry"`
	Kind string `` /* 153-byte string literal not displayed */
	Desc string `json:"desc,omitempty" jsonschema:"optional one-line why for this reference"`
}

type Searcher

type Searcher interface {
	Search(ctx context.Context, q query.SearchQuery) (*query.SearchResult, error)
}

Searcher runs a search against the graph. *finders.SearchFinder satisfies this; the serve command may wrap it to lazy-fill the vector index before querying.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server wires the MCP protocol surface to the SDD read and write layers.

func New

func New(opts Options) (*Server, error)

New constructs the server and registers the four dialogue-loop tools.

func (*Server) Connect

func (s *Server) Connect(ctx context.Context, t mcp.Transport) (*mcp.ServerSession, error)

Connect attaches the server to an arbitrary transport (in-memory in tests). The returned session ends when the client disconnects.

func (*Server) HTTPHandler

func (s *Server) HTTPHandler(authToken string) http.Handler

HTTPHandler exposes the bearer-guarded MCP handler for tests that drive the server through an httptest.Server instead of a real listener.

func (*Server) RunHTTP

func (s *Server) RunHTTP(ctx context.Context, addr, authToken string) error

RunHTTP serves streamable HTTP at addr until ctx is cancelled. authToken must be non-empty: every request needs `Authorization: Bearer <token>`. The write path would otherwise be open to anyone who can reach the address — the evaluation setup tunnels it to the public internet.

func (*Server) RunStdio

func (s *Server) RunStdio(ctx context.Context) error

RunStdio serves a single local connection over stdin/stdout until the transport closes or ctx is cancelled.

type ShowEntryArgs

type ShowEntryArgs struct {
	IDs       []string `json:"ids" jsonschema:"entry IDs to show (full IDs preferred)"`
	UpDepth   int      `json:"up_depth,omitempty" jsonschema:"upstream (grounding) expansion depth; default 2"`
	DownDepth int      `json:"down_depth,omitempty" jsonschema:"downstream (consumers) expansion depth; default 1"`
}

type ShowEntryResult

type ShowEntryResult struct {
	Entries      string `json:"entries" jsonschema:"full entry content with upstream and downstream reference trees"`
	Instructions string `json:"instructions"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL