mcpserver

package
v0.1.5 Latest Latest
Warning

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

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

Documentation

Overview

Package mcpserver serves search, describe, and invoke over one catalog.

Index

Constants

View Source
const (
	// CallerHeader is the credential of the process calling veto.
	// The value identifies that caller. It is not an upstream API token.
	CallerHeader = "Veto-Caller"

	// DefaultAddr is the listen address for serve --http.
	DefaultAddr = "127.0.0.1:7433"
)

Variables

View Source
var Version = "dev"

Version is the MCP server build. A release sets it with -X.

Functions

func Handler

func Handler(srv *Server, opt Options, ids []Identity) (http.Handler, error)

Handler is the Streamable HTTP MCP endpoint. A request without a known caller credential is rejected first.

func Listen

func Listen(ctx context.Context, addr string, h http.Handler) (string, error)

Listen serves h and returns the bound address. The server stops when ctx is done.

func RegisterTools

func RegisterTools(cat *catalog.Catalog, opt Options) []string

func RunStdio

func RunStdio(ctx context.Context, srv *Server, opt Options) error

func Serve

func Serve(ctx context.Context, addr string, h http.Handler) error

Serve listens on addr until ctx is done. An empty addr uses DefaultAddr.

func ToolNames

func ToolNames(cat *catalog.Catalog, pins []string, directPins, grouped bool) []string

Grouped mode adds one tool per resource, never one tool per operation.

func ValidatePins

func ValidatePins(cat *catalog.Catalog, pins []string) error

Types

type Identity

type Identity struct {
	ID    string
	Token string
}

Identity is one caller of the HTTP server. Token is the credential. ID is the name stored with an approval.

func Identities

func Identities(names map[string]string, getenv func(string) string) ([]Identity, error)

Identities reads caller credentials from the environment variables named in names. names maps a caller id to an environment variable. The credential values are not returned in errors.

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"`
}

type Options

type Options struct {
	Pins       []string
	DirectPins bool
	Grouped    bool
	// ChatApproval lets an elicitation answer approve a held call. RunStdio turns it on.
	ChatApproval bool
}

type SearchHit added in v0.1.3

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

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

type Server

type Server struct {
	Catalog   *catalog.Catalog
	Semantics agent.Notes
	Calls     *runtime.Runtime
}

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

func (s *Server) Invoke(ctx context.Context, operationID string, params map[string]string, approvalID string) (InvokeResult, error)

Invoke adapts string parameters at the MCP boundary and calls the shared runtime.

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