Documentation
¶
Overview ¶
Package server exposes a vault over the Model Context Protocol.
Index ¶
- Constants
- type AskIn
- type Count
- type Entry
- type FilterInfo
- type Gap
- type GapsIn
- type GapsOut
- type GetIn
- type GetOut
- type ListIn
- type ListOut
- type NearFAQ
- type Options
- type ReviewIn
- type ReviewOut
- type SearchIn
- type SearchOut
- type Server
- type TicketIn
- type TicketLink
- type TicketOut
- type TicketRow
- type TicketsIn
- type TicketsOut
- type WriteIn
- type WriteOut
Constants ¶
const Instructions = `` /* 2525-byte string literal not displayed */
Instructions are sent to the client at initialisation.
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 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.
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 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 Server ¶
Server binds a vault and its search index to MCP tools.
func (*Server) Refresh ¶
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 ¶
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 ¶
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 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.