Documentation
¶
Overview ¶
Package mcp implements the LLMSafeSpaces MCP server.
Index ¶
- func AddWorkflowTools(srv *server.MCPServer, h *handlers)
- func NewServer(client APIClient, defaultTimeout time.Duration) *server.MCPServer
- type APIClient
- type ActivateResp
- type CreateCredentialReq
- type CreateWorkspaceReq
- type CredentialResp
- type HTTPClient
- func (c *HTTPClient) ActivateWorkspace(ctx context.Context, workspaceID string) (*ActivateResp, error)
- func (c *HTTPClient) BindCredential(ctx context.Context, workspaceID string, credentialIDs []string) error
- func (c *HTTPClient) CancelWorkflowRun(ctx context.Context, runID string) error
- func (c *HTTPClient) CreateCredential(ctx context.Context, req CreateCredentialReq) (*CredentialResp, error)
- func (c *HTTPClient) CreateSession(ctx context.Context, workspaceID string) (*SessionResp, error)
- func (c *HTTPClient) CreateTrigger(ctx context.Context, ...) (json.RawMessage, error)
- func (c *HTTPClient) CreateWorkflow(ctx context.Context, name, specYAML, status string) (json.RawMessage, error)
- func (c *HTTPClient) CreateWorkspace(ctx context.Context, req CreateWorkspaceReq) (*WorkspaceResp, error)
- func (c *HTTPClient) DeleteCredential(ctx context.Context, credentialID string) error
- func (c *HTTPClient) DeleteTrigger(ctx context.Context, triggerID string) error
- func (c *HTTPClient) GetHistory(ctx context.Context, workspaceID, sessionID string) ([]Message, error)
- func (c *HTTPClient) GetWorkflow(ctx context.Context, workflowID string) (json.RawMessage, error)
- func (c *HTTPClient) GetWorkflowRunStatus(ctx context.Context, runID string) (json.RawMessage, error)
- func (c *HTTPClient) ListCredentials(ctx context.Context) ([]CredentialResp, error)
- func (c *HTTPClient) ListModels(ctx context.Context, workspaceID string) (json.RawMessage, error)
- func (c *HTTPClient) ListTriggers(ctx context.Context) (json.RawMessage, error)
- func (c *HTTPClient) ListWorkflows(ctx context.Context) (json.RawMessage, error)
- func (c *HTTPClient) PermissionReply(ctx context.Context, workspaceID, requestID, reply, message string) error
- func (c *HTTPClient) QuestionReject(ctx context.Context, workspaceID, requestID string) error
- func (c *HTTPClient) QuestionReply(ctx context.Context, workspaceID, requestID string, answers [][]string) error
- func (c *HTTPClient) RefreshWorkspace(ctx context.Context, workspaceID string) (*RefreshWorkspaceResp, error)
- func (c *HTTPClient) RunWorkflow(ctx context.Context, workflowID, input, workspaceID string) (json.RawMessage, error)
- func (c *HTTPClient) SendMessage(ctx context.Context, workspaceID, sessionID, message string, ...) (string, error)
- func (c *HTTPClient) SetModel(ctx context.Context, workspaceID, model string) error
- func (c *HTTPClient) SuspendWorkspace(ctx context.Context, workspaceID string) error
- func (c *HTTPClient) UpdateTrigger(ctx context.Context, triggerID string, enabled *bool) (json.RawMessage, error)
- func (c *HTTPClient) UpdateWorkflow(ctx context.Context, workflowID string, name, status, specYAML *string) (json.RawMessage, error)
- func (c *HTTPClient) UploadFile(ctx context.Context, workspaceID, filename string, content []byte) (*UploadResp, error)
- type Message
- type RefreshWorkspaceResp
- type SessionResp
- type UploadError
- type UploadResp
- type WorkspaceResp
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddWorkflowTools ¶ added in v0.8.13
AddWorkflowTools registers the Epic 64 workflow/trigger MCP tools on an existing MCPServer. Called by NewServer after registering the base tools.
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)
UploadFile(ctx context.Context, workspaceID, filename string, content []byte) (*UploadResp, 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 string, 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, sourceConfig, workspaceID, workflowID, prompt, memoryMode, captureMode, preserveSession string) (json.RawMessage, error)
UpdateTrigger(ctx context.Context, triggerID string, enabled *bool) (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 ¶
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 (*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 creates a session via POST /workspaces/:id/sessions/new (design 0041). The response is types.EnsureSessionResponse; the session identifier arrives in the sessionId field.
func (*HTTPClient) CreateTrigger ¶ added in v0.8.12
func (c *HTTPClient) CreateTrigger(ctx context.Context, name, sourceType, sourceConfig, workspaceID, workflowID, prompt, memoryMode, captureMode, preserveSession 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 (*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 (*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 the ABI contract stream (GET /workspaces/:id/contract-events — protojson StreamFrames, US-69.11) until the target session goes IDLE or the agent asks for input.
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 string, enabled *bool) (json.RawMessage, error)
UpdateTrigger issues a partial update via PUT /me/triggers/:id. The API binds types.UpdateTriggerRequest.Enabled *bool — a nil enabled sends no key (keep existing); a present value must be a JSON boolean (#1035).
func (*HTTPClient) UpdateWorkflow ¶ added in v0.8.12
func (c *HTTPClient) UpdateWorkflow(ctx context.Context, workflowID string, name, status, specYAML *string) (json.RawMessage, error)
UpdateWorkflow issues a partial update via PUT /me/workflows/:id. The API binds types.UpdateWorkflowRequest (pointer fields; nil = keep existing), so only the provided arguments are sent — omitted fields must not appear in the body at all, or their empty-string values fail validation server-side (#1036).
func (*HTTPClient) UploadFile ¶ added in v0.24.0
func (c *HTTPClient) UploadFile(ctx context.Context, workspaceID, filename string, content []byte) (*UploadResp, error)
UploadFile uploads content to the workspace via the REST upload route (US-68.2). The filename must already be sanitized (the handler applies agentd.SanitizeFilename; the API re-sanitizes — D9 defense-in-depth).
type Message ¶
type Message struct {
ID string `json:"id"`
Type string `json:"type"`
Parts []struct {
Type string `json:"type"`
Text string `json:"text"`
} `json:"parts"`
}
Message is one entry of session history, in the platform session contract shape (design 0049): every message is id/type/parts, and prose lives in text parts — the legacy {role, content} decode never matched the API response and always decoded empty (#1034 cluster).
func (Message) TextContent ¶ added in v0.22.0
TextContent returns the concatenated text parts of the message.
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:"sessionId"`
}
SessionResp is the response from session creation. The production route POST /workspaces/:id/sessions/new returns types.EnsureSessionResponse, whose session identifier is serialized as "sessionId" (#1033).
type UploadError ¶ added in v0.24.0
UploadError is the typed classification of an upload rejected by the API: the HTTP status, a public-safe message, and — for phase-gated rejections (409) — the workspace phase, so the tool error can name it instead of passing raw HTTP through (U1.5.11).
func (*UploadError) Error ¶ added in v0.24.0
func (e *UploadError) Error() string
type UploadResp ¶ added in v0.24.0
type UploadResp struct {
Path string `json:"path"`
Name string `json:"name"`
Size int64 `json:"size"`
}
UploadResp is the upload result: the workspace-absolute path of the stored file, its sanitized name, and its size in bytes.