tools

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(s *mcp.Server, sc DocumentScanner, graph GraphStore, search ContentSearcher, semantic SemanticSearch, metrics *ToolMetrics, docMetrics *DocMetrics, readOnly bool)

Types

type AddObservationsArgs

type AddObservationsArgs struct {
	Observations []memory.Observation `json:"observations" jsonschema:"observations to add"`
}

type AddObservationsResult

type AddObservationsResult struct {
	Observations []memory.Observation `json:"observations"`

	Skipped []SkippedObservation `json:"skipped,omitempty"`
}

type ContentSearcher

type ContentSearcher interface {
	Search(query, repo, fileType string) ([]memory.ContentMatch, error)

	Count() (int64, error)

	SearchMode() string
}

type CreateEntitiesArgs

type CreateEntitiesArgs struct {
	Entities []memory.Entity `json:"entities" jsonschema:"entities to create"`
}

type CreateEntitiesResult

type CreateEntitiesResult struct {
	Entities []memory.Entity `json:"entities"`

	Skipped []SkippedObservation `json:"skipped,omitempty"`
}

type CreateRelationsArgs

type CreateRelationsArgs struct {
	Relations []memory.Relation `json:"relations" jsonschema:"relations to create"`
}

type CreateRelationsResult

type CreateRelationsResult struct {
	Relations []memory.Relation `json:"relations"`
}

type DeleteEntitiesArgs

type DeleteEntitiesArgs struct {
	EntityNames []string `json:"entityNames" jsonschema:"Entities to delete."`

	Confirm bool `` /* 163-byte string literal not displayed */
}

type DeleteObservationsArgs

type DeleteObservationsArgs struct {
	Deletions []memory.Observation `json:"deletions" jsonschema:"observations to delete"`
}

type DeleteRelationsArgs

type DeleteRelationsArgs struct {
	Relations []memory.Relation `json:"relations" jsonschema:"relations to delete"`
}

type DocAccess

type DocAccess struct {
	Repo  string `json:"repo"`
	Path  string `json:"path"`
	Count int64  `json:"count"`
}

DocAccess holds access statistics for a single indexed document.

type DocMetrics

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

DocMetrics tracks how many times each indexed document has been fetched or returned in search results, keyed by "repo\tpath".

func NewDocMetrics

func NewDocMetrics() *DocMetrics

NewDocMetrics returns a new, empty DocMetrics instance.

func (*DocMetrics) Record

func (d *DocMetrics) Record(repo, path string)

Record increments the access counter for a specific repo+path pair.

func (*DocMetrics) TopN

func (d *DocMetrics) TopN(n int) []DocAccess

TopN returns up to n documents sorted by access count descending. Pass n <= 0 to return all tracked documents.

type DocumentScanner

type DocumentScanner interface {
	ListRepos() []scanner.RepoInfo

	SearchDocs(query string) []scanner.FileEntry

	GetFileContent(ctx context.Context, repo string, path string) (string, error)

	Status() (scanning bool, lastScan time.Time, repoCount int)

	TriggerScan() bool
}

type FindPathArgs

type FindPathArgs struct {
	From string `json:"from"               jsonschema:"Name of the starting entity."`

	To string `json:"to"                 jsonschema:"Name of the destination entity."`

	MaxDepth int `json:"max_depth,omitempty" jsonschema:"Maximum number of hops to search (1–10). Defaults to 6 when omitted."`
}

type FindPathResult

type FindPathResult struct {
	Path []memory.PathEdge `json:"path"`

	Found bool `json:"found"`

	Hops int `json:"hops"`
}

type GetFileContentArgs

type GetFileContentArgs struct {
	Repo string `` /* 134-byte string literal not displayed */
	Path string `json:"path" jsonschema:"The file path within the repository (e.g. 'docs/guide.md' or 'README.md')."`
}

type GraphAuditLogger

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

func NewGraphAuditLogger

func NewGraphAuditLogger(inner GraphStore) *GraphAuditLogger

func (*GraphAuditLogger) AddObservations

func (a *GraphAuditLogger) AddObservations(observations []memory.Observation) ([]memory.Observation, error)

func (*GraphAuditLogger) CreateEntities

func (a *GraphAuditLogger) CreateEntities(entities []memory.Entity) ([]memory.Entity, error)

func (*GraphAuditLogger) CreateRelations

func (a *GraphAuditLogger) CreateRelations(relations []memory.Relation) ([]memory.Relation, error)

func (*GraphAuditLogger) DeleteEntities

func (a *GraphAuditLogger) DeleteEntities(entityNames []string) error

func (*GraphAuditLogger) DeleteObservations

func (a *GraphAuditLogger) DeleteObservations(deletions []memory.Observation) error

func (*GraphAuditLogger) DeleteRelations

func (a *GraphAuditLogger) DeleteRelations(relations []memory.Relation) error

func (*GraphAuditLogger) EntityCount

func (a *GraphAuditLogger) EntityCount() (int64, error)

func (*GraphAuditLogger) EntityTypeCounts

func (a *GraphAuditLogger) EntityTypeCounts() (map[string]int64, error)

func (*GraphAuditLogger) FindPath

func (a *GraphAuditLogger) FindPath(from, to string, maxDepth int) ([]memory.PathEdge, error)

func (*GraphAuditLogger) GetIntegrationMap

func (a *GraphAuditLogger) GetIntegrationMap(ctx context.Context, service string, depth int) (memory.IntegrationMap, error)

func (*GraphAuditLogger) ListEntities

func (a *GraphAuditLogger) ListEntities(entityType string) (memory.KnowledgeGraph, error)

func (*GraphAuditLogger) ListRelations

func (a *GraphAuditLogger) ListRelations(relationType, fromEntity string) ([]memory.Relation, error)

func (*GraphAuditLogger) OpenNodes

func (a *GraphAuditLogger) OpenNodes(names []string) (memory.KnowledgeGraph, error)

func (*GraphAuditLogger) OpenNodesFiltered

func (a *GraphAuditLogger) OpenNodesFiltered(names []string, includeArchived bool) (memory.KnowledgeGraph, error)

func (*GraphAuditLogger) ReadGraph

func (a *GraphAuditLogger) ReadGraph() (memory.KnowledgeGraph, error)

func (*GraphAuditLogger) SearchNodes

func (a *GraphAuditLogger) SearchNodes(query string) (memory.KnowledgeGraph, error)

func (*GraphAuditLogger) SearchNodesFiltered

func (a *GraphAuditLogger) SearchNodesFiltered(query string, includeArchived bool) (memory.KnowledgeGraph, error)

func (*GraphAuditLogger) TraverseGraph

func (a *GraphAuditLogger) TraverseGraph(entity, relationType, direction string, maxDepth int) ([]memory.TraverseNode, error)

func (*GraphAuditLogger) UpdateEntity

func (a *GraphAuditLogger) UpdateEntity(oldName, newName, newType string) error

type GraphStore

type GraphStore interface {
	CreateEntities(entities []memory.Entity) ([]memory.Entity, error)

	CreateRelations(relations []memory.Relation) ([]memory.Relation, error)

	AddObservations(observations []memory.Observation) ([]memory.Observation, error)

	DeleteEntities(entityNames []string) error

	DeleteObservations(deletions []memory.Observation) error

	DeleteRelations(relations []memory.Relation) error

	ReadGraph() (memory.KnowledgeGraph, error)

	SearchNodes(query string) (memory.KnowledgeGraph, error)

	SearchNodesFiltered(query string, includeArchived bool) (memory.KnowledgeGraph, error)

	OpenNodes(names []string) (memory.KnowledgeGraph, error)

	OpenNodesFiltered(names []string, includeArchived bool) (memory.KnowledgeGraph, error)

	EntityCount() (int64, error)

	EntityTypeCounts() (map[string]int64, error)

	TraverseGraph(entity, relationType, direction string, maxDepth int) ([]memory.TraverseNode, error)

	GetIntegrationMap(ctx context.Context, service string, depth int) (memory.IntegrationMap, error)

	ListEntities(entityType string) (memory.KnowledgeGraph, error)

	ListRelations(relationType, fromEntity string) ([]memory.Relation, error)

	FindPath(from, to string, maxDepth int) ([]memory.PathEdge, error)

	UpdateEntity(oldName, newName, newType string) error
}

type IntegrationEdgeJSON

type IntegrationEdgeJSON struct {
	Target string `json:"target"`

	Schema string `json:"schema,omitempty"`

	Version string `json:"version,omitempty"`

	Paths int `json:"paths,omitempty"`

	Confidence string `json:"confidence"`

	SourceRepo string `json:"source_repo,omitempty"`
}

type IntegrationMapArgs

type IntegrationMapArgs struct {
	Service string `json:"service"         jsonschema:"required,Entity name of the service in the knowledge graph (e.g. 'checkout-service')."`

	Depth int `` /* 133-byte string literal not displayed */
}

type IntegrationMapResult

type IntegrationMapResult struct {
	Service string `json:"service"`

	Publishes []IntegrationEdgeJSON `json:"publishes"`

	Subscribes []IntegrationEdgeJSON `json:"subscribes"`

	ExposesAPI []IntegrationEdgeJSON `json:"exposes_api"`

	ProvidesGRPC []IntegrationEdgeJSON `json:"provides_grpc"`

	GRPCDeps []IntegrationEdgeJSON `json:"grpc_deps"`

	Calls []IntegrationEdgeJSON `json:"calls"`

	Coverage string `` /* 138-byte string literal not displayed */
}

type ListEntitiesArgs

type ListEntitiesArgs struct {
	EntityType string `` /* 202-byte string literal not displayed */
}

type ListRelationsArgs

type ListRelationsArgs struct {
	RelationType string `` /* 265-byte string literal not displayed */

	FromEntity string `` /* 166-byte string literal not displayed */
}

type ListRelationsResult

type ListRelationsResult struct {
	Relations []memory.Relation `json:"relations"`

	Count int `json:"count"`
}

type ListReposArgs

type ListReposArgs struct {
	FileType string `` /* 221-byte string literal not displayed */
}

type ListReposResult

type ListReposResult struct {
	Repos []repoSummary `json:"repos" jsonschema:"List of repositories with documentation"`
}

type OpenNodesArgs

type OpenNodesArgs struct {
	Names []string `json:"names" jsonschema:"names of nodes to open"`

	IncludeArchived bool `` /* 175-byte string literal not displayed */
}

type RawContentResult

type RawContentResult struct {
	Content string `json:"content" jsonschema:"The raw text content of the file."`
}

type ScanStatusArgs

type ScanStatusArgs struct{}

type ScanStatusResult

type ScanStatusResult struct {
	Scanning bool `json:"scanning"`

	LastScanAt time.Time `json:"last_scan_at"`

	RepoCount int `json:"repo_count"`

	ContentIndexed int64 `json:"content_indexed"`

	GraphEntities int64 `json:"graph_entities"`

	ContentEnabled bool `json:"content_enabled"`

	EntityBreakdown map[string]int64 `json:"entity_breakdown,omitempty"`

	SearchMode string `json:"search_mode,omitempty"`

	ReadOnly bool `json:"read_only"`
}

type SearchContentArgs

type SearchContentArgs struct {
	Query string `` /* 157-byte string literal not displayed */

	Repo string `json:"repo,omitempty" jsonschema:"Optional: filter results to a single repository name (e.g. 'org/payment-service')."`

	FileType string `` /* 227-byte string literal not displayed */
}

type SearchContentResult

type SearchContentResult struct {
	Matches []memory.ContentMatch `json:"matches" jsonschema:"List of files containing the query term, with a snippet showing the matched context."`
}

type SearchDocsArgs

type SearchDocsArgs struct {
	Query string `json:"query" jsonschema:"The search term to match against file paths and repo names."`

	FileType string `` /* 194-byte string literal not displayed */
}

type SearchDocsResult

type SearchDocsResult struct {
	Files []scanner.FileEntry `json:"files" jsonschema:"List of files matching the query"`
}

type SearchNodesArgs

type SearchNodesArgs struct {
	Query string `json:"query" jsonschema:"query string"`

	IncludeArchived bool `` /* 175-byte string literal not displayed */
}

type SemanticSearch

type SemanticSearch interface {
	Enabled() bool

	SearchDocs(ctx context.Context, query, repo string, topK int) ([]embeddings.DocResult, int, error)

	SearchEntities(ctx context.Context, query string, topK int) ([]embeddings.EntityResult, int, error)

	ScheduleIndexEntities(names []string)

	IndexDocs(ctx context.Context, repo string)
}

type SemanticSearchArgs

type SemanticSearchArgs struct {
	Query string `json:"query"            jsonschema:"Natural-language search query. Required."`

	Target string `` /* 139-byte string literal not displayed */

	TopK int `json:"top_k,omitempty"  jsonschema:"Maximum number of results per target (default 5, max 20)."`

	Repo string `` /* 130-byte string literal not displayed */
}

type SemanticSearchResult

type SemanticSearchResult struct {
	ContentResults []embeddings.DocResult `json:"content_results,omitempty"`

	EntityResults []embeddings.EntityResult `json:"entity_results,omitempty"`

	StaleDocs int `json:"stale_docs"`

	StaleEntities int `json:"stale_entities"`
}

type SkippedObservation

type SkippedObservation struct {
	EntityName  string `json:"entity_name"`
	Observation string `json:"observation"`
	Reason      string `json:"reason"`
}

SkippedObservation records a rejected observation along with the reason it was filtered.

type ToolMetrics

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

ToolMetrics tracks call counts per MCP tool name in a thread-safe manner.

func NewToolMetrics

func NewToolMetrics() *ToolMetrics

NewToolMetrics returns a new, empty ToolMetrics instance.

func (*ToolMetrics) Record

func (m *ToolMetrics) Record(toolName string)

Record increments the call counter for the given tool name.

func (*ToolMetrics) Snapshot

func (m *ToolMetrics) Snapshot() map[string]int64

Snapshot returns a point-in-time copy of all tool call counts.

type TraverseGraphArgs

type TraverseGraphArgs struct {
	Entity string `` /* 126-byte string literal not displayed */

	RelationType string `` /* 147-byte string literal not displayed */

	Direction string `` /* 182-byte string literal not displayed */

	Depth int `` /* 175-byte string literal not displayed */
}

type TraverseGraphResult

type TraverseGraphResult struct {
	StartEntity string `json:"start_entity"`

	Nodes []memory.TraverseNode `json:"nodes"`

	TotalFound int `json:"total_found"`
}

type TriggerScanArgs

type TriggerScanArgs struct{}

type TriggerScanResult

type TriggerScanResult struct {
	Triggered bool `json:"triggered"`

	AlreadyQueued bool `json:"already_queued"`
}

type UpdateEntityArgs

type UpdateEntityArgs struct {
	Name string `json:"name"               jsonschema:"Current name of the entity to update. Must match exactly."`

	NewName string `` /* 157-byte string literal not displayed */

	NewType string `json:"new_type,omitempty" jsonschema:"New entity type (e.g. 'service', 'team', 'api'). Omit to keep the current type."`
}

type UpdateEntityResult

type UpdateEntityResult struct {
	Updated bool `json:"updated"`

	Name string `json:"name"` // effective name after update

}

type UsageStatsArgs

type UsageStatsArgs struct{}

UsageStatsArgs has no parameters — the tool returns all stats unconditionally.

type UsageStatsResult

type UsageStatsResult struct {
	ToolCalls    map[string]int64 `` /* 126-byte string literal not displayed */
	TopDocuments []DocAccess      `` /* 198-byte string literal not displayed */
}

UsageStatsResult contains per-tool call counts and top-accessed documents since server start.

Jump to

Keyboard shortcuts

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