gateway

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 19 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 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

View Source
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

Paths maps the home to /mcp and back (core.SingleResource).

Functions

func PluginPermission

func PluginPermission(pluginID string) string

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 New

func New(host hub.ToolHost, audit hub.Auditor, opts Options) *Gateway

New returns the gateway. audit may be nil.

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

func (g *Gateway) SetHomeName(name string)

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.

Jump to

Keyboard shortcuts

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