Documentation
¶
Index ¶
- Constants
- Variables
- func MCPToolName(methodName string) string
- func NormalizeAndValidate(reg *Registration, spaceName string) error
- type Entry
- type JSONRPCError
- type JSONRPCRequest
- type JSONRPCResponse
- type MethodDefinition
- type MethodInfo
- type Registration
- type Registry
- func (r *Registry) Count() int
- func (r *Registry) Done(entry *Entry)
- func (r *Registry) Drain(spaceID string)
- func (r *Registry) InFlightForSpace(spaceID string) int
- func (r *Registry) List(user *model.User) []MethodInfo
- func (r *Registry) Pick(methodName string, user *model.User) (*Entry, string, error)
- func (r *Registry) Register(space *model.Space, owner *model.User, reg *Registration) error
- func (r *Registry) SetDrainChecker(fn func(spaceID string) bool)
- func (r *Registry) Undrain(spaceID string)
- func (r *Registry) UnregisterSpace(spaceID string)
- type ServerConfig
Constants ¶
View Source
const ( ScopePrivate = "private" ServerTypeStdio = "stdio" // ModeConcurrent allows multiple JSON-RPC requests to be in flight on the // method server at the same time. Responses are correlated by id. This is // the default. ModeConcurrent = "concurrent" // ModeSerial lets only one JSON-RPC request be in flight on the method // server at a time. Useful for method servers that are not re-entrant. ModeSerial = "serial" )
Variables ¶
Functions ¶
func MCPToolName ¶
func NormalizeAndValidate ¶
func NormalizeAndValidate(reg *Registration, spaceName string) error
Types ¶
type Entry ¶
type Entry struct {
MethodDefinition
SpaceID string
SpaceName string
OwnerID string
Owner string
Server ServerConfig
// contains filtered or unexported fields
}
type JSONRPCError ¶
type JSONRPCRequest ¶
type JSONRPCRequest struct {
JSONRPC string `json:"jsonrpc" msgpack:"jsonrpc"`
Method string `json:"method" msgpack:"method"`
Params json.RawMessage `json:"params,omitempty" msgpack:"params,omitempty"`
ID any `json:"id,omitempty" msgpack:"id,omitempty"`
}
type JSONRPCResponse ¶
type JSONRPCResponse struct {
JSONRPC string `json:"jsonrpc" msgpack:"jsonrpc"`
Result any `json:"result,omitempty" msgpack:"result,omitempty"`
Error *JSONRPCError `json:"error,omitempty" msgpack:"error,omitempty"`
ID any `json:"id,omitempty" msgpack:"id,omitempty"`
}
type MethodDefinition ¶
type MethodDefinition struct {
Name string `json:"name" toml:"name" msgpack:"name"`
LocalName string `json:"local_name" toml:"local_name" msgpack:"local_name"`
Description string `json:"description" toml:"description" msgpack:"description"`
Keywords []string `json:"keywords,omitempty" toml:"keywords" msgpack:"keywords,omitempty"`
Scope string `json:"scope,omitempty" toml:"scope" msgpack:"scope,omitempty"`
Groups []string `json:"groups,omitempty" toml:"groups" msgpack:"groups,omitempty"`
MCPTool bool `json:"mcp_tool" toml:"mcp_tool" msgpack:"mcp_tool"`
Events []string `json:"events,omitempty" toml:"events,omitempty" msgpack:"events,omitempty"`
EventSinks []string `json:"event_sinks,omitempty" toml:"event_sinks,omitempty" msgpack:"event_sinks,omitempty"`
ParamsSchema map[string]any `json:"params_schema,omitempty" toml:"params_schema" msgpack:"params_schema,omitempty"`
ResultSchema map[string]any `json:"result_schema,omitempty" toml:"result_schema" msgpack:"result_schema,omitempty"`
}
type MethodInfo ¶
type MethodInfo struct {
Name string `json:"name" msgpack:"name"`
LocalName string `json:"local_name" msgpack:"local_name"`
Description string `json:"description" msgpack:"description"`
Keywords []string `json:"keywords,omitempty" msgpack:"keywords,omitempty"`
Scope string `json:"scope" msgpack:"scope"`
Groups []string `json:"groups,omitempty" msgpack:"groups,omitempty"`
MCPTool bool `json:"mcp_tool" msgpack:"mcp_tool"`
Events []string `json:"events,omitempty" msgpack:"events,omitempty"`
EventSinks []string `json:"event_sinks,omitempty" msgpack:"event_sinks,omitempty"`
ParamsSchema map[string]any `json:"params_schema,omitempty" msgpack:"params_schema,omitempty"`
ResultSchema map[string]any `json:"result_schema,omitempty" msgpack:"result_schema,omitempty"`
OwnerID string `json:"owner_id" msgpack:"owner_id"`
Owner string `json:"owner" msgpack:"owner"`
ProviderCount int `json:"provider_count" msgpack:"provider_count"`
}
type Registration ¶
type Registration struct {
Server ServerConfig `json:"server" toml:"server" msgpack:"server"`
Methods []MethodDefinition `json:"methods" toml:"methods" msgpack:"methods"`
}
func LoadRawTOML ¶
func LoadRawTOML(data []byte) (*Registration, error)
LoadRawTOML decodes TOML bytes into a Registration without running normalization or validation. Callers (typically the agent) forward the decoded struct to the knot server, which validates it during registration.
func LoadRawTOMLFile ¶
func LoadRawTOMLFile(path string) (*Registration, error)
func LoadTOMLFile ¶
func LoadTOMLFile(path string, spaceName string) (*Registration, error)
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func DefaultRegistry ¶
func DefaultRegistry() *Registry
func NewRegistry ¶
func NewRegistry() *Registry
func (*Registry) Count ¶
Count returns the total number of registered method entries across all spaces and names. Each duplicate exact-match registration counts once. Useful for debug/diagnostic logging; not part of the discovery surface.
func (*Registry) InFlightForSpace ¶
func (*Registry) SetDrainChecker ¶
SetDrainChecker installs a callback that Register consults to determine whether a space should be draining even if no prior entries exist (e.g. after an unregister/register churn cycle). The PoolService sets this so drain state survives method server restarts.
func (*Registry) UnregisterSpace ¶
type ServerConfig ¶
type ServerConfig struct {
Type string `json:"type" toml:"type" msgpack:"type"`
Command string `json:"command" toml:"command" msgpack:"command"`
Args []string `json:"args,omitempty" toml:"args" msgpack:"args,omitempty"`
Timeout int `json:"timeout,omitempty" toml:"timeout" msgpack:"timeout,omitempty"`
Mode string `json:"mode,omitempty" toml:"mode" msgpack:"mode,omitempty"`
}
Click to show internal directories.
Click to hide internal directories.