Documentation
¶
Overview ¶
Package mcpconnect serves the separately consented, draft-only external MCP connection. It has no reference to the in-app AI service or sending engine.
Index ¶
- Constants
- func Register(h huma.API, s *Service)
- func RegisterJobs(reg *jobs.Registry, s *Service)
- type ClientRegistration
- type MCPConnection
- type MCPConnectionList
- type MCPConsent
- type MCPConsentDecision
- type MCPConsentList
- type MCPConsentOptions
- type MCPConsentResult
- type MCPFlowSource
- type MCPProposalDecision
- type MCPProposalInput
- type MCPProposalList
- type MCPProposalListItem
- type MCPProposalReceipt
- type MCPProposalView
- type MCPProposedEmail
- type MCPProposedFlow
- type MCPSelectedSource
- type MCPSelectedSources
- type MCPSourceHandle
- type MCPSourceSelection
- type MCPWorkflowContent
- type MCPWorkflowInput
- type RegisteredClient
- type RetentionArgs
- type RetentionWorker
- type Service
- func (s *Service) Authorize(ctx context.Context, in url.Values) (string, error)
- func (s *Service) Connection(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (MCPConnection, error)
- func (s *Service) Connections(ctx context.Context, ws *store.Workspace, p *authz.Principal, cursor string) (MCPConnectionList, error)
- func (s *Service) Consent(ctx context.Context, raw string) (MCPConsent, error)
- func (s *Service) ConsentOptions(ctx context.Context, ws *store.Workspace, p *authz.Principal) (MCPConsentOptions, error)
- func (s *Service) DecideConsent(ctx context.Context, ws *store.Workspace, in MCPConsentDecision) (MCPConsentResult, error)
- func (s *Service) DecideProposal(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) error
- func (s *Service) DenyConsent(ctx context.Context, raw string) (MCPConsentResult, error)
- func (s *Service) Exchange(ctx context.Context, client store.McpConnectClient, in url.Values, ...) (TokenResponse, error)
- func (s *Service) Handler() http.Handler
- func (s *Service) Proposal(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (MCPProposalView, error)
- func (s *Service) Proposals(ctx context.Context, ws *store.Workspace, p *authz.Principal, cursor string) (MCPProposalList, error)
- func (s *Service) Purge(ctx context.Context) error
- func (s *Service) RegisterClient(ctx context.Context, in ClientRegistration, verified bool) (RegisteredClient, error)
- func (s *Service) RegisterPublic(r chi.Router)
- func (s *Service) RevokeConnection(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) error
- func (s *Service) RevokeToken(ctx context.Context, client store.McpConnectClient, raw string) error
- func (s *Service) SelectSource(ctx context.Context, ws *store.Workspace, p *authz.Principal, grant uuid.UUID, ...) (MCPSourceHandle, error)
- func (s *Service) SelectedSources(ctx context.Context, ws *store.Workspace, p *authz.Principal, grant uuid.UUID) (MCPSelectedSources, error)
- type TokenResponse
Constants ¶
const (
Path = "/mcp/connect"
)
Variables ¶
This section is empty.
Functions ¶
func RegisterJobs ¶
Types ¶
type ClientRegistration ¶
type ClientRegistration struct {
Name string `json:"client_name,omitempty" maxLength:"120"`
RedirectURIs []string `json:"redirect_uris" minItems:"1" maxItems:"5"`
AuthMethod string `json:"token_endpoint_auth_method,omitempty" enum:"none,client_secret_basic,client_secret_post"`
GrantTypes []string `json:"grant_types,omitempty"`
ResponseTypes []string `json:"response_types,omitempty"`
}
type MCPConnection ¶
type MCPConnection struct {
ID uuid.UUID `json:"id"`
ClientName string `json:"clientName"`
Verified bool `json:"verified"`
UserName string `json:"userName"`
UserID uuid.UUID `json:"userId"`
Scopes []string `json:"scopes"`
Lists []uuid.UUID `json:"lists"`
SenderDomains []string `json:"senderDomains"`
AllowedIPs []string `json:"allowedIps"`
CreatedAt time.Time `json:"createdAt"`
ExpiresAt time.Time `json:"expiresAt"`
RevokedAt *time.Time `json:"revokedAt,omitempty"`
RevokedReason string `json:"revokedReason"`
}
type MCPConnectionList ¶
type MCPConnectionList struct {
Items []MCPConnection `json:"items"`
NextCursor string `json:"nextCursor,omitempty"`
}
type MCPConsent ¶
type MCPConsentDecision ¶
type MCPConsentList ¶
type MCPConsentOptions ¶
type MCPConsentResult ¶
type MCPConsentResult struct {
Redirect string `json:"redirect"`
}
type MCPFlowSource ¶
type MCPFlowSource struct {
Graph automations.AutomationGraph `json:"graph"`
Emails map[string]editorial.Source `json:"emails"`
}
type MCPProposalDecision ¶
type MCPProposalDecision struct {
Decision string `json:"decision" enum:"kept,discarded,accepted,rejected"`
}
type MCPProposalInput ¶
type MCPProposalInput struct {
Key string `json:"key" jsonschema:"idempotency key: 1–80 ASCII letters, numbers, hyphens or underscores"`
Kind string `json:"kind" enum:"campaign,post"`
Name string `json:"name" minLength:"1" maxLength:"200"`
Source string `json:"source,omitempty" jsonschema:"selected source handle; omit for a new blank draft"`
Change bool `json:"change" jsonschema:"true proposes an exact-revision change; false creates a new draft copy"`
Email MCPProposedEmail `json:"email"`
}
type MCPProposalList ¶
type MCPProposalList struct {
Items []MCPProposalListItem `json:"items"`
NextCursor string `json:"nextCursor,omitempty"`
}
type MCPProposalListItem ¶
type MCPProposalListItem struct {
ID uuid.UUID `json:"id"`
Kind string `json:"kind"`
Name string `json:"name"`
ClientName string `json:"clientName"`
Verified bool `json:"verified"`
Change bool `json:"change"`
Decision string `json:"decision"`
ExpiresAt time.Time `json:"expiresAt"`
Purged bool `json:"purged"`
Revoked bool `json:"revoked"`
}
type MCPProposalReceipt ¶
type MCPProposalReceipt struct {
ID uuid.UUID `json:"id"`
Decision string `json:"decision"`
ExpiresAt time.Time `json:"expiresAt"`
}
Receipts contain no restored text, links, target IDs or reviewer identity.
type MCPProposalView ¶
type MCPProposalView struct {
ID uuid.UUID `json:"id"`
Kind string `json:"kind"`
Name string `json:"name"`
ClientName string `json:"clientName"`
Verified bool `json:"verified"`
UserName string `json:"userName"`
CreatedAt time.Time `json:"createdAt"`
CanDecide bool `json:"canDecide"`
BaseRevision int64 `json:"baseRevision"`
TargetID *uuid.UUID `json:"targetId,omitempty"`
Before *MCPProposedEmail `json:"before,omitempty"`
Email MCPProposedEmail `json:"email"`
HTML string `json:"html"`
Decision string `json:"decision"`
Blocked string `json:"blocked" enum:",expired,revoked,changed,purged,permission"`
ExpiresAt time.Time `json:"expiresAt"`
ResultID *uuid.UUID `json:"resultId,omitempty"`
Workflow *MCPWorkflowContent `json:"workflow,omitempty"`
BeforeFlow *MCPProposedFlow `json:"beforeFlow,omitempty"`
TriggerName string `json:"triggerName,omitempty"`
}
type MCPProposedEmail ¶
type MCPProposedFlow ¶
type MCPProposedFlow struct {
Graph automations.AutomationGraph `json:"graph"`
Emails []automations.ProposedEmail `json:"emails" minItems:"1" maxItems:"5"`
}
type MCPSelectedSource ¶
type MCPSelectedSource struct {
MCPSourceHandle
ID uuid.UUID `json:"id"`
Name string `json:"name"`
}
Human-only selection receipts; never returned to an external client.
type MCPSelectedSources ¶
type MCPSelectedSources struct {
Items []MCPSelectedSource `json:"items"`
}
type MCPSourceHandle ¶
type MCPSourceSelection ¶
type MCPSourceSelection struct {
SharingReviewed bool `` /* 137-byte string literal not displayed */
Kind string `json:"kind" enum:"campaign,post,template,voice,list,segment,automation,report"`
ID uuid.UUID `json:"id"`
}
Selecting a source is a human API action, never an external tool that can enumerate raw resource names or guess workspace IDs. Discovery returns only these explicitly selected, revision-bound handles.
type MCPWorkflowContent ¶
type MCPWorkflowContent struct {
Segment *segments.SegmentDefinition `json:"segment,omitempty"`
SegmentName string `json:"segmentName,omitempty"`
Flow *MCPProposedFlow `json:"flow,omitempty"`
Previews []string `json:"previews"`
}
type MCPWorkflowInput ¶
type MCPWorkflowInput struct {
Key string `json:"key" minLength:"1" maxLength:"80"`
Name string `json:"name" minLength:"1" maxLength:"120"`
Source string `json:"source" minLength:"1" maxLength:"100"`
TemplateSource string `json:"templateSource,omitempty" maxLength:"100"`
Change bool `json:"change"`
Trigger string `json:"trigger,omitempty" enum:"joined_list,segment_entered,segment_left"`
Segment *segments.SegmentDefinition `json:"segment,omitempty"`
SegmentName string `json:"segmentName,omitempty" maxLength:"120"`
Flow *MCPProposedFlow `json:"flow,omitempty"`
}
One proposal is one dependency bundle. No independently applicable child proposal can leave a flow referring to an unkept segment or email.
type RegisteredClient ¶
type RegisteredClient struct {
ClientRegistration
ID string `json:"client_id"`
Secret string `json:"client_secret,omitempty"`
IssuedAt int64 `json:"client_id_issued_at"`
SecretExpiresAt int64 `json:"client_secret_expires_at"`
}
type RetentionArgs ¶
type RetentionArgs struct{}
func (RetentionArgs) InsertOpts ¶
func (RetentionArgs) InsertOpts() river.InsertOpts
func (RetentionArgs) Kind ¶
func (RetentionArgs) Kind() string
type RetentionWorker ¶
type RetentionWorker struct {
river.WorkerDefaults[RetentionArgs]
S *Service
}
func (*RetentionWorker) Work ¶
func (w *RetentionWorker) Work(ctx context.Context, _ *river.Job[RetentionArgs]) error
type Service ¶
type Service struct {
Pool *pgxpool.Pool
Q *store.Queries
Audit *audit.Logger
PublicURL func() string
Development bool
Now func() time.Time
Campaigns *campaigns.Service
Website *website.Service
Automations *automations.Service
Segments *segments.Service
}
func (*Service) Connection ¶
func (*Service) Connections ¶
func (*Service) ConsentOptions ¶
func (s *Service) ConsentOptions(ctx context.Context, ws *store.Workspace, p *authz.Principal) (MCPConsentOptions, error)
Options are for the signed-in person's consent form, never MCP/model context.
func (*Service) DecideConsent ¶
func (s *Service) DecideConsent(ctx context.Context, ws *store.Workspace, in MCPConsentDecision) (MCPConsentResult, error)
func (*Service) DecideProposal ¶
func (*Service) DenyConsent ¶
Denial needs no workspace, capability or MFA upgrade: it never grants access.
func (*Service) Purge ¶
Purge runs bounded batches. Refresh replay hashes live until the absolute family expiry, including after rotation. Closed grants stay readable another seven days for recovery; their audit is retained independently.
func (*Service) RegisterClient ¶
func (s *Service) RegisterClient(ctx context.Context, in ClientRegistration, verified bool) (RegisteredClient, error)
func (*Service) RegisterPublic ¶
RegisterPublic mounts only protocol endpoints. Human consent uses the normal session/CSRF/MFA API middleware, never bearer credentials from this transport.