server

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 13 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 server exposes a vault over the Model Context Protocol.

Index

Constants

View Source
const Instructions = `` /* 2230-byte string literal not displayed */

Instructions are sent to the client at initialisation.

Variables

This section is empty.

Functions

This section is empty.

Types

type AskIn

type AskIn struct {
	Question string `json:"question" jsonschema:"the question, in natural language"`
}

type Count

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

type Entry

type Entry struct {
	Path        string `json:"path"`
	Title       string `json:"title"`
	Type        string `json:"type"`
	Description string `json:"description,omitempty"`
}

type GetIn

type GetIn struct {
	Path string `json:"path" jsonschema:"vault-relative path (e.g. faq/release.md), or a note title"`
}

type GetOut

type GetOut struct {
	Path        string         `json:"path"`
	Title       string         `json:"title"`
	Type        string         `json:"type"`
	Description string         `json:"description,omitempty"`
	Revision    string         `json:"revision" jsonschema:"pass as base_revision to kb_write when updating this note"`
	Owners      []string       `json:"owners,omitempty"`
	Tickets     []TicketLink   `json:"tickets,omitempty"`
	Frontmatter map[string]any `json:"frontmatter"`
	Body        string         `json:"body"`
	Links       []string       `json:"links,omitempty"`
	Backlinks   []string       `json:"backlinks,omitempty"`
	Broken      []string       `json:"broken_links,omitempty"`
}

type ListIn

type ListIn struct {
	Type string `json:"type,omitempty" jsonschema:"only notes of this type"`
	Tag  string `json:"tag,omitempty" jsonschema:"only notes with this tag"`
	Dir  string `json:"dir,omitempty" jsonschema:"only notes under this folder"`
}

type ListOut

type ListOut struct {
	Total   int     `json:"total"`
	Types   []Count `json:"types"`
	Tags    []Count `json:"tags"`
	Folders []Count `json:"folders"`
	Notes   []Entry `json:"notes"`
	Note    string  `json:"note,omitempty"`
}

type Options

type Options struct {
	ReadOnly bool
	Author   string // generated.by for writes, e.g. "claude-code"
	Version  string
	// Env looks up tracker credentials (os.Getenv in production). Nil means
	// no credentials: kb_ticket still returns the related notes.
	Env func(string) string
	// GitStatus reports the vault's git sync state (nil: git is off).
	GitStatus func() any
}

Options configure the server.

type ReviewIn

type ReviewIn struct {
	Owner  string `json:"owner,omitempty" jsonschema:"only notes owned by this person or group"`
	Reason string `json:"reason,omitempty" jsonschema:"only one reason: stale, unverified, draft, broken-links or no-owner"`
	Limit  int    `json:"limit,omitempty" jsonschema:"max items (default 25, max 200)"`
}

type ReviewOut

type ReviewOut struct {
	Total int                `json:"total"`
	Items []vault.ReviewItem `json:"items"`
	Git   any                `json:"git,omitempty"` // sync state: branch, pull request, problems
}

type SearchIn

type SearchIn struct {
	Query          string   `json:"query" jsonschema:"keywords; empty lists notes matching the filters"`
	Type           string   `json:"type,omitempty" jsonschema:"only notes of this OKF type, e.g. FAQ or Playbook"`
	Tags           []string `json:"tags,omitempty" jsonschema:"only notes carrying all these tags"`
	Dir            string   `json:"dir,omitempty" jsonschema:"only notes under this vault folder"`
	Ticket         string   `json:"ticket,omitempty" jsonschema:"only notes linked to or mentioning this ticket key, e.g. PROJ-123"`
	Owner          string   `json:"owner,omitempty" jsonschema:"only notes owned by this person or group"`
	Limit          int      `json:"limit,omitempty" jsonschema:"max hits (default 8, max 50)"`
	WithDeprecated bool     `json:"with_deprecated,omitempty" jsonschema:"include notes with status: deprecated"`
}

type SearchOut

type SearchOut struct {
	Hits []search.Hit `json:"hits"`
}

type Server

type Server struct {
	MCP *mcp.Server
	// contains filtered or unexported fields
}

Server binds a vault and its search index to MCP tools.

func New

func New(v *vault.Vault, ix *search.Index, opts Options) *Server

New builds the MCP server. The caller keeps the index fresh (see Refresh).

func (*Server) Refresh

func (s *Server) Refresh(snap *vault.Snapshot)

Refresh rebuilds the search index from a new snapshot.

func (*Server) TicketContext

func (s *Server) TicketContext(ctx context.Context, key string) (*TicketOut, error)

TicketContext gathers what the vault and the tracker know about a ticket.

type TicketIn

type TicketIn struct {
	Key string `json:"key" jsonschema:"ticket key, e.g. PROJ-123"`
}
type TicketLink struct {
	Key string `json:"key"`
	URL string `json:"url,omitempty"`
}

type TicketOut

type TicketOut struct {
	Key         string         `json:"key"`
	URL         string         `json:"url,omitempty"`
	Ticket      *tracker.Issue `json:"ticket,omitempty"`
	TrackerNote string         `json:"tracker_note,omitempty" jsonschema:"why the ticket itself could not be fetched"`
	Linked      []Entry        `json:"linked,omitempty" jsonschema:"notes listing this ticket in their tickets frontmatter"`
	Mentioned   []Entry        `json:"mentioned,omitempty" jsonschema:"notes mentioning the key in their text"`
	Suggested   []search.Hit   `json:"suggested,omitempty" jsonschema:"notes matching the ticket summary and labels"`
	Hint        string         `json:"hint"`
}

type WriteIn

type WriteIn struct {
	Path         string   `json:"path" jsonschema:"vault-relative .md path in kebab-case, e.g. faq/how-to-release.md"`
	Type         string   `json:"type,omitempty" jsonschema:"OKF type; required when creating (FAQ, Playbook, Reference, Decision, Tool ...)"`
	Title        string   `json:"title,omitempty" jsonschema:"display title; for FAQ the canonical question"`
	Description  string   `json:"description,omitempty" jsonschema:"one sentence summary, shown in indexes and search hits"`
	Tags         []string `json:"tags,omitempty" jsonschema:"tags (replaces existing tags when given)"`
	Aliases      []string `json:"aliases,omitempty" jsonschema:"alternative names; for FAQ other phrasings of the question"`
	Status       string   `json:"status,omitempty" jsonschema:"draft, stable or deprecated"`
	Body         string   `json:"body,omitempty" jsonschema:"Markdown body (replaces the existing body when given)"`
	Tickets      []string `json:"tickets,omitempty" jsonschema:"ticket keys this note documents, e.g. [PROJ-123] (replaces existing)"`
	Owners       []string `json:"owners,omitempty" jsonschema:"people or groups who own this note (replaces existing)"`
	BaseRevision string   `json:"base_revision,omitempty" jsonschema:"revision from kb_get; the write fails if the note changed since"`
	Mode         string   `json:"mode,omitempty" jsonschema:"create, update or upsert (default upsert)"`
	Note         string   `json:"note,omitempty" jsonschema:"short change note recorded in log.md"`
}

type WriteOut

type WriteOut struct {
	*vault.WriteResult
	Sync any `json:"sync,omitempty"` // branch, pull request, unpushed commits, problems
}

WriteOut is a write result plus the vault's git sync state.

Jump to

Keyboard shortcuts

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