Documentation
¶
Overview ¶
Package mcpserver provides the MCP server for remote agent orchestration. It supports two backends: K8s+Redis (original) and OpenShell (new).
Index ¶
- type Backend
- type ExecResult
- type Journal
- type K8sBackend
- func (b *K8sBackend) CreateSandbox(ctx context.Context, opts SandboxOpts) (string, error)
- func (b *K8sBackend) DeleteSandbox(ctx context.Context, name string) error
- func (b *K8sBackend) ExecStream(_ context.Context, _ string, _ []string) (ExecResult, error)
- func (b *K8sBackend) IdleCount(ctx context.Context) (int, error)
- func (b *K8sBackend) ListSandboxes(ctx context.Context) ([]SandboxStatus, error)
- func (b *K8sBackend) Redis() *redis.Client
- func (b *K8sBackend) TeamID() string
- type K8sConfig
- type Options
- type Pool
- type PoolBackend
- type SandboxOpts
- type SandboxStatus
- type Server
- type TaskEvent
- type TaskResult
- type TaskState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface {
CreateSandbox(ctx context.Context, opts SandboxOpts) (name string, err error)
DeleteSandbox(ctx context.Context, name string) error
ListSandboxes(ctx context.Context) ([]SandboxStatus, error)
ExecStream(ctx context.Context, name string, command []string) (ExecResult, error)
IdleCount(ctx context.Context) (int, error)
}
Backend abstracts the compute layer for sandbox lifecycle and task execution. Implementations: K8sBackend (Redis + K8s Deployments), compose.Backend (agent-compose).
type ExecResult ¶
ExecResult holds the output of a completed exec.
type Journal ¶
type Journal struct {
// contains filtered or unexported fields
}
Journal appends task events to a JSONL file and replays on startup.
func NewJournal ¶
NewJournal opens or creates a JSONL task journal. Replays existing events to rebuild in-memory state.
type K8sBackend ¶
type K8sBackend struct {
// contains filtered or unexported fields
}
K8sBackend implements Backend using Redis + K8s Deployments. This is the original backend; it stays operational until the OpenShell backend proves the full workflow end-to-end.
func NewK8sBackend ¶
func NewK8sBackend(cfg K8sConfig) (*K8sBackend, error)
NewK8sBackend creates a K8s backend from config.
func (*K8sBackend) CreateSandbox ¶
func (b *K8sBackend) CreateSandbox(ctx context.Context, opts SandboxOpts) (string, error)
func (*K8sBackend) DeleteSandbox ¶
func (b *K8sBackend) DeleteSandbox(ctx context.Context, name string) error
func (*K8sBackend) ExecStream ¶
func (b *K8sBackend) ExecStream(_ context.Context, _ string, _ []string) (ExecResult, error)
func (*K8sBackend) ListSandboxes ¶
func (b *K8sBackend) ListSandboxes(ctx context.Context) ([]SandboxStatus, error)
func (*K8sBackend) Redis ¶
func (b *K8sBackend) Redis() *redis.Client
Redis returns the underlying Redis client for task-level operations (createTask, getTask, etc.) that haven't been migrated to the journal yet.
func (*K8sBackend) TeamID ¶
func (b *K8sBackend) TeamID() string
TeamID returns the team identifier for scoping Redis keys.
type K8sConfig ¶
type K8sConfig struct {
RedisURL string
Kubeconfig string
Namespace string
TeamID string
MaxAgents int
}
K8sConfig holds connection settings for the K8s+Redis backend.
type Options ¶
type Options struct {
// Backend selection: "openshell" or "k8s" (default: "k8s")
Backend string
// ExternalBackend allows the caller to inject a pre-built Backend,
// avoiding import cycles. When set, Backend field is ignored.
ExternalBackend Backend
// OpenShell config (used when Backend=="openshell" and ExternalBackend is nil)
GatewayEndpoint string
GatewayInsecure bool
OpenShellBinary string
Image string
WarmPool int
// K8s config (backward compat)
RedisURL string
Kubeconfig string
Namespace string
TeamID string
// Coordination
Coordinator coordination.Coordinator
// Shared
JournalPath string
MaxAgents int
MaxCost float64
GithubToken string
GithubRepo string
}
Options configures the MCP server.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool manages a warm pool of pre-created sandboxes.
func (*Pool) EnsureCapacity ¶
EnsureCapacity verifies at least count idle sandboxes exist.
type PoolBackend ¶
PoolBackend is an optional interface for backends that support idle pool management.
type SandboxOpts ¶
type SandboxOpts struct {
Image string
Mode string // "worker" or "session"
Env map[string]string
Labels map[string]string
NoKeep bool
}
SandboxOpts configures a new sandbox.
type SandboxStatus ¶
type SandboxStatus struct {
Name string
Status string // "running", "ready", "stopped", "dead"
Idle bool
}
SandboxStatus describes a sandbox returned by ListSandboxes.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server holds all state for the MCP server.
type TaskEvent ¶
type TaskEvent struct {
TaskID string `json:"task_id"`
State string `json:"state"`
Prompt string `json:"prompt,omitempty"`
Provider string `json:"provider,omitempty"`
Sandbox string `json:"sandbox,omitempty"`
Result string `json:"result,omitempty"`
Error string `json:"error,omitempty"`
Timestamp string `json:"ts"`
}
TaskEvent is one line in the task journal.
type TaskResult ¶
type TaskResult struct {
Type string `json:"type"`
Summary string `json:"summary"`
FullText string `json:"full_text,omitempty"`
Branch string `json:"branch,omitempty"`
Commit string `json:"commit,omitempty"`
FilesChanged int `json:"files_changed,omitempty"`
Tokens int `json:"tokens_used,omitempty"`
Duration int `json:"duration_seconds,omitempty"`
}
TaskResult is the structured JSON returned by task execution.