mcpserver

package
v2.3.9 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
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 NewServer

func NewServer(registry *clients.Registry) *Server

NewServer creates a new MCP server

func (*Server) ReportSkillUsage

func (s *Server) ReportSkillUsage(skillName, skillVersion string)

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) Run

func (s *Server) Run(ctx context.Context) error

Run starts the MCP server over stdio

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

Jump to

Keyboard shortcuts

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