mcp

package
v0.8.13 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package mcp implements the LLMSafeSpaces MCP server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddWorkflowTools added in v0.8.13

func AddWorkflowTools(srv *server.MCPServer, h *handlers)

AddWorkflowTools registers the Epic 64 workflow/trigger MCP tools on an existing MCPServer. Called by NewServer after registering the base tools.

func NewServer

func NewServer(client APIClient, defaultTimeout time.Duration) *server.MCPServer

NewServer creates a configured MCP server with all LLMSafeSpaces tools registered. Tools are workspace-centric — the sandbox layer is hidden from callers.

Types

type APIClient

type APIClient interface {
	CreateWorkspace(ctx context.Context, req CreateWorkspaceReq) (*WorkspaceResp, error)
	ActivateWorkspace(ctx context.Context, workspaceID string) (*ActivateResp, error)
	SuspendWorkspace(ctx context.Context, workspaceID string) error
	RefreshWorkspace(ctx context.Context, workspaceID string) (*RefreshWorkspaceResp, error)
	CreateSession(ctx context.Context, workspaceID string) (*SessionResp, error)
	GetHistory(ctx context.Context, workspaceID, sessionID string) ([]Message, error)
	SendMessage(ctx context.Context, workspaceID, sessionID, message string, timeout time.Duration) (string, error)

	// Agent input — question & permission replies (Epic 16 US-16.6)
	QuestionReply(ctx context.Context, workspaceID, requestID string, answers [][]string) error
	QuestionReject(ctx context.Context, workspaceID, requestID string) error
	PermissionReply(ctx context.Context, workspaceID, requestID, reply, message string) error

	// Credential management
	CreateCredential(ctx context.Context, req CreateCredentialReq) (*CredentialResp, error)
	ListCredentials(ctx context.Context) ([]CredentialResp, error)
	DeleteCredential(ctx context.Context, credentialID string) error
	BindCredential(ctx context.Context, workspaceID string, credentialIDs []string) error

	// Model management
	ListModels(ctx context.Context, workspaceID string) (json.RawMessage, error)
	SetModel(ctx context.Context, workspaceID, model string) error

	// Workflow management (Epic 64)
	ListWorkflows(ctx context.Context) (json.RawMessage, error)
	GetWorkflow(ctx context.Context, workflowID string) (json.RawMessage, error)
	CreateWorkflow(ctx context.Context, name, specYAML, status string) (json.RawMessage, error)
	UpdateWorkflow(ctx context.Context, workflowID, name, status, specYAML string) (json.RawMessage, error)
	RunWorkflow(ctx context.Context, workflowID, input, workspaceID string) (json.RawMessage, error)
	GetWorkflowRunStatus(ctx context.Context, runID string) (json.RawMessage, error)
	CancelWorkflowRun(ctx context.Context, runID string) error

	// Trigger management (Epic 64)
	ListTriggers(ctx context.Context) (json.RawMessage, error)
	CreateTrigger(ctx context.Context, name, sourceType, targetType, sourceConfig, targetConfig string) (json.RawMessage, error)
	UpdateTrigger(ctx context.Context, triggerID, enabled string) (json.RawMessage, error)
	DeleteTrigger(ctx context.Context, triggerID string) error
}

APIClient defines the interface for calling the LLMSafeSpaces REST API. All operations are workspace-centric — the sandbox layer is internal.

type ActivateResp

type ActivateResp struct {
	Resumed   string `json:"resumed"`
	Suspended string `json:"suspended,omitempty"`
}

ActivateResp is the response from workspace activation.

type CreateCredentialReq

type CreateCredentialReq struct {
	Name        string `json:"name"`
	Kind        string `json:"kind"`
	Slug        string `json:"slug"`
	APIKey      string `json:"apiKey"`
	BaseURL     string `json:"baseURL,omitempty"`
	Default     string `json:"default,omitempty"`
	WorkspaceID string `json:"workspaceID,omitempty"` // if set, auto-binds after creation
}

CreateCredentialReq is the request for creating an LLM provider credential.

Epic 55 identity model: Kind is the SDK-class enum (openai, anthropic, openai_compatible, ...) that selects the adapter the agent loads; Slug is the per-owner unique identity that becomes the agent-config.json provider key. Both are required — the API's llm-provider value validator rejects a credential missing either.

type CreateWorkspaceReq

type CreateWorkspaceReq struct {
	Name    string `json:"name,omitempty"`
	Runtime string `json:"runtime"`
}

CreateWorkspaceReq is the request body for workspace creation.

type CredentialResp

type CredentialResp struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Type string `json:"type"`
}

CredentialResp is the response from credential operations.

type HTTPClient

type HTTPClient struct {
	BaseURL    string
	HTTPClient *http.Client
	APIKey     string
}

HTTPClient implements APIClient using HTTP calls to the LLMSafeSpaces API. It resolves workspace → sandbox internally for session/message operations.

func (*HTTPClient) ActivateWorkspace

func (c *HTTPClient) ActivateWorkspace(ctx context.Context, workspaceID string) (*ActivateResp, error)

func (*HTTPClient) BindCredential

func (c *HTTPClient) BindCredential(ctx context.Context, workspaceID string, credentialIDs []string) error

func (*HTTPClient) CancelWorkflowRun added in v0.8.12

func (c *HTTPClient) CancelWorkflowRun(ctx context.Context, runID string) error

func (*HTTPClient) CreateCredential

func (c *HTTPClient) CreateCredential(ctx context.Context, req CreateCredentialReq) (*CredentialResp, error)

func (*HTTPClient) CreateSession

func (c *HTTPClient) CreateSession(ctx context.Context, workspaceID string) (*SessionResp, error)

CreateSession resolves workspace → sandbox, then creates a session via the proxy.

func (*HTTPClient) CreateTrigger added in v0.8.12

func (c *HTTPClient) CreateTrigger(ctx context.Context, name, sourceType, targetType, sourceConfig, targetConfig string) (json.RawMessage, error)

func (*HTTPClient) CreateWorkflow added in v0.8.12

func (c *HTTPClient) CreateWorkflow(ctx context.Context, name, specYAML, status string) (json.RawMessage, error)

func (*HTTPClient) CreateWorkspace

func (c *HTTPClient) CreateWorkspace(ctx context.Context, req CreateWorkspaceReq) (*WorkspaceResp, error)

func (*HTTPClient) DeleteCredential

func (c *HTTPClient) DeleteCredential(ctx context.Context, credentialID string) error

func (*HTTPClient) DeleteTrigger added in v0.8.12

func (c *HTTPClient) DeleteTrigger(ctx context.Context, triggerID string) error

func (*HTTPClient) GetHistory

func (c *HTTPClient) GetHistory(ctx context.Context, workspaceID, sessionID string) ([]Message, error)

func (*HTTPClient) GetWorkflow added in v0.8.12

func (c *HTTPClient) GetWorkflow(ctx context.Context, workflowID string) (json.RawMessage, error)

func (*HTTPClient) GetWorkflowRunStatus added in v0.8.12

func (c *HTTPClient) GetWorkflowRunStatus(ctx context.Context, runID string) (json.RawMessage, error)

func (*HTTPClient) ListCredentials

func (c *HTTPClient) ListCredentials(ctx context.Context) ([]CredentialResp, error)

func (*HTTPClient) ListModels

func (c *HTTPClient) ListModels(ctx context.Context, workspaceID string) (json.RawMessage, error)

func (*HTTPClient) ListTriggers added in v0.8.12

func (c *HTTPClient) ListTriggers(ctx context.Context) (json.RawMessage, error)

func (*HTTPClient) ListWorkflows added in v0.8.12

func (c *HTTPClient) ListWorkflows(ctx context.Context) (json.RawMessage, error)

func (*HTTPClient) PermissionReply

func (c *HTTPClient) PermissionReply(ctx context.Context, workspaceID, requestID, reply, message string) error

func (*HTTPClient) QuestionReject

func (c *HTTPClient) QuestionReject(ctx context.Context, workspaceID, requestID string) error

func (*HTTPClient) QuestionReply

func (c *HTTPClient) QuestionReply(ctx context.Context, workspaceID, requestID string, answers [][]string) error

func (*HTTPClient) RefreshWorkspace

func (c *HTTPClient) RefreshWorkspace(ctx context.Context, workspaceID string) (*RefreshWorkspaceResp, error)

func (*HTTPClient) RunWorkflow added in v0.8.12

func (c *HTTPClient) RunWorkflow(ctx context.Context, workflowID, input, workspaceID string) (json.RawMessage, error)

func (*HTTPClient) SendMessage

func (c *HTTPClient) SendMessage(ctx context.Context, workspaceID, sessionID, message string, timeout time.Duration) (string, error)

SendMessage sends a prompt via prompt_async, then subscribes to SSE events until session.idle is received or timeout expires.

func (*HTTPClient) SetModel

func (c *HTTPClient) SetModel(ctx context.Context, workspaceID, model string) error

func (*HTTPClient) SuspendWorkspace

func (c *HTTPClient) SuspendWorkspace(ctx context.Context, workspaceID string) error

func (*HTTPClient) UpdateTrigger added in v0.8.12

func (c *HTTPClient) UpdateTrigger(ctx context.Context, triggerID, enabled string) (json.RawMessage, error)

func (*HTTPClient) UpdateWorkflow added in v0.8.12

func (c *HTTPClient) UpdateWorkflow(ctx context.Context, workflowID, name, status, specYAML string) (json.RawMessage, error)

type Message

type Message struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

Message represents a chat message in session history.

type RefreshWorkspaceResp

type RefreshWorkspaceResp struct {
	RestartGeneration int64 `json:"restartGeneration"`
}

RefreshWorkspaceResp is the response from workspace compute refresh.

type SessionResp

type SessionResp struct {
	ID string `json:"id"`
}

SessionResp is the response from session creation.

type WorkspaceResp

type WorkspaceResp struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	Runtime string `json:"runtime"`
	Phase   string `json:"phase"`
}

WorkspaceResp is the response from workspace creation.

Jump to

Keyboard shortcuts

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