Documentation
¶
Index ¶
- Constants
- Variables
- func ContextWithPeerInfo(ctx context.Context, peer PeerInfo, err error) context.Context
- func HostAPIProjectionCoverage() []string
- func ProjectedHostAPIMethods() []string
- func RunHostedProxy(ctx context.Context, client HostedProxyClient, opts HostedProxyOptions) error
- func ServeHTTP(ctx context.Context, invoker HostAPIInvoker, workspace string, ...) (err error)
- func ServeStdio(ctx context.Context, invoker HostAPIInvoker, workspace string, stdin io.Reader, ...) (err error)
- type CallExecutor
- func (e *CallExecutor) CallTool(ctx context.Context, source toolspkg.SourceRef, ...) (result toolspkg.ToolResult, err error)
- func (e *CallExecutor) ListTools(ctx context.Context, source toolspkg.SourceRef) ([]toolspkg.MCPToolDescriptor, error)
- func (e *CallExecutor) ListToolsWithProtocol(ctx context.Context, source toolspkg.SourceRef) (descriptors []toolspkg.MCPToolDescriptor, protocolVersion string, err error)
- func (e *CallExecutor) ProjectionGeneration(ctx context.Context, sources []toolspkg.SourceRef) (string, bool)
- func (e *CallExecutor) Status(ctx context.Context, source toolspkg.SourceRef) (status toolspkg.MCPAuthStatus, err error)
- type CallExecutorOption
- func WithAuthMutationGeneration(generation *mcpauth.MutationGeneration) CallExecutorOption
- func WithHTTPClient(client *http.Client) CallExecutorOption
- func WithSecretLookup(lookup func(string) string) CallExecutorOption
- func WithSecretResolver(resolver secretRefResolver) CallExecutorOption
- func WithTimeout(timeout time.Duration) CallExecutorOption
- func WithTokenStore(store mcpauth.TokenStore) CallExecutorOption
- type HostAPIFacade
- type HostAPIInvokeRequest
- type HostAPIInvokeResponse
- type HostAPIInvoker
- type HostAPISessionCloseRequest
- type HostedBindRequest
- type HostedBindResponse
- type HostedCallRequest
- type HostedCallResponse
- type HostedConfig
- type HostedLaunchRequest
- type HostedProjectionGeneration
- type HostedProjectionHandler
- type HostedProjectionResponse
- type HostedProxyClient
- type HostedProxyOptions
- type HostedRegistry
- type HostedReleaseRequest
- type HostedService
- func (s *HostedService) ArmLaunch(ctx context.Context, sessionID string) (err error)
- func (s *HostedService) Bind(ctx context.Context, req HostedBindRequest, peer PeerInfo) (response HostedBindResponse, err error)
- func (s *HostedService) Call(ctx context.Context, req HostedCallRequest, peer PeerInfo) (HostedCallResponse, error)
- func (s *HostedService) CancelLaunch(sessionID string)
- func (s *HostedService) Launch(ctx context.Context, req HostedLaunchRequest) (compozyconfig.MCPServer, error)
- func (s *HostedService) Projection(ctx context.Context, bindID string, peer PeerInfo) (HostedProjectionResponse, error)
- func (s *HostedService) ReleaseBind(bindID string)
- func (s *HostedService) ReleaseBindForPeer(ctx context.Context, bindID string, peer PeerInfo) error
- func (s *HostedService) ReleaseSession(sessionID string)
- type InsufficientScopeError
- type PeerInfo
- type ProjectionEpoch
- type ResolvedServer
- type ServerResolver
- type ServerResolverFunc
- type UnsupportedCapabilityError
- type UnsupportedProtocolVersionError
Constants ¶
const (
// HostedServerName is the single stdio MCP server name injected into ACP sessions.
HostedServerName = "compozy-hosted-tools"
)
Variables ¶
var ( ErrHostedDisabled = errors.New("mcp: hosted MCP is disabled") ErrHostedSessionRequired = errors.New("mcp: hosted MCP session id is required") ErrHostedNonceRequired = errors.New("mcp: hosted MCP bind nonce is required") ErrHostedNonceInvalid = errors.New("mcp: hosted MCP bind nonce is invalid") ErrHostedNonceExpired = errors.New("mcp: hosted MCP bind nonce expired") ErrHostedBindRequired = errors.New("mcp: hosted MCP bind id is required") ErrHostedBindNotFound = errors.New("mcp: hosted MCP bind not found") ErrHostedPeerInvalid = errors.New("mcp: hosted MCP peer validation failed") ErrHostedBinaryInvalid = errors.New("mcp: hosted MCP binary validation failed") ErrHostedRegistryRequired = errors.New("mcp: hosted MCP registry is required") ErrHostedProjectionChanged = errors.New("mcp: hosted MCP projection changed") )
var ErrAuthorizationRequired = errors.New("mcp: remote server requires authorization")
ErrAuthorizationRequired reports that a remote MCP server rejected the current bearer token.
var ErrPeerCredentialsUnsupported = errors.New("mcp: peer credential validation is unsupported")
Functions ¶
func ContextWithPeerInfo ¶
ContextWithPeerInfo annotates an accepted UDS connection context.
func HostAPIProjectionCoverage ¶
func HostAPIProjectionCoverage() []string
HostAPIProjectionCoverage reports methods missing an explicit publish or exclusion decision.
func ProjectedHostAPIMethods ¶
func ProjectedHostAPIMethods() []string
ProjectedHostAPIMethods returns the canonical, ordered Host API subset exposed by MCP serve.
func RunHostedProxy ¶
func RunHostedProxy(ctx context.Context, client HostedProxyClient, opts HostedProxyOptions) error
RunHostedProxy binds to the daemon and serves hosted Compozy tools over MCP stdio.
Types ¶
type CallExecutor ¶
type CallExecutor struct {
// contains filtered or unexported fields
}
CallExecutor lists and calls configured MCP servers through official MCP SDK clients.
func NewMCPCallExecutor ¶
func NewMCPCallExecutor( servers ServerResolver, opts ...CallExecutorOption, ) (*CallExecutor, error)
NewMCPCallExecutor constructs the daemon-owned MCP executor.
func (*CallExecutor) CallTool ¶
func (e *CallExecutor) CallTool( ctx context.Context, source toolspkg.SourceRef, req toolspkg.MCPToolCallRequest, ) (result toolspkg.ToolResult, err error)
CallTool invokes one configured MCP tool.
func (*CallExecutor) ListTools ¶
func (e *CallExecutor) ListTools( ctx context.Context, source toolspkg.SourceRef, ) ([]toolspkg.MCPToolDescriptor, error)
ListTools discovers tools from one configured MCP server.
func (*CallExecutor) ListToolsWithProtocol ¶
func (e *CallExecutor) ListToolsWithProtocol( ctx context.Context, source toolspkg.SourceRef, ) (descriptors []toolspkg.MCPToolDescriptor, protocolVersion string, err error)
ListToolsWithProtocol discovers tools and returns the protocol version negotiated with the server.
func (*CallExecutor) ProjectionGeneration ¶
func (e *CallExecutor) ProjectionGeneration( ctx context.Context, sources []toolspkg.SourceRef, ) (string, bool)
ProjectionGeneration reports the exact live tool-list cache generation for configured sources.
func (*CallExecutor) Status ¶
func (e *CallExecutor) Status( ctx context.Context, source toolspkg.SourceRef, ) (status toolspkg.MCPAuthStatus, err error)
Status returns token-redacted auth diagnostics for registry availability.
type CallExecutorOption ¶
type CallExecutorOption func(*CallExecutor)
CallExecutorOption configures the daemon-owned MCP executor.
func WithAuthMutationGeneration ¶
func WithAuthMutationGeneration(generation *mcpauth.MutationGeneration) CallExecutorOption
WithAuthMutationGeneration coordinates refresh with settings-owned login and logout.
func WithHTTPClient ¶
func WithHTTPClient(client *http.Client) CallExecutorOption
WithHTTPClient configures remote MCP HTTP calls with an explicit client.
func WithSecretLookup ¶
func WithSecretLookup(lookup func(string) string) CallExecutorOption
WithSecretLookup resolves auth client secret environment-variable names.
func WithSecretResolver ¶
func WithSecretResolver(resolver secretRefResolver) CallExecutorOption
WithSecretResolver resolves env: and vault: refs for MCP auth and stdio secret_env launch bindings.
func WithTimeout ¶
func WithTimeout(timeout time.Duration) CallExecutorOption
WithTimeout configures the default bounded call timeout when a caller has no deadline.
func WithTokenStore ¶
func WithTokenStore(store mcpauth.TokenStore) CallExecutorOption
WithTokenStore allows remote MCP authorization headers to be injected inside internal/mcp.
type HostAPIFacade ¶
type HostAPIFacade struct {
// contains filtered or unexported fields
}
HostAPIFacade binds MCP calls to one resolved workspace before dispatching existing Host API logic.
func NewHostAPIFacade ¶
func NewHostAPIFacade( handler *extensionpkg.HostAPIHandler, checker *extensionpkg.CapabilityChecker, workspaces workspacepkg.RuntimeResolver, sourceSessions resources.SourceSessionManager, ) *HostAPIFacade
NewHostAPIFacade constructs the daemon-side MCP projection adapter.
func (*HostAPIFacade) Close ¶
func (f *HostAPIFacade) Close(ctx context.Context) error
Close releases every daemon-local grant and resource source retained by MCP serve clients.
func (*HostAPIFacade) CloseHostAPISession ¶
func (f *HostAPIFacade) CloseHostAPISession(ctx context.Context, serveSessionID string) error
CloseHostAPISession releases one MCP serve client's grant and source-owned resources.
func (*HostAPIFacade) InvokeHostAPI ¶
func (f *HostAPIFacade) InvokeHostAPI( ctx context.Context, serveSessionID string, workspaceRef string, method string, params json.RawMessage, ) (json.RawMessage, error)
InvokeHostAPI resolves, validates, and binds a projected request before invoking the Host API.
type HostAPIInvokeRequest ¶
type HostAPIInvokeRequest struct {
ServeSessionID string `json:"serve_session_id"`
Workspace string `json:"workspace"`
Method string `json:"method"`
Params json.RawMessage `json:"params"`
}
HostAPIInvokeRequest is the daemon-internal UDS relay contract for one projected call.
type HostAPIInvokeResponse ¶
type HostAPIInvokeResponse struct {
Result json.RawMessage `json:"result"`
}
HostAPIInvokeResponse carries the canonical Host API result without reshaping it.
type HostAPIInvoker ¶
type HostAPIInvoker interface {
InvokeHostAPI(
ctx context.Context,
serveSessionID string,
workspace string,
method string,
params json.RawMessage,
) (json.RawMessage, error)
CloseHostAPISession(ctx context.Context, serveSessionID string) error
}
HostAPIInvoker dispatches a workspace-bound Host API call through the running daemon.
type HostAPISessionCloseRequest ¶
type HostAPISessionCloseRequest struct {
ServeSessionID string `json:"serve_session_id"`
}
HostAPISessionCloseRequest identifies one MCP serve client lifecycle to release.
type HostedBindRequest ¶
type HostedBindRequest struct {
SessionID string `json:"session_id"`
Nonce string `json:"bind_nonce"`
}
HostedBindRequest is sent by the stdio proxy immediately after ACP starts it.
type HostedBindResponse ¶
type HostedBindResponse struct {
BindID string `json:"bind_id"`
Scope tools.Scope `json:"scope"`
Tools []tools.ToolView `json:"tools"`
Digest string `json:"digest"`
}
HostedBindResponse proves a hosted proxy has bound to one launch record.
type HostedCallRequest ¶
type HostedCallRequest struct {
BindID string `json:"bind_id"`
ToolName string `json:"tool_name"`
ToolCallID string `json:"tool_call_id,omitempty"`
CorrelationID string `json:"correlation_id,omitempty"`
Input json.RawMessage `json:"input,omitempty"`
}
HostedCallRequest invokes one hosted MCP tool through the registry.
type HostedCallResponse ¶
type HostedCallResponse struct {
Result tools.ToolResult `json:"result"`
}
HostedCallResponse carries the canonical registry result envelope.
type HostedConfig ¶
type HostedConfig struct {
Enabled bool
BindNonceTTL time.Duration
ExpectedBinary string
HomePaths compozyconfig.HomePaths
Registry HostedRegistry
ProjectionGeneration HostedProjectionGeneration
Logger *slog.Logger
Now func() time.Time
NonceReader func([]byte) error
}
HostedConfig configures hosted MCP launch and bind validation.
type HostedLaunchRequest ¶
HostedLaunchRequest describes one session-bound MCP launch.
type HostedProjectionGeneration ¶
HostedProjectionGeneration identifies one complete authoritative projection state. Returning known=false keeps projection reads uncached.
type HostedProjectionHandler ¶
type HostedProjectionHandler func(HostedProjectionResponse) error
HostedProjectionHandler receives projection snapshots from the daemon stream.
type HostedProjectionResponse ¶
type HostedProjectionResponse struct {
Tools []tools.ToolView `json:"tools"`
Digest string `json:"digest"`
}
HostedProjectionResponse is a full session-callable projection snapshot.
type HostedProxyClient ¶
type HostedProxyClient interface {
BindHostedMCP(ctx context.Context, req HostedBindRequest) (HostedBindResponse, error)
HostedMCPProjection(ctx context.Context, bindID string) (HostedProjectionResponse, error)
StreamHostedMCPProjection(
ctx context.Context,
bindID string,
lastDigest string,
handler HostedProjectionHandler,
) error
CallHostedMCP(ctx context.Context, req HostedCallRequest) (HostedCallResponse, error)
ReleaseHostedMCP(ctx context.Context, req HostedReleaseRequest) error
}
HostedProxyClient is the UDS client surface consumed by the hosted stdio proxy.
type HostedProxyOptions ¶
type HostedProxyOptions struct {
SessionID string
Nonce string
Stdin io.Reader
Stdout io.Writer
Stderr io.Writer
Version string
}
HostedProxyOptions configures one `compozy tool mcp` stdio proxy process.
type HostedRegistry ¶
HostedRegistry resolves the daemon-owned tool registry at call time.
type HostedReleaseRequest ¶
type HostedReleaseRequest struct {
BindID string `json:"bind_id"`
}
HostedReleaseRequest releases one active bind record.
type HostedService ¶
type HostedService struct {
// contains filtered or unexported fields
}
HostedService owns session-scoped hosted MCP launch and bind lifecycle.
func NewHostedService ¶
func NewHostedService(cfg HostedConfig) (*HostedService, error)
NewHostedService builds a hosted MCP lifecycle service.
func (*HostedService) ArmLaunch ¶
func (s *HostedService) ArmLaunch(ctx context.Context, sessionID string) (err error)
ArmLaunch starts the first-bind window after the ACP provider has initialized.
func (*HostedService) Bind ¶
func (s *HostedService) Bind( ctx context.Context, req HostedBindRequest, peer PeerInfo, ) (response HostedBindResponse, err error)
Bind consumes a launch nonce after validating the Unix peer and expected binary.
func (*HostedService) Call ¶
func (s *HostedService) Call(ctx context.Context, req HostedCallRequest, peer PeerInfo) (HostedCallResponse, error)
Call routes a hosted MCP tool call through the registry dispatch pipeline.
func (*HostedService) CancelLaunch ¶
func (s *HostedService) CancelLaunch(sessionID string)
CancelLaunch removes all hosted state for a failed session start.
func (*HostedService) Launch ¶
func (s *HostedService) Launch(ctx context.Context, req HostedLaunchRequest) (compozyconfig.MCPServer, error)
Launch mints a session-bound, single-use hosted MCP launch record.
func (*HostedService) Projection ¶
func (s *HostedService) Projection( ctx context.Context, bindID string, peer PeerInfo, ) (HostedProjectionResponse, error)
Projection returns the current session-callable tool projection for one bind.
func (*HostedService) ReleaseBind ¶
func (s *HostedService) ReleaseBind(bindID string)
ReleaseBind removes one active bind record.
func (*HostedService) ReleaseBindForPeer ¶
ReleaseBindForPeer removes a bind only after validating the requesting peer still owns it.
func (*HostedService) ReleaseSession ¶
func (s *HostedService) ReleaseSession(sessionID string)
ReleaseSession removes all hosted state for a stopped session.
type InsufficientScopeError ¶
type InsufficientScopeError struct {
Scopes []string
}
InsufficientScopeError reports a remote OAuth challenge that requires explicit scope approval.
func (*InsufficientScopeError) Error ¶
func (e *InsufficientScopeError) Error() string
type PeerInfo ¶
type PeerInfo struct {
PID int `json:"pid"`
UID int `json:"uid"`
GID int `json:"gid"`
ExecutablePath string `json:"executable_path"`
Supported bool `json:"supported"`
}
PeerInfo is the UDS peer identity captured from the accepted socket.
func PeerInfoFromConn ¶
PeerInfoFromConn returns OS peer credentials and executable identity for an accepted UDS connection.
type ProjectionEpoch ¶
type ProjectionEpoch struct {
// contains filtered or unexported fields
}
ProjectionEpoch is the daemon-owned monotonic invalidation source for hosted tool projections.
func NewProjectionEpoch ¶
func NewProjectionEpoch() *ProjectionEpoch
NewProjectionEpoch creates an initialized projection epoch.
func (*ProjectionEpoch) Advance ¶
func (e *ProjectionEpoch) Advance() uint64
Advance invalidates projections built against an earlier daemon state.
func (*ProjectionEpoch) Current ¶
func (e *ProjectionEpoch) Current() uint64
Current returns the current epoch without changing it.
type ResolvedServer ¶
type ResolvedServer struct {
Server compozyconfig.MCPServer
Target mcpauth.Target
}
ResolvedServer binds one MCP config to its OAuth credential owner.
type ServerResolver ¶
type ServerResolver interface {
ResolveMCPServer(ctx context.Context, source toolspkg.SourceRef) (ResolvedServer, error)
}
ServerResolver returns the daemon-visible MCP server selected by one source.
type ServerResolverFunc ¶
ServerResolverFunc adapts a function into a server resolver.
func (ServerResolverFunc) ResolveMCPServer ¶
func (f ServerResolverFunc) ResolveMCPServer( ctx context.Context, source toolspkg.SourceRef, ) (ResolvedServer, error)
ResolveMCPServer returns the configured MCP server selected by source.
type UnsupportedCapabilityError ¶
type UnsupportedCapabilityError struct {
Capability string
}
UnsupportedCapabilityError reports an MCP capability Compozy intentionally does not implement.
func (*UnsupportedCapabilityError) Error ¶
func (e *UnsupportedCapabilityError) Error() string
type UnsupportedProtocolVersionError ¶
type UnsupportedProtocolVersionError struct{ Version string }
UnsupportedProtocolVersionError reports a peer that negotiated outside Compozy's MCP contract.
func (*UnsupportedProtocolVersionError) Error ¶
func (e *UnsupportedProtocolVersionError) Error() string
Source Files
¶
- authorization_required.go
- executor.go
- executor_auth.go
- executor_cache.go
- executor_client.go
- executor_payload_redaction.go
- executor_redaction.go
- executor_result.go
- executor_result_binary.go
- executor_server_resolver.go
- executor_setup.go
- executor_tools.go
- hosted.go
- hosted_binding.go
- hosted_bootstrap_projection.go
- hosted_path.go
- hosted_projection_cache.go
- hosted_projection_generation.go
- hosted_proxy.go
- hosted_proxy_result.go
- hosted_proxy_transport_error.go
- hosted_records.go
- hosted_tool_views.go
- insufficient_scope.go
- peer.go
- peer_linux.go
- protocol.go
- serve.go
- serve_binding.go
- serve_facade.go
- serve_http.go
- serve_projection.go
- serve_projection_decisions.go
- tool_descriptor.go
- unsupported_capability.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package securehttp provides outbound HTTP clients for remote MCP and OAuth services.
|
Package securehttp provides outbound HTTP clients for remote MCP and OAuth services. |