mcp

package
v1.9.10 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: AGPL-3.0 Imports: 20 Imported by: 1 module, 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

Index

Constants

View Source
const (
	KindCloud  = "cloud"
	KindLocal  = "local"
	KindCustom = "custom"

	CloudMCPURL = "https://api.apito.io/mcp"
	LocalMCPURL = "http://localhost:4055/mcp"

	ScopeMCP = "mcp"
)

Variables

This section is empty.

Functions

func ApprovalMintRequest

func ApprovalMintRequest(label string, scope GrantScope) (*models.CreateAccessTokenRequest, error)

ApprovalMintRequest builds the mint for an MCP approval. An empty preset stays mcp_assistant. MCP advanced and Custom are the other choices. Named presets ignore client-supplied capabilities.

func CanonicalResource

func CanonicalResource(raw string) (string, error)

CanonicalResource removes client hints from the resource identifier. kind and profile are not part of the OAuth audience.

func DefaultURL

func DefaultURL(kind, custom string) (string, error)

DefaultURL is the clean URL for a deployment. It does not add kind or profile.

func InferKind

func InferKind(raw string) (string, error)

InferKind reads the deployment from the URL. The host wins over any hint.

func NormalizeApprovalPreset

func NormalizeApprovalPreset(raw string, caps []string) (string, []string, error)

NormalizeApprovalPreset keeps MCP approval on mcp_assistant, mcp_advanced, or custom.

func PublicBase

func PublicBase(scheme, host, forwardedProto, forwardedHost, forwardedPort, configured string) string

PublicBase is scheme://host[:port] for the request the client actually used. A loopback host with no port is the Studio console on 4055. Nginx $host drops that port, and the MCP resource must still be http://localhost:4055/mcp.

func WithRESTMeta

func WithRESTMeta(ctx context.Context, projectID, tenantID string, headers map[string]string) context.Context

WithRESTMeta attaches project scope and headers to the context used by System.REST.

Types

type AccessRecord

type AccessRecord struct {
	Hash          string    `json:"hash"`
	ClientID      string    `json:"client_id"`
	Resource      string    `json:"resource"`
	UserID        string    `json:"user_id"`
	InternalToken string    `json:"internal_token,omitempty"`
	Scope         string    `json:"scope"`
	ExpiresAt     time.Time `json:"expires_at"`
	RefreshHash   string    `json:"refresh_hash,omitempty"`
}

type AuditEvent

type AuditEvent struct {
	RequestID string `json:"request_id"`
	Tool      string `json:"tool"`
	Transport string `json:"transport"`
	Edition   string `json:"edition"`
	ProjectID string `json:"project_id,omitempty"`
	TenantID  string `json:"tenant_id,omitempty"`
	ScopeOK   bool   `json:"scope_ok"`
	Error     string `json:"error,omitempty"`
}

AuditEvent is trusted server-side MCP metadata.

type Auditor

type Auditor interface {
	Record(ctx context.Context, event AuditEvent)
}

Auditor records MCP tool calls on the existing log pipeline.

type AuthRequest

type AuthRequest struct {
	ID            string    `json:"id"`
	ClientID      string    `json:"client_id"`
	RedirectURI   string    `json:"redirect_uri"`
	CodeChallenge string    `json:"code_challenge"`
	Method        string    `json:"method"`
	Resource      string    `json:"resource"`
	State         string    `json:"state"`
	Scope         string    `json:"scope"`
	ExpiresAt     time.Time `json:"expires_at"`
	Status        string    `json:"status"`
}

type ClientRecord

type ClientRecord struct {
	ID           string    `json:"id"`
	Name         string    `json:"name"`
	RedirectURIs []string  `json:"redirect_uris"`
	CreatedAt    time.Time `json:"created_at"`
}

type CodeRecord

type CodeRecord struct {
	Hash          string              `json:"hash"`
	ClientID      string              `json:"client_id"`
	RedirectURI   string              `json:"redirect_uri"`
	Challenge     string              `json:"challenge"`
	Method        string              `json:"method"`
	Resource      string              `json:"resource"`
	UserID        string              `json:"user_id"`
	InternalToken string              `json:"internal_token,omitempty"`
	ProjectMode   string              `json:"project_mode"`
	ProjectIDs    []string            `json:"project_ids"`
	TenantMode    string              `json:"tenant_mode"`
	TenantIDs     map[string][]string `json:"tenant_ids"`
	ExpiresAt     time.Time           `json:"expires_at"`
	Used          bool                `json:"used"`
}

type Endpoint

type Endpoint struct {
	Kind     string
	Resource string
	Public   string
}

Endpoint is the public MCP resource a client configures.

func Resolve

func Resolve(raw, kindHint string) (Endpoint, error)

Resolve applies an optional kind hint without letting it override the host.

type GrantScope

type GrantScope struct {
	Name              string
	Description       string
	Duration          string
	Preset            string
	Capabilities      []string
	ProjectGrantMode  string
	ProjectIDs        []string
	TenantGrantMode   string
	TenantIDs         map[string][]string
	AcknowledgeDanger bool
}

GrantScope is the project and tenant choice from the existing approval form.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler serves OAuth discovery and Streamable HTTP MCP on the engine router.

func Mount

func Mount(e *echo.Echo, opt Options) (*Handler, error)

type Options

type Options struct {
	Config    *models.Config
	StorePath string
	Authorize echo.MiddlewareFunc
	Mint      func(ctx context.Context, userID string, req *models.CreateAccessTokenRequest) (string, error)
	System    SystemAPI
	Audit     Auditor
	Edition   string
	Now       func() time.Time
}

Options wires the adapter to engine auth without a second permission model.

type RESTMeta

type RESTMeta struct {
	ProjectID string
	TenantID  string
	Headers   map[string]string
}

RESTMeta is project scope and extra headers for an in-process REST call.

func RESTMetaFrom

func RESTMetaFrom(ctx context.Context) (RESTMeta, bool)

RESTMetaFrom reads metadata attached by WithRESTMeta.

type RefreshRecord

type RefreshRecord struct {
	Hash          string    `json:"hash"`
	ClientID      string    `json:"client_id"`
	Resource      string    `json:"resource"`
	UserID        string    `json:"user_id"`
	InternalToken string    `json:"internal_token,omitempty"`
	Scope         string    `json:"scope"`
	ExpiresAt     time.Time `json:"expires_at"`
	Used          bool      `json:"used"`
}

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is the durable OAuth client, transaction, and credential record. It is not the process-local device-login map.

func OpenStore

func OpenStore(path string) (*Store, error)

func (*Store) Access

func (s *Store) Access(raw string) (AccessRecord, bool)

func (*Store) Client

func (s *Store) Client(id string) (ClientRecord, bool)

func (*Store) Request

func (s *Store) Request(id string) (AuthRequest, bool)

func (*Store) SaveAccess

func (s *Store) SaveAccess(raw string, rec AccessRecord) error

func (*Store) SaveClient

func (s *Store) SaveClient(rec ClientRecord) error

func (*Store) SaveCode

func (s *Store) SaveCode(raw string, rec CodeRecord) error

func (*Store) SaveRefresh

func (s *Store) SaveRefresh(raw string, rec RefreshRecord) error

func (*Store) SaveRequest

func (s *Store) SaveRequest(rec AuthRequest) error

func (*Store) TakeCode

func (s *Store) TakeCode(raw string) (CodeRecord, bool)

func (*Store) TakeRefresh

func (s *Store) TakeRefresh(raw string) (RefreshRecord, bool)

type SystemAPI

type SystemAPI interface {
	GraphQL(ctx context.Context, token, projectID, tenantID, query string, vars map[string]any) (json.RawMessage, error)
	REST(ctx context.Context, token, method, path string, body []byte) (int, json.RawMessage, error)
}

SystemAPI executes an already-authorized system call inside the engine process.

type Tool

type Tool struct {
	Name        string
	Description string
	Access      string
	ProOnly     bool
}

Tool is one MCP tool exposed by the engine adapter.

func Catalog

func Catalog() []Tool

Jump to

Keyboard shortcuts

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