Documentation
¶
Overview ¶
Package gateway serves the hub's MCP endpoint, /mcp: the whole home as one MCP resource, "home", for ChatGPT and Claude. It is stateless and answers JSON (go-sdk Stateless + JSONResponse), so it needs no session state and no server-sent events.
MCP Gatekeeper's access check (mcpguard) runs in front of it: Routes mounts exactly /mcp behind Guard.MiddlewareFor("home"), so only a live OAuth access token for the home, of a person who is active, gets in. The gateway then:
- takes a place among the person's calls in flight (Guard.AdmitAccess: 8 per person);
- shows each person the tools their permissions allow (core.Person.Permissions: core.PermissionAll, or "plugin:<id>" per plugin; an owner has all; none means nothing), on an MCP server built per permission set, whose version fingerprint and instructions follow the tools;
- limits tool calls per grant (120 a minute), caps a call at 90 s (Cloudflare cuts an answer after about 100 s), tells the plugin who asked (hub.Caller: the person, Via "chatgpt" or "claude") and records every call in the activity log with redacted arguments.
Index ¶
Constants ¶
const ( // ResourceID is the gatekeeper resource of the home. ResourceID core.ResourceID = "home" // Path is the MCP endpoint. Path = "/mcp" )
The home as an MCP resource: one path, one resource id.
Variables ¶
var Paths = core.SingleResource{At: Path, ID: ResourceID}
Paths maps the home to /mcp and back (core.SingleResource).
Functions ¶
func PluginPermission ¶
PluginPermission is the permission id of a plugin: "plugin:<id>".
Types ¶
type Gateway ¶
type Gateway struct {
// contains filtered or unexported fields
}
Gateway is the MCP endpoint. Its home name may change while it serves.
func (*Gateway) Catalog ¶
func (g *Gateway) Catalog() core.ResourceCatalog
Catalog is the gatekeeper's resource catalog of the hub: one resource, the home. Any account of the hub may use it (a hub has one).
func (*Gateway) Resource ¶
func (g *Gateway) Resource() core.ResourceInfo
Resource is the home as the OAuth consent screen shows it: its name, and the assistants' tools.
func (*Gateway) Routes ¶
func (g *Gateway) Routes(guard *mcpguard.Guard) core.RouteRegistrar
Routes mounts exactly /mcp behind guard's access check for the home.
func (*Gateway) SetHomeName ¶
SetHomeName changes the home name in the instructions and the MCP title; the next request sees it. homed calls it when the home is renamed.
type Options ¶
type Options struct {
// HomeName is the home's name (the account's). It goes into the instructions and the MCP title.
HomeName string
// Instructions returns the enabled plugins' instructions, appended to the hub preamble. It is read again every
// time the tool set changes. Nil means none.
Instructions func() string
// Version is the hub version, the first half of the MCP serverInfo.version. Empty means "dev".
Version string
// RateLimit is the number of tool calls per minute allowed per grant (token bucket). Zero or less means 120.
RateLimit int
// MaxToolTimeout caps how long an assistant's tool call may run; zero or less means 90 s, under Cloudflare's cut.
MaxToolTimeout time.Duration
// Log receives warnings about tools the gateway has to skip. Nil discards them.
Log *slog.Logger
}
Options configures the gateway.