mcp

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	E_INVALID          = "E_INVALID"
	E_CONFIRM_REQUIRED = "E_CONFIRM_REQUIRED"
	E_NOT_FOUND        = "E_NOT_FOUND"
	E_CONFLICT         = "E_CONFLICT"
	E_INTERNAL         = "E_INTERNAL"
)
View Source
const (
	TransportStdio = "stdio"
	TransportHTTP  = "http"
)

Variables

This section is empty.

Functions

func BranchAdapter

func BranchAdapter(ctx context.Context, a *app.App, in BranchInput) (any, error)

BranchAdapter creates a VM branch and returns presenters.BranchView.

func Err

func Err(code, msg string, details map[string]any) error

func ExecuteAdapter

func ExecuteAdapter(ctx context.Context, a *app.App, in ExecuteInput) (any, error)

ExecuteAdapter runs a command in a VM and returns presenters.ExecuteView.

func KillAdapter

func KillAdapter(ctx context.Context, a *app.App, in KillInput) (any, error)

KillAdapter deletes VMs per inputs. Returns nil output on success.

func RunAdapter

func RunAdapter(ctx context.Context, a *app.App, in RunInput) (any, error)

RunAdapter starts a VM per inputs and returns a presenters.RunView.

func SetRateLimit

func SetRateLimit(tool string, perMinute int)

SetRateLimit sets a simple per-minute limit for a given tool.

func StartServer

func StartServer(ctx context.Context, application *app.App, opts Options) error

StartServer wires the MCP server using the Go SDK when built with `-tags mcp`. Note: This file references the MCP Go SDK. Ensure the module is added:

go get github.com/modelcontextprotocol/go-sdk

API calls here are structured to match the SDK’s server + stdio transport.

func StatusAdapter

func StatusAdapter(ctx context.Context, a *app.App, in StatusInput) (any, error)

StatusAdapter calls the existing status handler and returns the structured result.

Types

type BranchInput

type BranchInput struct {
	Target   string `json:"target,omitempty" jsonschema:"Source VM ID or alias; defaults to HEAD"`
	Alias    string `json:"alias,omitempty" jsonschema:"Alias for the new VM"`
	Checkout bool   `json:"checkout,omitempty" jsonschema:"Switch HEAD to the new VM after creation"`
}

BranchInput defines inputs for vers.branch

type Error

type Error struct {
	Code    string
	Message string
	Details map[string]any
}

func (*Error) Error

func (e *Error) Error() string

type ExecuteInput

type ExecuteInput struct {
	Target         string   `json:"target,omitempty" jsonschema:"VM ID or alias; defaults to HEAD"`
	Command        []string `json:"command" jsonschema:"Command and args to run"`
	TimeoutSeconds int      `json:"timeoutSeconds,omitempty" jsonschema:"Execution timeout in seconds"`
}

ExecuteInput defines inputs for vers.execute

type KillInput

type KillInput struct {
	Targets          []string `json:"targets,omitempty" jsonschema:"VM identifiers; empty means HEAD VM"`
	SkipConfirmation bool     `json:"skipConfirmation,omitempty" jsonschema:"Required for destructive operations in MCP"`
	Recursive        bool     `json:"recursive,omitempty" jsonschema:"Delete all descendants"`
}

KillInput defines inputs for vers.kill

type Options

type Options struct {
	// Transport selects the server transport. Supported: "stdio", "http".
	Transport string
	// Addr is the listen address for HTTP transport.
	Addr string
	// AllowInsecureSetKey toggles a local-only tool to set API key via MCP.
	AllowInsecureSetKey bool
	// Verbose enables extra debug logging.
	Verbose bool
}

Options configures the MCP server startup.

type RunInput

type RunInput struct {
	MemSizeMib  int64  `json:"memSizeMib,omitempty" jsonschema:"VM memory size in MiB"`
	VcpuCount   int64  `json:"vcpuCount,omitempty" jsonschema:"Number of vCPUs"`
	RootfsName  string `json:"rootfsName,omitempty" jsonschema:"Rootfs image name"`
	KernelName  string `json:"kernelName,omitempty" jsonschema:"Kernel image name"`
	FsSizeVmMib int64  `json:"fsSizeVmMib,omitempty" jsonschema:"VM filesystem size in MiB"`
	VMAlias     string `json:"vmAlias,omitempty" jsonschema:"Alias for the root VM"`
}

RunInput defines inputs for vers.run

type StatusInput

type StatusInput struct {
	Target string `json:"target,omitempty" jsonschema:"VM ID or alias for VM-specific status"`
}

StatusInput is the input schema for vers.status tool.

type ToolMetricView

type ToolMetricView struct {
	Calls           int64  `json:"calls"`
	Errors          int64  `json:"errors"`
	TotalDurationMs int64  `json:"totalDurationMs"`
	LastError       string `json:"lastError,omitempty"`
	RatePerMinute   int    `json:"ratePerMinute"`
	UsedInWindow    int    `json:"usedInWindow"`
	WindowResetSec  int64  `json:"windowResetSec"`
}

ToolMetricView is a read-only view for reporting via vers.metrics.

type ToolMetrics

type ToolMetrics struct {
	Calls         int64
	Errors        int64
	TotalDuration time.Duration
	LastError     string
}

Jump to

Keyboard shortcuts

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