toolstore

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 8 Imported by: ? 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

Index

Constants

View Source
const CacheDirEnv = "LEANPROXY_TOOLCACHE_DIR"

CacheDirEnv overrides the persistent tool cache directory. Tests (and operators who want the cache elsewhere) set it; when unset the cache lives in $HOME/.config/leanproxy/toolcache.

View Source
const CacheValidDuration = 24 * time.Hour

Variables

This section is empty.

Functions

func DefaultCacheDir added in v1.1.1

func DefaultCacheDir() (string, error)

DefaultCacheDir returns the persistent tool cache directory: the LEANPROXY_TOOLCACHE_DIR environment variable when set, otherwise $HOME/.config/leanproxy/toolcache. $HOME is honored (os.UserHomeDir) so a test that points HOME at a scratch directory never touches the real one.

Types

type Cache

type Cache interface {
	GetTools(serverName string) ([]CachedTool, error)
	SetTools(serverName string, tools []CachedTool) error
	Invalidate(serverName string) error
	GetCacheDir() string
}

type CachedTool

type CachedTool struct {
	Name         string          `json:"name"`
	Title        string          `json:"title,omitempty"`
	Description  string          `json:"description"`
	InputSchema  json.RawMessage `json:"inputSchema"`
	OutputSchema json.RawMessage `json:"outputSchema,omitempty"`
	Annotations  json.RawMessage `json:"annotations,omitempty"`
	Icons        json.RawMessage `json:"icons,omitempty"`
	Meta         json.RawMessage `json:"_meta,omitempty"`
}

CachedTool is one persisted tool definition. The MCP 2025 metadata fields are optional, so cache files written before they existed still load.

type FileCache

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

func NewFileCache

func NewFileCache(logger *slog.Logger) (*FileCache, error)

NewFileCache creates the persistent tool cache in DefaultCacheDir.

func (*FileCache) GetCacheDir

func (c *FileCache) GetCacheDir() string

func (*FileCache) GetTools

func (c *FileCache) GetTools(serverName string) ([]CachedTool, error)

func (*FileCache) Invalidate

func (c *FileCache) Invalidate(serverName string) error

func (*FileCache) ListCachedServers

func (c *FileCache) ListCachedServers() ([]string, error)

func (*FileCache) SetTools

func (c *FileCache) SetTools(serverName string, tools []CachedTool) error

type NoOpCache

type NoOpCache struct{}

func NewNoOpCache

func NewNoOpCache() *NoOpCache

func (*NoOpCache) GetCacheDir

func (c *NoOpCache) GetCacheDir() string

func (*NoOpCache) GetTools

func (c *NoOpCache) GetTools(serverName string) ([]CachedTool, error)

func (*NoOpCache) Invalidate

func (c *NoOpCache) Invalidate(serverName string) error

func (*NoOpCache) SetTools

func (c *NoOpCache) SetTools(serverName string, tools []CachedTool) error

Jump to

Keyboard shortcuts

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