mcptools

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseAllForwards added in v0.2.0

func CloseAllForwards()

CloseAllForwards releases all active forwards. Safe to call during shutdown.

func LeaseGate added in v0.4.0

LeaseGate wraps an inner tool handler so that, before invoking it, the caller's effective identity is verified to hold an active lease covering every node the call would touch.

Behavior:

  • cfg.Enabled == false → pass-through (no store calls).
  • extract returns [] → pass-through (no node ownership to check).
  • All requested nodes are covered by one or more active leases owned by this agent_id → call inner; on return, if inner took > 30s and the covering lease's runway is < 5min, opportunistically Extend by 60s (errors silently ignored, this is best-effort heartbeat).
  • Otherwise → render a structured markdown error listing the holders of the offending nodes and the recommended recovery commands.

The wrap order is: LeaseGate(...) → addTool(...) so that ops-registry tracking sees both successful calls and lease-denied calls. Tools that bypass addTool (s.AddTool direct) still call LeaseGate first.

func ProgressTokenFromRequest added in v0.4.1

func ProgressTokenFromRequest(req mcp.CallToolRequest) mcp.ProgressToken

ProgressTokenFromRequest extracts _meta.progressToken from an inbound CallToolRequest. Returns nil if the client did not supply one.

func RegisterContext

func RegisterContext(s *server.MCPServer, reg *registry.Registry, leaseCfg LeaseGateConfig)

func RegisterDeploy

func RegisterDeploy(s *server.MCPServer, reg *registry.Registry, pool *agentclient.Pool, creds *credentials.Store, agentToken string)

func RegisterDiagnostics

func RegisterDiagnostics(s *server.MCPServer, reg *registry.Registry, pool *agentclient.Pool, auditLog *audit.Log, leaseCfg LeaseGateConfig)

func RegisterExecute

func RegisterExecute(s *server.MCPServer, reg *registry.Registry, pool *agentclient.Pool, auditLog *audit.Log, leaseCfg LeaseGateConfig)

func RegisterForward added in v0.2.0

func RegisterForward(s *server.MCPServer, reg *registry.Registry, pool *agentclient.Pool, leaseCfg LeaseGateConfig)

RegisterForward wires the forward_port / stop_forward / list_forwards tools.

func RegisterHistory

func RegisterHistory(s *server.MCPServer, auditLog *audit.Log)

func RegisterImportExport

func RegisterImportExport(s *server.MCPServer, reg *registry.Registry)

func RegisterInventory

func RegisterInventory(s *server.MCPServer, reg *registry.Registry, pool *agentclient.Pool)

func RegisterJobs added in v0.2.0

func RegisterJobs(s *server.MCPServer, reg *registry.Registry, pool *agentclient.Pool, leaseCfg LeaseGateConfig)

RegisterJobs exposes the background-job tools (detached executions).

func RegisterLeasing added in v0.4.0

func RegisterLeasing(s *server.MCPServer, reg *registry.Registry, store leasing.Store)

RegisterLeasing registers the 8 lease tools described in v0.4.0 M2 of the leasing design memo. Tools wrap the in-process leasing.Store (M1).

The reg argument is used only by the topology / role convenience tools and the optional node-name validation in lease(). Store is owned by the caller (cmd/lablink-server/main.go).

func RegisterMultiNode

func RegisterMultiNode(s *server.MCPServer, reg *registry.Registry, pool *agentclient.Pool, auditLog *audit.Log, leaseCfg LeaseGateConfig)

func RegisterNodeOps

func RegisterNodeOps(s *server.MCPServer, reg *registry.Registry, pool *agentclient.Pool, leaseCfg LeaseGateConfig)

func RegisterPackage

func RegisterPackage(s *server.MCPServer, reg *registry.Registry, pool *agentclient.Pool, leaseCfg LeaseGateConfig)

func RegisterPatch

func RegisterPatch(s *server.MCPServer, reg *registry.Registry, pool *agentclient.Pool, auditLog *audit.Log, patchCfg *PatchConfig, leaseCfg LeaseGateConfig)

func RegisterPortal added in v0.2.0

func RegisterPortal(s *server.MCPServer)

RegisterPortal exposes get_portal_url so the AI client can hand the operator a clickable link to the local operations portal without grepping logs.

func RegisterProcess

func RegisterProcess(s *server.MCPServer, reg *registry.Registry, pool *agentclient.Pool, leaseCfg LeaseGateConfig)

func RegisterSchedule

func RegisterSchedule(s *server.MCPServer, reg *registry.Registry, pool *agentclient.Pool, auditLog *audit.Log, leaseCfg LeaseGateConfig)

func RegisterTopology

func RegisterTopology(s *server.MCPServer, reg *registry.Registry)

func RegisterTransfer

func RegisterTransfer(s *server.MCPServer, reg *registry.Registry, pool *agentclient.Pool, leaseCfg LeaseGateConfig)

func SetHealthMonitor

func SetHealthMonitor(m *healthmon.Monitor)

SetHealthMonitor stores the health monitor for use by all tool handlers.

func SetOpsRegistry

func SetOpsRegistry(r *ops.Registry)

SetOpsRegistry registers a process-wide operations registry. Tool handlers that opt in via beginOp will record themselves there for the local portal. Safe to leave nil; in that case beginOp is a no-op pass-through.

func SetPortalURL added in v0.2.0

func SetPortalURL(u string)

SetPortalURL records the bookmarkable portal URL for get_portal_url to return. Pass "" to indicate the portal is unavailable.

func StartMCPHeartbeat added in v0.4.1

func StartMCPHeartbeat(
	ctx context.Context,
	req mcp.CallToolRequest,
	interval time.Duration,
	progress func() (done, total int64),
) func()

StartMCPHeartbeat starts a background goroutine that sends a notifications/progress message to the MCP client every interval. progress is called on each tick to retrieve the current (done, total) pair. Returns a cancel func that stops the goroutine and waits for it to exit. Safe to call when req carries no _meta.progressToken — the goroutine is not started and the returned cancel is a no-op.

Types

type LeaseGateConfig added in v0.4.0

type LeaseGateConfig struct {
	Store    leasing.Store
	Registry *registry.Registry
	Enabled  bool
}

LeaseGateConfig is the wiring an MCP tool registration uses to enable lease checks. One LeaseGateConfig is shared across every tool registration in a single lablink-server process.

Enabled gates the whole middleware: when false, LeaseGate degrades to a pass-through (no lookup, no heartbeat, no allocation). Lease enforcement is opt-in: lablink-server leaves this false by default and enables it only when LABLINK_LEASE_REQUIRED=1 (or another affirmative token).

type NodeExtractor added in v0.4.0

type NodeExtractor func(mcp.CallToolRequest, *registry.Registry) []string

NodeExtractor pulls the tool-touched node names out of an MCP request. Tools that act on a single node pass extractSingleNode("node"); tools that fan out over a role/topology or a node list pass a custom extractor.

An empty return is allowed and means "this call doesn't touch a node" — LeaseGate then passes through without consulting the store.

type PatchConfig

type PatchConfig struct {
	SfpCopySource string // Network share or local path to sfpcopy.exe (dev machine accessible)
	CacheDir      string // Local cache dir for sfpcopy.exe on the dev machine
}

PatchConfig holds configurable paths for patching.

func NewPatchConfig

func NewPatchConfig(configDir string) *PatchConfig

Jump to

Keyboard shortcuts

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