server

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 15 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 = `` /* 2525-byte string literal not displayed */

Instructions are sent to the client at initialisation.

View Source
const PluginClient = "okvault-obsidian"

PluginClient is the Obsidian plugin's MCP client name. Its kb_ask calls are a person typing in the FAQ panel, not an agent's question, so they are not recorded as gaps.

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 FilterInfo added in v0.5.0

type FilterInfo struct {
	Name string `json:"name"`
	JQL  string `json:"jql"`
	URL  string `json:"url,omitempty" jsonschema:"the filter in Jira's issue search"`
}

FilterInfo is a ticket filter with its Jira search page.

type Gap added in v0.2.0

type Gap struct {
	ID         string       `json:"id"`
	Question   string       `json:"question" jsonschema:"the most asked phrasing still unanswered"`
	Phrasings  []string     `json:"phrasings" jsonschema:"unanswered phrasings, most asked first (aliases for the FAQ that answers them)"`
	Asked      int          `json:"asked"`
	FirstAsked time.Time    `json:"first_asked"`
	LastAsked  time.Time    `json:"last_asked"`
	Clients    []string     `json:"clients,omitempty" jsonschema:"MCP clients that asked"`
	Nearest    *NearFAQ     `json:"nearest_faq,omitempty" jsonschema:"the FAQ that came closest; a near miss often needs only an alias"`
	Related    []search.Hit `json:"related,omitempty" jsonschema:"notes agents were pointed to instead"`
}

Gap is a question agents asked that the vault cannot answer confidently yet, with the other ways they phrased it.

type GapsIn added in v0.2.0

type GapsIn struct {
	Limit   int    `json:"limit,omitempty" jsonschema:"max groups (default 20, max 100)"`
	Dismiss string `json:"dismiss,omitempty" jsonschema:"id of a group to hide from now on; only when a person asks for it"`
}

GapsIn is the kb_gaps input.

type GapsOut added in v0.2.0

type GapsOut struct {
	Total     int    `json:"total" jsonschema:"open gaps (before limit)"`
	Gaps      []Gap  `json:"gaps"`
	Answered  int    `json:"answered" jsonschema:"groups an FAQ answers now (hidden)"`
	Dismissed int    `json:"dismissed" jsonschema:"groups a person dismissed (hidden)"`
	Log       string `json:"log" jsonschema:"where this machine records the questions"`
}

GapsOut is the kb_gaps result.

func BuildGaps added in v0.2.0

func BuildGaps(ix *search.Index, log *gaps.Log, limit int) (GapsOut, error)

BuildGaps reads the log and returns the open gaps, most asked first. A phrasing an FAQ now answers confidently drops out; a group with none left counts as answered.

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 NearFAQ added in v0.2.0

type NearFAQ struct {
	Path       string  `json:"path"`
	Question   string  `json:"question"`
	Confidence float64 `json:"confidence"`
}

NearFAQ is the FAQ that came closest to answering a gap.

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
	// Gaps records the questions kb_ask cannot answer confidently and serves
	// kb_gaps (nil: off).
	Gaps *gaps.Log
}

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)"`
	Rescan bool   `` /* 173-byte string literal not displayed */
}

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.

Reloads and their refreshes overlap (the watcher, writes, git, rescan), so a refresh for an older snapshot can run after one for a newer snapshot. Each rebuild therefore uses the vault's current snapshot, one at a time: the last rebuild to run always indexes the newest snapshot. snap only says a reload happened.

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.

func (*Server) Tickets added in v0.5.0

func (s *Server) Tickets(ctx context.Context, name string, limit int) (*TicketsOut, error)

Tickets lists the configured ticket filters and, with a name, runs that one.

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 TicketRow added in v0.5.0

type TicketRow struct {
	tracker.Issue
	Linked    int `json:"linked_notes" jsonschema:"notes listing this ticket in their tickets frontmatter"`
	Mentioned int `json:"mentioned_in,omitempty" jsonschema:"notes mentioning the key in their text"`
}

TicketRow is a ticket in a filter's result, with the notes documenting it.

type TicketsIn added in v0.5.0

type TicketsIn struct {
	Filter string `` /* 127-byte string literal not displayed */
	Limit  int    `json:"limit,omitempty" jsonschema:"most tickets to return (default and max 50)"`
}

type TicketsOut added in v0.5.0

type TicketsOut struct {
	Filters     []FilterInfo `json:"filters"`
	Filter      *FilterInfo  `json:"filter,omitempty" jsonschema:"the filter that ran"`
	Tickets     []TicketRow  `json:"tickets,omitempty"`
	TrackerNote string       `json:"tracker_note,omitempty" jsonschema:"why the filter could not run"`
}

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