mcpconnect

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: AGPL-3.0 Imports: 52 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	Path = "/mcp/connect"
)

Variables

This section is empty.

Functions

func Register

func Register(h huma.API, s *Service)

func RegisterJobs

func RegisterJobs(reg *jobs.Registry, s *Service)

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 MCPConsent struct {
	ClientName   string    `json:"clientName"`
	ClientID     string    `json:"clientId"`
	Verified     bool      `json:"verified"`
	CallbackHost string    `json:"callbackHost"`
	Scopes       []string  `json:"scopes"`
	ExpiresAt    time.Time `json:"expiresAt"`
}

type MCPConsentDecision

type MCPConsentDecision struct {
	Request       string      `json:"request" maxLength:"100"`
	Scopes        []string    `json:"scopes" maxItems:"3"`
	Lists         []uuid.UUID `json:"lists" maxItems:"100"`
	SenderDomains []string    `json:"senderDomains" maxItems:"100"`
	AllowedIPs    []string    `json:"allowedIps" maxItems:"20"`
}

type MCPConsentList

type MCPConsentList struct {
	ID   uuid.UUID `json:"id"`
	Name string    `json:"name"`
}

type MCPConsentOptions

type MCPConsentOptions struct {
	Endpoint       string           `json:"endpoint"`
	Scopes         []string         `json:"scopes"`
	Lists          []MCPConsentList `json:"lists"`
	SenderDomains  []string         `json:"senderDomains"`
	DefaultLists   []uuid.UUID      `json:"defaultLists"`
	DefaultDomains []string         `json:"defaultDomains"`
}

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 MCPProposedEmail struct {
	Subject   string `json:"subject" minLength:"1" maxLength:"250"`
	Preheader string `json:"preheader" maxLength:"500"`
	MJML      string `json:"mjml" minLength:"1" maxLength:"100000"`
}

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 MCPSourceHandle struct {
	Handle    string    `json:"handle"`
	Kind      string    `json:"kind"`
	ExpiresAt time.Time `json:"expiresAt"`
}

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

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) Authorize

func (s *Service) Authorize(ctx context.Context, in url.Values) (string, error)

func (*Service) Connection

func (s *Service) Connection(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (MCPConnection, error)

func (*Service) Connections

func (s *Service) Connections(ctx context.Context, ws *store.Workspace, p *authz.Principal, cursor string) (MCPConnectionList, error)

func (*Service) Consent

func (s *Service) Consent(ctx context.Context, raw string) (MCPConsent, error)

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 (s *Service) DecideProposal(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in MCPProposalDecision) error

func (*Service) DenyConsent

func (s *Service) DenyConsent(ctx context.Context, raw string) (MCPConsentResult, error)

Denial needs no workspace, capability or MFA upgrade: it never grants access.

func (*Service) Exchange

func (s *Service) Exchange(ctx context.Context, client store.McpConnectClient, in url.Values, ip *netip.Addr) (TokenResponse, error)

func (*Service) Handler

func (s *Service) Handler() http.Handler

func (*Service) Proposal

func (s *Service) Proposal(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (MCPProposalView, error)

func (*Service) Proposals

func (s *Service) Proposals(ctx context.Context, ws *store.Workspace, p *authz.Principal, cursor string) (MCPProposalList, error)

func (*Service) Purge

func (s *Service) Purge(ctx context.Context) error

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

func (s *Service) RegisterPublic(r chi.Router)

RegisterPublic mounts only protocol endpoints. Human consent uses the normal session/CSRF/MFA API middleware, never bearer credentials from this transport.

func (*Service) RevokeConnection

func (s *Service) RevokeConnection(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) error

func (*Service) RevokeToken

func (s *Service) RevokeToken(ctx context.Context, client store.McpConnectClient, raw string) error

func (*Service) SelectSource

func (s *Service) SelectSource(ctx context.Context, ws *store.Workspace, p *authz.Principal, grant uuid.UUID, in MCPSourceSelection) (MCPSourceHandle, error)

func (*Service) SelectedSources

func (s *Service) SelectedSources(ctx context.Context, ws *store.Workspace, p *authz.Principal, grant uuid.UUID) (MCPSelectedSources, error)

type TokenResponse

type TokenResponse struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	TokenType    string `json:"token_type"`
	ExpiresIn    int64  `json:"expires_in"`
	Scope        string `json:"scope"`
}

Jump to

Keyboard shortcuts

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