tools

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Analyze

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

Analyze implements graph analysis MCP tools.

func NewAnalyze

func NewAnalyze(c backend.Backend) *Analyze

NewAnalyze creates a new Analyze tool handler with a 30-second graph cache.

func (*Analyze) FindConnections

func (a *Analyze) FindConnections(ctx context.Context, req *mcp.CallToolRequest, input types.FindConnectionsInput) (*mcp.CallToolResult, any, error)

FindConnections finds how two pages are connected in the graph.

func (*Analyze) GraphOverview

func (a *Analyze) GraphOverview(ctx context.Context, req *mcp.CallToolRequest, input types.GraphOverviewInput) (*mcp.CallToolResult, any, error)

GraphOverview returns global graph statistics.

func (*Analyze) KnowledgeGaps

func (a *Analyze) KnowledgeGaps(ctx context.Context, req *mcp.CallToolRequest, input types.KnowledgeGapsInput) (*mcp.CallToolResult, any, error)

KnowledgeGaps finds sparse areas in the knowledge graph.

func (*Analyze) ListOrphans

func (a *Analyze) ListOrphans(ctx context.Context, req *mcp.CallToolRequest, input types.ListOrphansInput) (*mcp.CallToolResult, any, error)

ListOrphans returns the actual orphan page names (not just a count).

func (*Analyze) TopicClusters

func (a *Analyze) TopicClusters(ctx context.Context, req *mcp.CallToolRequest, input types.TopicClustersInput) (*mcp.CallToolResult, any, error)

TopicClusters finds community clusters in the knowledge graph.

type Decision

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

Decision implements decision protocol MCP tools.

func NewDecision

func NewDecision(c backend.Backend) *Decision

NewDecision creates a new Decision tool handler.

func (*Decision) AnalysisHealth

func (d *Decision) AnalysisHealth(ctx context.Context, req *mcp.CallToolRequest, input types.AnalysisHealthInput) (*mcp.CallToolResult, any, error)

AnalysisHealth audits analysis/strategy pages for graph connectivity.

func (*Decision) DecisionCheck

func (d *Decision) DecisionCheck(ctx context.Context, req *mcp.CallToolRequest, input types.DecisionCheckInput) (*mcp.CallToolResult, any, error)

DecisionCheck surfaces all decisions, highlighting overdue ones.

func (*Decision) DecisionCreate

func (d *Decision) DecisionCreate(ctx context.Context, req *mcp.CallToolRequest, input types.DecisionCreateInput) (*mcp.CallToolResult, any, error)

DecisionCreate creates a new DECIDE block with #decision tag and deadline.

func (*Decision) DecisionDefer

func (d *Decision) DecisionDefer(ctx context.Context, req *mcp.CallToolRequest, input types.DecisionDeferInput) (*mcp.CallToolResult, any, error)

DecisionDefer pushes a deadline with a reason and increments defer count.

func (*Decision) DecisionResolve

func (d *Decision) DecisionResolve(ctx context.Context, req *mcp.CallToolRequest, input types.DecisionResolveInput) (*mcp.CallToolResult, any, error)

DecisionResolve marks a decision as DONE with resolution date and outcome.

type Flashcard

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

Flashcard implements flashcard/SRS MCP tools.

func NewFlashcard

func NewFlashcard(c backend.Backend) *Flashcard

NewFlashcard creates a new Flashcard tool handler.

func (*Flashcard) FlashcardCreate

func (f *Flashcard) FlashcardCreate(ctx context.Context, req *mcp.CallToolRequest, input types.FlashcardCreateInput) (*mcp.CallToolResult, any, error)

FlashcardCreate creates a new flashcard (block with #card tag and child answer).

func (*Flashcard) FlashcardDue

FlashcardDue returns cards currently due for review.

func (*Flashcard) FlashcardOverview

func (f *Flashcard) FlashcardOverview(ctx context.Context, req *mcp.CallToolRequest, input types.FlashcardOverviewInput) (*mcp.CallToolResult, any, error)

FlashcardOverview returns SRS statistics across all cards.

type Journal

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

Journal implements journal MCP tools.

func NewJournal

func NewJournal(c backend.Backend) *Journal

NewJournal creates a new Journal tool handler.

func (*Journal) JournalRange

func (j *Journal) JournalRange(ctx context.Context, req *mcp.CallToolRequest, input types.JournalRangeInput) (*mcp.CallToolResult, any, error)

JournalRange returns journal entries across a date range.

func (*Journal) JournalSearch

func (j *Journal) JournalSearch(ctx context.Context, req *mcp.CallToolRequest, input types.JournalSearchInput) (*mcp.CallToolResult, any, error)

JournalSearch searches within journal entries.

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

Navigate implements navigation MCP tools.

func NewNavigate

func NewNavigate(c backend.Backend) *Navigate

NewNavigate creates a new Navigate tool handler.

GetBlock retrieves a block with ancestors, children, and optionally siblings.

GetLinks returns forward links and backlinks for a page.

GetPage retrieves a page with its full recursive block tree and parsed content.

func (n *Navigate) GetReferences(ctx context.Context, req *mcp.CallToolRequest, input types.GetReferencesInput) (*mcp.CallToolResult, any, error)

GetReferences finds all blocks referencing a specific block via ((uuid)).

ListPages lists pages with optional filtering.

Traverse finds paths between two pages using BFS on the link graph.

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

Search implements search and query MCP tools.

func NewSearch

func NewSearch(c backend.Backend) *Search

NewSearch creates a new Search tool handler.

func (*Search) FindByTag

func (s *Search) FindByTag(ctx context.Context, req *mcp.CallToolRequest, input types.FindByTagInput) (*mcp.CallToolResult, any, error)

FindByTag finds content by tag, including child tags.

func (*Search) QueryDatalog

func (s *Search) QueryDatalog(ctx context.Context, req *mcp.CallToolRequest, input types.QueryDatalogInput) (*mcp.CallToolResult, any, error)

QueryDatalog executes raw DataScript queries.

func (*Search) QueryProperties

func (s *Search) QueryProperties(ctx context.Context, req *mcp.CallToolRequest, input types.QueryPropertiesInput) (*mcp.CallToolResult, any, error)

QueryProperties finds blocks/pages by property values.

func (*Search) Search

Search performs full-text search across all blocks with context. Uses FullTextSearcher (indexed) when available, falls back to brute-force scan.

type Semantic

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

Semantic implements the 3 semantic search MCP tools: dewey_semantic_search, dewey_similar, and dewey_semantic_search_filtered.

Design decision: The embedder and store are injected as dependencies (Dependency Inversion Principle) to enable testing with mocks and to support graceful degradation when Ollama is unavailable.

func NewSemantic

func NewSemantic(e embed.Embedder, s *store.Store) *Semantic

NewSemantic creates a new Semantic tool handler with the given embedder and store. Both embedder and store may be nil — the tools return clear MCP error messages when unavailable, enabling graceful degradation when Ollama is not running or no persistent store is configured.

Returns a ready-to-use handler for the three semantic search MCP tools.

func (*Semantic) SemanticSearch

func (s *Semantic) SemanticSearch(ctx context.Context, req *mcp.CallToolRequest, input types.SemanticSearchInput) (*mcp.CallToolResult, any, error)

SemanticSearch handles the dewey_semantic_search MCP tool. Embeds the query text via the configured embedder, then searches for similar blocks via cosine similarity. Returns a JSON array of types.SemanticSearchResult with provenance metadata (page, source, similarity score, indexed timestamp). Defaults limit to 10 and threshold to 0.3 if not specified.

Returns an MCP error result (not a Go error) if the embedder is unavailable, the store is nil, embedding fails, or the search fails.

func (*Semantic) SemanticSearchFiltered

func (s *Semantic) SemanticSearchFiltered(ctx context.Context, req *mcp.CallToolRequest, input types.SemanticSearchFilteredInput) (*mcp.CallToolResult, any, error)

SemanticSearchFiltered handles the dewey_semantic_search_filtered MCP tool. Combines semantic search with metadata filters (source type, source ID, property, tag) to narrow results. Filters are applied at the SQL level before vector comparison for efficiency. Returns a JSON array of types.SemanticSearchResult. Defaults limit to 10 and threshold to 0.3.

Returns an MCP error result (not a Go error) if the embedder is unavailable, the store is nil, embedding fails, or the filtered search fails.

func (*Semantic) Similar

Similar handles the dewey_similar MCP tool. Finds documents similar to a given page or block by looking up its existing embedding and searching for similar vectors. At least one of input.Page or input.UUID must be provided. Returns a JSON array of types.SemanticSearchResult excluding the query document itself. Defaults limit to 10.

Returns an MCP error result (not a Go error) if neither page nor UUID is provided, the embedder is unavailable, no embeddings exist in the index, or the referenced page/block has no embedding.

type Whiteboard

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

Whiteboard implements whiteboard MCP tools.

func NewWhiteboard

func NewWhiteboard(c backend.Backend) *Whiteboard

NewWhiteboard creates a new Whiteboard tool handler.

func (*Whiteboard) GetWhiteboard

GetWhiteboard retrieves a whiteboard's content including embedded pages and connections.

func (*Whiteboard) ListWhiteboards

ListWhiteboards returns all whiteboards in the graph.

type Write

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

Write implements write MCP tools.

func NewWrite

func NewWrite(c backend.Backend) *Write

NewWrite creates a new Write tool handler.

func (*Write) AppendBlocks

func (w *Write) AppendBlocks(ctx context.Context, req *mcp.CallToolRequest, input types.AppendBlocksInput) (*mcp.CallToolResult, any, error)

AppendBlocks appends plain-string blocks to an existing page (same API as create_page blocks).

func (*Write) BulkUpdateProperties

func (w *Write) BulkUpdateProperties(ctx context.Context, req *mcp.CallToolRequest, input types.BulkUpdatePropertiesInput) (*mcp.CallToolResult, any, error)

BulkUpdateProperties sets a property on multiple pages at once.

func (*Write) CreatePage

func (w *Write) CreatePage(ctx context.Context, req *mcp.CallToolRequest, input types.CreatePageInput) (*mcp.CallToolResult, any, error)

CreatePage creates a new page with optional properties and initial blocks.

func (*Write) DeleteBlock

func (w *Write) DeleteBlock(ctx context.Context, req *mcp.CallToolRequest, input types.DeleteBlockInput) (*mcp.CallToolResult, any, error)

DeleteBlock removes a block from the graph.

func (*Write) DeletePage

func (w *Write) DeletePage(ctx context.Context, req *mcp.CallToolRequest, input types.DeletePageInput) (*mcp.CallToolResult, any, error)

DeletePage removes a page from the graph.

func (*Write) LinkPages

func (w *Write) LinkPages(ctx context.Context, req *mcp.CallToolRequest, input types.LinkPagesInput) (*mcp.CallToolResult, any, error)

LinkPages creates bidirectional links between two pages.

func (*Write) MoveBlock

func (w *Write) MoveBlock(ctx context.Context, req *mcp.CallToolRequest, input types.MoveBlockInput) (*mcp.CallToolResult, any, error)

MoveBlock moves a block to a new location.

func (*Write) RenamePage

func (w *Write) RenamePage(ctx context.Context, req *mcp.CallToolRequest, input types.RenamePageInput) (*mcp.CallToolResult, any, error)

RenamePage renames a page and updates all links across the graph.

func (*Write) UpdateBlock

func (w *Write) UpdateBlock(ctx context.Context, req *mcp.CallToolRequest, input types.UpdateBlockInput) (*mcp.CallToolResult, any, error)

UpdateBlock updates an existing block's content.

func (*Write) UpsertBlocksRaw

func (w *Write) UpsertBlocksRaw(ctx context.Context, req *mcp.CallToolRequest) (*mcp.CallToolResult, error)

UpsertBlocksRaw is the raw ToolHandler for upsert_blocks (avoids recursive type cycle in schema generation).

Jump to

Keyboard shortcuts

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