cache

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddServerTools

func AddServerTools(serverName string, tools []ToolEntry, configChecksum string)

AddServerTools adds or updates tools for a server Also updates the checksum for change detection

func ComputeServerChecksum

func ComputeServerChecksum(command string, args []string, env map[string]string) string

ComputeServerChecksum computes a checksum for a server config Used to detect if server config changed

func GetServerChecksum

func GetServerChecksum(serverName string) string

GetServerChecksum returns the stored checksum for a server

func GetServerForTool

func GetServerForTool(toolName string) string

GetServerForTool looks up which server provides a tool Returns empty string if not found

func HasServer

func HasServer(serverName string) bool

HasServer returns true if cache has tools from this server

func InvalidateCache

func InvalidateCache()

InvalidateCache clears the in-memory cache, forcing next LoadCache to read from disk

func IsEmpty

func IsEmpty() bool

IsEmpty returns true if cache has no tools

func RemoveServer

func RemoveServer(serverName string)

RemoveServer removes all tools from a server

func SaveCache

func SaveCache() error

SaveCache saves the current cache to disk

func ValidateChecksums

func ValidateChecksums(verbose bool) (needsRefresh []string, removed []string)

ValidateChecksums compares current MCP config checksums against cached checksums Returns lists of servers that need refreshing and servers that were removed

Types

type PersistentToolsCache

type PersistentToolsCache struct {
	Version         int               `json:"version"`
	LastUpdated     time.Time         `json:"lastUpdated"`
	Tools           []ToolEntry       `json:"tools"`
	ServerChecksums map[string]string `json:"serverChecksums"` // server name -> config checksum
}

PersistentToolsCache is the structure stored in the cache file

func LoadCache

func LoadCache() (*PersistentToolsCache, error)

LoadCache loads the cache from disk into memory Returns an empty cache if file doesn't exist

type ToolEntry

type ToolEntry struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Source      string `json:"source"` // MCP server name or "internal"
}

ToolEntry represents a single tool in the cache

func GetAllTools

func GetAllTools() []ToolEntry

GetAllTools returns all cached tools

func GetToolsForServer

func GetToolsForServer(serverName string) []ToolEntry

GetToolsForServer returns all tools from a specific server

Jump to

Keyboard shortcuts

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