capability

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package capability is search, describe, and invoke. MCP and JSON call Server.

Index

Constants

View Source
const (
	SearchName          = "capabilities_search"
	SearchCommand       = "search"
	SearchDescription   = "Search operations. Hits include id, call, related ids, related_calls, and confirmation. Paginate with offset and limit."
	DescribeName        = "capabilities_describe"
	DescribeCommand     = "describe"
	DescribeDescription = "Describe one operation by id. Returns the operation, the call line, related ids, and the relation note."
	InvokeName          = "capabilities_invoke"
	InvokeCommand       = "invoke"
	InvokeDescription   = "" /* 1123-byte string literal not displayed */
)

Variables

This section is empty.

Functions

func RunJSON

func RunJSON(ctx context.Context, s *Server, r io.Reader, w io.Writer) error

RunJSON reads capability lines from r and writes the same JSON MCP returns.

func Sanitize

func Sanitize(msg string) string

Sanitize removes credentials from an invoke error shown on the wire.

Types

type Capability

type Capability struct {
	Name        string       `json:"name"`
	Command     string       `json:"command"`
	Description string       `json:"description"`
	Input       []InputField `json:"input"`
}

func All

func All() []Capability

func ByCommand

func ByCommand(name string) (Capability, bool)

type DescribeArgs

type DescribeArgs struct {
	OperationID string `json:"operation_id" jsonschema:"operation id"`
}

type Help

type Help struct {
	Capabilities []Capability `json:"capabilities"`
}

func HelpJSON

func HelpJSON() Help

type InputField

type InputField struct {
	Name        string `json:"name"`
	Type        string `json:"type"`
	Required    bool   `json:"required,omitempty"`
	Description string `json:"description,omitempty"`
}

type InvokeArgs

type InvokeArgs struct {
	OperationID string   `json:"operation_id" jsonschema:"operation id"`
	Params      Params   `json:"params,omitempty" jsonschema:"parameters; strings, or a JSON object for body"`
	ApprovalID  string   `json:"approval_id,omitempty" jsonschema:"approved id from veto approve; a pending id does not run the call"`
	Token       string   `json:"token,omitempty" jsonschema:"user token for this call when the scheme source is invoke"`
	Preview     bool     `` /* 128-byte string literal not displayed */
	Fields      []string `json:"fields,omitempty" jsonschema:"response fields to return; omit them to keep the whole body"`
	Offset      int      `json:"offset,omitempty" jsonschema:"page offset when fields are set"`
	Limit       int      `json:"limit,omitempty" jsonschema:"page size when fields are set"`
	Idempotency string   `json:"idempotency_key,omitempty" jsonschema:"stable key for a retry after sent without a response"`
}

func DecodeInvoke

func DecodeInvoke(raw []byte) (InvokeArgs, error)

DecodeInvoke reads tool arguments from the raw JSON the host sent.

func (InvokeArgs) Request

func (a InvokeArgs) Request() runtime.Request

Request is the runtime call for these arguments. Caller is set by the adapter.

type InvokeResult

type InvokeResult struct {
	Status      string       `json:"status"`
	ApprovalID  string       `json:"approval_id,omitempty"`
	OperationID string       `json:"operation_id,omitempty"`
	HTTPStatus  int          `json:"http_status,omitempty"`
	Body        string       `json:"body,omitempty"`
	Code        string       `json:"code,omitempty"`
	Retryable   bool         `json:"retryable"`
	RetryAfter  string       `json:"retry_after,omitempty"`
	Error       string       `json:"error,omitempty"`
	Truncated   bool         `json:"truncated,omitempty"`
	Page        *result.Page `json:"page,omitempty"`
	Why         string       `json:"why,omitempty"`
	Caller      string       `json:"caller,omitempty"`
	HTTP        bool         `json:"http"`
	Sent        bool         `json:"sent,omitempty"`
	NextCalls   []NextCall   `json:"next_calls,omitempty"`
}

type Line

type Line struct {
	Search   *SearchArgs   `json:"search,omitempty"`
	Describe *DescribeArgs `json:"describe,omitempty"`
	Invoke   *InvokeArgs   `json:"invoke,omitempty"`
	Caller   string        `json:"caller,omitempty"`
}

Line is one skill request. Exactly one of Search, Describe, or Invoke is set.

type NextCall added in v0.1.8

type NextCall struct {
	OperationID string            `json:"operation_id"`
	Params      map[string]string `json:"params,omitempty"`
}

NextCall is one later operation a successful response can name.

type Params

type Params map[string]any

Params is invoke arguments. Numbers stay digits, not float64.

func (*Params) UnmarshalJSON

func (p *Params) UnmarshalJSON(b []byte) error

func (*Params) UnmarshalJSONFrom

func (p *Params) UnmarshalJSONFrom(dec *jsontext.Decoder) error

type PinArgs

type PinArgs struct {
	Params      Params   `json:"params,omitempty" jsonschema:"parameters; strings, or a JSON object for body"`
	ApprovalID  string   `json:"approval_id,omitempty" jsonschema:"approved id from veto approve; a pending id does not run the call"`
	Token       string   `json:"token,omitempty" jsonschema:"user token for this call when the scheme source is invoke"`
	Preview     bool     `` /* 128-byte string literal not displayed */
	Fields      []string `json:"fields,omitempty" jsonschema:"response fields to return; omit them to keep the whole body"`
	Offset      int      `json:"offset,omitempty" jsonschema:"page offset when fields are set"`
	Limit       int      `json:"limit,omitempty" jsonschema:"page size when fields are set"`
	Idempotency string   `json:"idempotency_key,omitempty" jsonschema:"stable key for a retry after sent without a response"`
}

PinArgs is invoke for a pinned tool. The pin is the operation.

func DecodePin

func DecodePin(raw []byte) (PinArgs, error)

DecodePin reads a pinned tool's arguments. The pin is the operation.

func (PinArgs) Invoke

func (a PinArgs) Invoke(operationID string) InvokeArgs

Invoke binds a pinned tool to the shared invoke arguments.

type SearchArgs

type SearchArgs struct {
	Query  string `json:"query" jsonschema:"search query"`
	Offset int    `json:"offset,omitempty" jsonschema:"hit offset"`
	Limit  int    `json:"limit,omitempty" jsonschema:"page size"`
}

type SearchHit

type SearchHit struct {
	ID           string   `json:"id"`
	Call         string   `json:"call"`
	Related      []string `json:"related,omitempty"`
	RelatedCalls []string `json:"related_calls,omitempty"`
	Confirmation bool     `json:"confirmation,omitempty"`
	Task         bool     `json:"task,omitempty"`
}

SearchHit is one search result on the wire. Describe still returns the operation.

type Server

type Server struct {
	Catalog   *catalog.Catalog
	Semantics semantics.Notes
	Calls     *runtime.Runtime
	Flows     map[string]*flow.Definition
	// contains filtered or unexported fields
}

func (*Server) Call

func (s *Server) Call(ctx context.Context, req runtime.Request) (InvokeResult, error)

Call runs one typed invoke. It does not use the agent loop.

func (*Server) Describe

func (s *Server) Describe(operationID string) ([]byte, error)

func (*Server) Encode

func (s *Server) Encode(v any) ([]byte, error)

Encode writes the same JSON MCP returns for search, describe, and invoke.

func (*Server) EncodeInvoke

func (s *Server) EncodeInvoke(ctx context.Context, req runtime.Request) (InvokeResult, []byte, error)

EncodeInvoke runs Call, redacts, and encodes. Adapters share this body.

func (*Server) EncodePreview

func (s *Server) EncodePreview(ctx context.Context, req runtime.Request) (runtime.Preview, []byte, error)

EncodePreview runs Preview and encodes. A failed preview still returns the body.

func (*Server) EncodeResult

func (s *Server) EncodeResult(res InvokeResult, callErr error) (InvokeResult, []byte, error)

EncodeResult redacts and encodes one invoke result.

func (*Server) Handle

func (s *Server) Handle(ctx context.Context, line Line) ([]byte, error)

Handle runs exactly one of search, describe, or invoke on a line.

func (*Server) Preview

func (s *Server) Preview(ctx context.Context, req runtime.Request) (runtime.Preview, error)

Preview runs the shared runtime and stops before a token URL and upstream HTTP.

func (*Server) RunDescribe

func (s *Server) RunDescribe(args DescribeArgs) ([]byte, error)

func (*Server) RunInvoke

func (s *Server) RunInvoke(ctx context.Context, args InvokeArgs) ([]byte, error)

RunInvoke encodes one invoke. MCP wraps IsError and elicitation around EncodeInvoke.

func (*Server) RunSearch

func (s *Server) RunSearch(args SearchArgs) ([]byte, error)

func (*Server) Search

func (s *Server) Search(query string, offset, limit int) []SearchHit

Jump to

Keyboard shortcuts

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