server

package
v0.0.0-...-1125d44 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package server implements the MCP server that exposes documentation tools to AI assistants.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterGlossaryTools

func RegisterGlossaryTools(s *mcp.Server, holder *StateHolder)

RegisterGlossaryTools registers the lookup_term, list_glossary, and explain_page tools.

func RegisterReindexTool

func RegisterReindexTool(s *mcp.Server, holder *StateHolder, configLoader func() (*config.UserConfig, *config.ResolvedConfig, error))

RegisterReindexTool registers the reindex tool that rebuilds the search index.

func RegisterResources

func RegisterResources(s *mcp.Server, holder *StateHolder)

func RegisterTools

func RegisterTools(s *mcp.Server, holder *StateHolder)

RegisterTools registers all read-only MCP tools on the server.

func RegisterWriteTools

func RegisterWriteTools(s *mcp.Server, holder *StateHolder)

RegisterWriteTools registers the write_page, edit_page, and append_to_page tools.

Types

type FullBuildResult

type FullBuildResult struct {
	State       *ServerState
	FileResults map[string]*index.FileResult
}

FullBuildResult holds the server state and per-file results from a full index build.

func BuildServerState

func BuildServerState(cfg *config.ResolvedConfig, userCfg *config.UserConfig, provider search.EmbeddingProvider, onProgress ...index.ProgressFunc) *FullBuildResult

BuildServerState builds a complete ServerState from resolved config by indexing all sources. An optional progress callback can be provided to report indexing progress.

type ServerState

type ServerState struct {
	Index             *index.DocIndex
	Config            *config.ResolvedConfig
	UserConfig        *config.UserConfig
	Synonyms          map[string][]string
	Pins              map[string]struct{}
	LinkIndex         *index.LinkIndex
	PageVectors       map[string]*search.PageVector
	Glossary          *index.GlossaryIndex
	Templates         *index.TemplateIndex
	EmbeddingProvider search.EmbeddingProvider
	SemanticWeight    float64
}

ServerState holds the fully built index, config, and derived data structures for the MCP server.

func AwaitState

func AwaitState(ctx context.Context, holder *StateHolder) (*ServerState, error)

AwaitState blocks until the index is ready, then returns the current state.

func BuildServerStateFromIndex

func BuildServerStateFromIndex(idx *index.DocIndex, cfg *config.ResolvedConfig, userCfg *config.UserConfig, provider search.EmbeddingProvider) *ServerState

BuildServerStateFromIndex builds a ServerState from a pre-built DocIndex, skipping the expensive indexing step. Used when restoring from cache.

func ReindexPage

func ReindexPage(state *ServerState, source, page, filePath string) *ServerState

type StateHolder

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

StateHolder provides thread-safe access to the current ServerState. It includes a readiness gate so the MCP server can start immediately while indexing runs in the background.

func NewStateHolder

func NewStateHolder(s *ServerState) *StateHolder

NewStateHolder creates a StateHolder with the given initial state. If s is non-nil the holder is immediately ready. If s is nil the holder starts in a not-ready state; call MarkReady or MarkFailed to signal completion.

func (*StateHolder) Get

func (h *StateHolder) Get() *ServerState

Get returns the current server state.

func (*StateHolder) MarkFailed

func (h *StateHolder) MarkFailed(err error)

MarkFailed records an indexing error and signals that startup is complete (with failure).

func (*StateHolder) MarkReady

func (h *StateHolder) MarkReady(s *ServerState)

MarkReady sets the state and signals that the server is ready to handle requests.

func (*StateHolder) Set

func (h *StateHolder) Set(s *ServerState)

Set replaces the current server state.

func (*StateHolder) WaitReady

func (h *StateHolder) WaitReady(ctx context.Context) error

WaitReady blocks until the holder is ready or the context is cancelled. Returns nil on success, the indexing error if startup failed, or the context error if the caller's deadline expired.

Jump to

Keyboard shortcuts

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