mcpserver

package
v0.0.0-...-d7aa690 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 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 mcpserver exposes MindCLI's read-only knowledge operations through bounded, redacted transport-neutral methods and an MCP adapter.

Index

Constants

View Source
const (
	DefaultResultLimit       = 10
	MaxResultLimit           = 50
	MaxQueryBytes            = 4096
	MaxFilterValues          = 50
	MaxFilterValueBytes      = 512
	MaxDocumentContentBytes  = 20 * 1024
	MaxTitleBytes            = 4096
	MaxPathBytes             = 8192
	MaxPreviewBytes          = 1024
	MaxMetadataFields        = 50
	MaxMetadataValueBytes    = 1024
	MaxAnswerBytes           = 32 * 1024
	MaxAskSources            = 5
	MaxAskContextBytesPerDoc = 4096
)

Variables

This section is empty.

Functions

func New

func New(service *Service, version string, logger *slog.Logger) *mcp.Server

New creates an MCP server exposing only MindCLI's read-only operations.

Types

type AnswerGenerator

type AnswerGenerator interface {
	GenerateAnswer(context.Context, string, []string) (string, error)
}

AnswerGenerator is the non-streaming LLM behavior used by the ask tool.

type AskInput

type AskInput struct {
	Question string      `json:"question" jsonschema:"question to answer from the local knowledge index"`
	Limit    int         `json:"limit,omitempty" jsonschema:"maximum retrieved documents from 1 to 50"`
	Filters  FilterInput `json:"filters,omitempty" jsonschema:"typed filters applied before answer generation"`
}

type AskOutput

type AskOutput struct {
	Answer     string           `json:"answer"`
	Confidence ConfidenceOutput `json:"confidence"`
	Citations  []DocumentOutput `json:"citations"`
}

type CollectionOutput

type CollectionOutput struct {
	ID            string    `json:"id"`
	Name          string    `json:"name"`
	Description   string    `json:"description,omitempty"`
	Query         string    `json:"query,omitempty"`
	CreatedAt     time.Time `json:"created_at"`
	DocumentCount int       `json:"document_count,omitempty"`
}

type ConfidenceOutput

type ConfidenceOutput struct {
	Score float64 `json:"score"`
	Level string  `json:"level"`
}

type DocumentOutput

type DocumentOutput struct {
	ID         string            `json:"id"`
	Source     string            `json:"source"`
	Path       string            `json:"path"`
	Title      string            `json:"title"`
	Content    string            `json:"content,omitempty"`
	Preview    string            `json:"preview,omitempty"`
	Metadata   map[string]string `json:"metadata,omitempty"`
	IndexedAt  time.Time         `json:"indexed_at"`
	ModifiedAt time.Time         `json:"modified_at"`
	Truncated  bool              `json:"truncated,omitempty"`
}

type FilterInput

type FilterInput struct {
	Sources       []string `` /* 128-byte string literal not displayed */
	Tags          []string `json:"tags,omitempty" jsonschema:"tags every result must contain"`
	ExcludedTags  []string `json:"excluded_tags,omitempty" jsonschema:"tags results must not contain"`
	Collections   []string `json:"collections,omitempty" jsonschema:"collection names; multiple names form a union"`
	After         string   `json:"after,omitempty" jsonschema:"inclusive YYYY-MM-DD or RFC3339 timestamp"`
	Before        string   `json:"before,omitempty" jsonschema:"exclusive YYYY-MM-DD or RFC3339 timestamp"`
	Paths         []string `json:"paths,omitempty" jsonschema:"case-insensitive path fragments every result must contain"`
	Domains       []string `json:"domains,omitempty" jsonschema:"domains or parent domains to match"`
	Kinds         []string `json:"kinds,omitempty" jsonschema:"source-specific record kinds such as bookmark"`
	ExactPhrases  []string `json:"exact_phrases,omitempty" jsonschema:"exact phrases every result must contain"`
	ExcludedTerms []string `json:"excluded_terms,omitempty" jsonschema:"words or phrases results must not contain"`
	RelativeTime  string   `json:"relative_time,omitempty" jsonschema:"today, yesterday, this week, last week, this month, last month, or last year"`
}

FilterInput is the typed MCP representation of MindCLI's structured filters.

type GetDocumentInput

type GetDocumentInput struct {
	ID              string `json:"id" jsonschema:"stable document ID"`
	MaxContentBytes int    `json:"max_content_bytes,omitempty" jsonschema:"content bound from 1 to 20480 bytes"`
}

type ListCollectionsOutput

type ListCollectionsOutput struct {
	Collections []CollectionOutput `json:"collections"`
}

type RecentDocumentsInput

type RecentDocumentsInput struct {
	Since  string `json:"since,omitempty" jsonschema:"lookback such as 7d, 2w, or 24h, or an inclusive timestamp"`
	Before string `json:"before,omitempty" jsonschema:"exclusive YYYY-MM-DD or RFC3339 timestamp; defaults to now"`
	Limit  int    `json:"limit,omitempty" jsonschema:"maximum documents from 1 to 50"`
}

type RecentDocumentsOutput

type RecentDocumentsOutput struct {
	After     time.Time        `json:"after"`
	Before    time.Time        `json:"before"`
	Documents []DocumentOutput `json:"documents"`
}

type RelatedDocumentsInput

type RelatedDocumentsInput struct {
	ID    string `json:"id" jsonschema:"stable source document ID"`
	Limit int    `json:"limit,omitempty" jsonschema:"maximum related documents from 1 to 50"`
}

type RelatedDocumentsOutput

type RelatedDocumentsOutput struct {
	Source  DocumentOutput        `json:"source"`
	Results []RelatedResultOutput `json:"results"`
}

type RelatedResultOutput

type RelatedResultOutput struct {
	Document DocumentOutput         `json:"document"`
	Score    float64                `json:"score"`
	Reasons  []query.RelationReason `json:"reasons"`
}

type SearchInput

type SearchInput struct {
	Query   string      `json:"query,omitempty" jsonschema:"search text, optionally including MindCLI structured query syntax"`
	Limit   int         `json:"limit,omitempty" jsonschema:"maximum results from 1 to 50"`
	Filters FilterInput `json:"filters,omitempty" jsonschema:"typed filters combined with filters in query"`
}

type SearchOutput

type SearchOutput struct {
	Results       []SearchResultOutput `json:"results"`
	ActiveFilters []string             `json:"active_filters,omitempty"`
}

type SearchResultOutput

type SearchResultOutput struct {
	Document   DocumentOutput `json:"document"`
	Score      float64        `json:"score"`
	Highlights []string       `json:"highlights,omitempty"`
}

type Searcher

type Searcher interface {
	SearchParsed(context.Context, query.ParsedQuery, int) (storage.SearchResults, error)
	Related(context.Context, string, int) ([]query.RelatedResult, error)
}

Searcher is the read-only retrieval behavior required by the MCP service.

type Service

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

Service implements the bounded read-only operations exposed as MCP tools.

func NewService

func NewService(db *storage.DB, searcher Searcher, llm AnswerGenerator, redactor privacy.Redactor) *Service

NewService creates a read-only service over an existing MindCLI index.

func (*Service) Ask

func (s *Service) Ask(ctx context.Context, input AskInput) (AskOutput, error)

func (*Service) GetDocument

func (s *Service) GetDocument(ctx context.Context, input GetDocumentInput) (DocumentOutput, error)

func (*Service) ListCollections

func (s *Service) ListCollections(ctx context.Context) (ListCollectionsOutput, error)

func (*Service) RecentDocuments

func (s *Service) RecentDocuments(ctx context.Context, input RecentDocumentsInput) (RecentDocumentsOutput, error)

func (*Service) RelatedDocuments

func (s *Service) RelatedDocuments(ctx context.Context, input RelatedDocumentsInput) (RelatedDocumentsOutput, error)

func (*Service) Search

func (s *Service) Search(ctx context.Context, input SearchInput) (SearchOutput, error)

func (*Service) ShowCollection

func (s *Service) ShowCollection(ctx context.Context, input ShowCollectionInput) (ShowCollectionOutput, error)

type ShowCollectionInput

type ShowCollectionInput struct {
	Name  string `json:"name" jsonschema:"collection name"`
	Limit int    `json:"limit,omitempty" jsonschema:"maximum documents from 1 to 50"`
}

type ShowCollectionOutput

type ShowCollectionOutput struct {
	Collection CollectionOutput `json:"collection"`
	Documents  []DocumentOutput `json:"documents"`
}

Jump to

Keyboard shortcuts

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