Documentation
¶
Index ¶
Constants ¶
const DefaultCacheTTL = 60 * time.Second
DefaultCacheTTL is how long clients may treat a list result as fresh. Deliberately short: an asset added to the vault should show up in the chat client within a minute, not on the next restart.
Variables ¶
This section is empty.
Functions ¶
func NewMCPServer ¶ added in v2.3.2
func NewMCPServer(impl *mcp.Implementation) *mcp.Server
NewMCPServer builds an MCP server configured the way every sx surface needs it — currently `sx mcp` over stdio and `sx cloud serve` over the relay.
This exists so the cacheScope middleware can't be omitted. Wiring it at each construction site meant a third site added later would ship the SDK's "public" default, which is precisely the cross-user cache hint the middleware is there to prevent — and the omission would be invisible, since every test that builds its own server would still pass.
func PrivateCacheScopeMiddleware ¶ added in v2.3.2
func PrivateCacheScopeMiddleware(ttl time.Duration) mcp.Middleware
PrivateCacheScopeMiddleware marks every cacheable result private and gives it a TTL, overriding the SDK's "public" default.
Applied as receiving middleware rather than by wrapping each handler so it can't be forgotten when a new tool or vault type is added — every cacheable result on its way out of the server passes through here.
This middleware owns TTLMs as well as CacheScope: it overwrites whatever the handler set. No handler sets one today, and a single owner is what keeps the freshness hint consistent across every method. A handler that needs its own TTL should stop routing through here rather than fight it.
Types ¶
type ReadSkillInput ¶
type ReadSkillInput struct {
Name string `json:"name" jsonschema:"name of the skill to read"`
}
ReadSkillInput is the input type for read_skill tool
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server provides an MCP server that exposes skill operations
func (*Server) ReportSkillUsage ¶
ReportSkillUsage reports usage of a skill to the vault. This function runs in a goroutine and is best-effort - it will not block the MCP call.
func (*Server) SetUsageReporter ¶
func (s *Server) SetUsageReporter(reporter UsageReporter)
SetUsageReporter sets a custom usage reporter (for testing)
type UsageReporter ¶
type UsageReporter interface {
ReportSkillUsage(skillName, skillVersion string)
}
UsageReporter handles reporting skill usage