Documentation
¶
Index ¶
Constants ¶
const ( LevelRead = "read" LevelActions = "actions" LevelWrite = "write" )
Access levels of a key issued to an OAuth client. A plain API key has none.
const ConfigPrefix = "MCP_"
ConfigPrefix is the environment prefix of Config.
Variables ¶
This section is empty.
Functions ¶
func EnabledFromEnv ¶
func EnabledFromEnv() bool
EnabledFromEnv reports whether MCP_ENABLED turns the MCP server on. It is read before the dependency graph is built, since it decides whether the graph holds the server at all.
Types ¶
type APIKeyAuthenticator ¶
type APIKeyAuthenticator struct {
// contains filtered or unexported fields
}
APIKeyAuthenticator authenticates workspace API keys.
func NewAPIKeyAuthenticator ¶
func NewAPIKeyAuthenticator(validator APIKeyValidator) *APIKeyAuthenticator
func (*APIKeyAuthenticator) Authenticate ¶
type APIKeyValidator ¶
type APIKeyValidator interface {
ValidateMCPKey(ctx context.Context, rawKey string) (MCPKey, error)
}
APIKeyValidator validates a raw workspace API key, plain or OAuth-issued.
type Authorizer ¶
Authorizer refuses a caller whose role does not allow a procedure.
type BearerAuthenticator ¶
type BearerAuthenticator interface {
Authenticate(ctx context.Context, token string) (principal Principal, claimed bool, err error)
}
BearerAuthenticator resolves one form of bearer token. claimed is false when the token is not of that form, so the next authenticator can try it. A token it claims but rejects returns an error wrapping connectutil.ErrInvalidCredential.
type Config ¶
type Config struct {
// Enabled starts the MCP HTTP server.
Enabled bool `env:"ENABLED" envDefault:"false"`
// WriteTools lists the tools that create, edit and delete entities.
WriteTools bool `env:"WRITE_TOOLS" envDefault:"true"`
// PublicURL is the base URL clients reach the MCP server at: the OAuth
// protected resource and authorization server issuer.
PublicURL string `env:"PUBLIC_URL" envDefault:"http://localhost:8082"`
// UIURL is the base URL of the main UI, which serves the OAuth consent
// page. Empty takes AUTH_OIDC_CALLBACK_BASE_URL.
UIURL string `env:"UI_URL"`
}
Config switches the MCP server and its write tools.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves the MCP endpoint at /mcp.
func NewHandler ¶
func NewHandler(cfg Config, services Services, authorizer Authorizer, authenticators ...BearerAuthenticator) *Handler
NewHandler serves the tools over Streamable HTTP without session state. Every request needs a bearer token one of authenticators accepts; one without answers 401 pointing at the protected resource metadata under cfg.PublicURL. Every tool call runs in that token's workspace, refused when the caller's role does not allow its procedures. A token's access level limits the tools it lists and calls: read lists the read tools, actions adds the action tools. Write tools are listed only when cfg.WriteTools is set. Every level serves the reference resources and sends serverInstructions on initialize.
type MCPKey ¶
MCPKey is what a workspace API key grants on /mcp. Level is empty for a plain API key.
type Principal ¶
Principal is the user and workspace a bearer token acts for, with the token's expiry and access level (empty for no limit).
type Services ¶
type Services struct {
Sources pipelinev1connect.SourceServiceHandler
Destinations pipelinev1connect.DestinationServiceHandler
Connections pipelinev1connect.ConnectionServiceHandler
Jobs pipelinev1connect.JobServiceHandler
Workflows pipelinev1connect.WorkflowServiceHandler
Stats statsv1connect.StatsServiceHandler
Registry registryv1connect.ConnectorRegistryServiceHandler
}
Services are the public API handlers the tools call.