mcpserver

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mcpserver is `unpause mcp`: a read-only MCP server that lets another assistant list, search and read Sessions. It never writes to a Transcript.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogPath added in v0.9.0

func LogPath(cachePath string) string

LogPath is the Access log next to the index cache at cachePath.

func New

func New(version string, load Loader, rec Recorder) *mcp.Server

New builds the server with its three read-only tools, each call recorded by rec.

func Run

func Run(ctx context.Context, version string, load Loader, rec Recorder) error

Run serves over stdin and stdout until the client disconnects or ctx ends. rec gets one Access log Entry per tool call.

Types

type AccessLog added in v0.9.0

type AccessLog struct {
	Path    string
	MaxSize int64
	Stderr  io.Writer // where a failed write is reported
	// contains filtered or unexported fields
}

AccessLog appends Entries to a JSON-lines file, rotating it to Path+".1" once it reaches MaxSize. The file is 0600: it shows what was read.

func NewAccessLog added in v0.9.0

func NewAccessLog(path string) *AccessLog

NewAccessLog logs to path, rotating at 10 MB.

func (*AccessLog) Record added in v0.9.0

func (l *AccessLog) Record(e Entry)

Record appends e as one line. A failure goes to Stderr; it never fails the tool call.

type Entry added in v0.9.0

type Entry struct {
	At            string          `json:"at"`
	Client        string          `json:"client"`
	ClientVersion string          `json:"client_version"`
	Tool          string          `json:"tool"`
	Input         json.RawMessage `json:"input"`
	SessionIDs    []string        `json:"session_ids"`
	Count         int             `json:"count"`
	Total         int             `json:"total"`
	DurationMS    int64           `json:"duration_ms"`
	Error         string          `json:"error,omitempty"`
}

Entry is one line of the Access log: one tool call. It holds what the client sent and which Sessions came back, never message text, titles, snippets or folders (ADR 0013).

func ReadLog added in v0.9.0

func ReadLog(path string) ([]Entry, error)

ReadLog reads the rotated file and then the current one, oldest first. Missing files are no Entries; lines that don't parse, or are over maxLine, are skipped.

type GetInput

type GetInput struct {
	ID       string `json:"id" jsonschema:"session id, id prefix, or Name (same lookup as unpause open)"`
	Offset   int    `json:"offset,omitempty" jsonschema:"index of the first message, default 0"`
	Limit    int    `json:"limit,omitempty" jsonschema:"messages per page, default 50, max 200"`
	MaxChars int    `json:"max_chars,omitempty" jsonschema:"longest content block kept whole, default 20000; longer ones are cut"`
	// MaxTotalChars keeps one result under what clients accept from a tool.
	MaxTotalChars int `` /* 293-byte string literal not displayed */
}

GetInput is get_session's arguments.

type GetOutput

type GetOutput struct {
	Session    Summary              `json:"session"`
	Total      int                  `json:"total"`
	Offset     int                  `json:"offset"`
	NextOffset *int                 `json:"next_offset,omitempty"`
	Messages   []claude.FullMessage `json:"messages"`
}

GetOutput is get_session's result.

type ListInput

type ListInput struct {
	Account string `json:"account,omitempty" jsonschema:"only this Account label, exact (e.g. personal, work)"`
	Project string `json:"project,omitempty" jsonschema:"case-insensitive substring of the working directory"`
	Live    *bool  `json:"live,omitempty" jsonschema:"true: only sessions running now; false: only ones that are not"`
	Limit   int    `json:"limit,omitempty" jsonschema:"page size, default 20, max 100"`
	Offset  int    `json:"offset,omitempty" jsonschema:"how many to skip, default 0"`
}

ListInput is list_sessions' arguments.

type ListOutput

type ListOutput struct {
	Total      int       `json:"total"`
	Offset     int       `json:"offset"`
	NextOffset *int      `json:"next_offset,omitempty" jsonschema:"offset of the next page; absent on the last page"`
	Sessions   []Summary `json:"sessions"`
}

ListOutput is list_sessions' result.

type Loader

type Loader func(ctx context.Context) (sessions []*session.Session, exclude []string, err error)

Loader returns the Sessions to serve, newest first and already default-filtered (non-empty, not sidechain), plus the mcp exclude globs. It runs on every tool call.

type Recorder added in v0.9.0

type Recorder func(Entry)

Recorder receives one Entry per tool call. A nil Recorder records nothing.

type SearchHit

type SearchHit struct {
	Summary
	Hits     int      `json:"hits" jsonschema:"total matches of all terms"`
	Snippets []string `json:"snippets" jsonschema:"up to 3 excerpts around a match"`
}

SearchHit is one matching Session.

type SearchInput

type SearchInput struct {
	Query   string `` /* 156-byte string literal not displayed */
	Account string `json:"account,omitempty" jsonschema:"only this Account label, exact"`
	Project string `json:"project,omitempty" jsonschema:"case-insensitive substring of the working directory"`
	Limit   int    `json:"limit,omitempty" jsonschema:"page size, default 10, max 50"`
	Offset  int    `json:"offset,omitempty" jsonschema:"how many to skip, default 0"`
}

SearchInput is search_sessions' arguments.

type SearchOutput

type SearchOutput struct {
	Total      int         `json:"total"`
	Offset     int         `json:"offset"`
	NextOffset *int        `json:"next_offset,omitempty"`
	Results    []SearchHit `json:"results"`
}

SearchOutput is search_sessions' result.

type Stats added in v0.9.0

type Stats struct {
	Calls      int       `json:"calls"`
	Errors     int       `json:"errors"`
	First      time.Time `json:"first,omitzero"`
	Last       time.Time `json:"last,omitzero"`
	Tools      []Tally   `json:"tools"`
	Clients    []Tally   `json:"clients"`
	MostRead   []Tally   `json:"most_read"` // Session ids by successful get_session calls
	TopQueries []Tally   `json:"top_queries"`
}

Stats summarizes the Access log for `unpause mcp stats`.

func Summarize added in v0.9.0

func Summarize(entries []Entry, since time.Time) Stats

Summarize counts the Entries at or after since (all of them when since is zero). Entries whose time doesn't parse are skipped.

type Summary

type Summary struct {
	ID         string `json:"id"`
	Title      string `json:"title"`
	Account    string `json:"account"`
	Project    string `json:"project" jsonschema:"repo folder name"`
	CWD        string `json:"cwd"`
	Branch     string `json:"branch,omitempty"`
	Created    string `json:"created,omitempty"`
	LastActive string `json:"last_active,omitempty"`
	Messages   int    `json:"messages" jsonschema:"user prompts plus assistant replies"`
	Live       string `json:"live,omitempty" jsonschema:"busy or idle when the session is running now"`
	Cowork     bool   `json:"cowork,omitempty" jsonschema:"a Claude Desktop Cowork session"`
}

Summary is how a Session is described in every tool's output.

type Tally added in v0.9.0

type Tally struct {
	Name  string `json:"name"`
	Count int    `json:"count"`
}

Tally is a name and how often it came up.

Jump to

Keyboard shortcuts

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