mcpgw

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 27 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 mcpgw is Keystone's MCP gateway: clients reach registered MCP servers through /mcp with a KTMS key, and the gateway holds the servers' credentials, enforces each key's allowed_mcp and tool_rpm, and accounts for every tool call.

Index

Constants

View Source
const A2AVersion = "0.3.0"

A2AVersion is the A2A protocol version the bridge speaks.

View Source
const CodeForbidden = -32003

CodeForbidden is the JSON-RPC error of a tool or server the key may not use.

View Source
const Separator = "__"

Separator joins a server and a tool name in the /mcp aggregate.

View Source
const UserHeader = "X-KTMS-User"

UserHeader names the end user a call is made for, as user_id does on /v1.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builtin added in v1.6.0

type Builtin interface {
	Tools() []*mcp.Tool
	Call(ctx context.Context, id *apikeys.Identity, tool string, args json.RawMessage) (*mcp.CallToolResult, error)
}

Builtin is a server KTMS answers itself (agents.Service), named agents.Server.

type Gateway

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

Gateway serves /mcp and /mcp/{server}.

func New

func New(snaps Snapshots, verifier Verifier, limiter ToolLimiter, recorder Recorder, version string) *Gateway

New builds a gateway; limiter and recorder may be nil.

func (*Gateway) Close

func (g *Gateway) Close()

Close ends every upstream session.

func (*Gateway) ListTools

func (g *Gateway) ListTools(ctx context.Context, server string) ([]*mcp.Tool, error)

ListTools is the server's tools for an operator (Admin API ListMCPTools).

func (*Gateway) Register

func (g *Gateway) Register(mux *http.ServeMux)

Register mounts the gateway on mux.

func (*Gateway) WithAgents added in v1.6.0

func (g *Gateway) WithAgents(b Builtin, rpm int32) *Gateway

WithAgents serves the agents' inbox as the server agents.Server, rpm calls a minute per key (0 = unlimited); it shadows an upstream of the same name.

type Recorder

type Recorder interface {
	RecordToolCall(usagereport.ToolCall) error
}

Recorder accounts for tool calls (usagereport.UsageCollectorClient).

type Snapshots

type Snapshots interface {
	Snapshot() *registry.Snapshot
}

Snapshots is the live configuration (registry.Loader).

type ToolLimiter

type ToolLimiter interface {
	AdmitTool(ctx context.Context, keyName, server, tool string, rpm int32) (bool, time.Duration)
}

ToolLimiter enforces tool_rpm (throttle.Redis).

type Verifier

type Verifier interface {
	VerifyScope(ctx context.Context, plain, scope string) (*apikeys.Identity, error)
}

Verifier authenticates a client key for a scope (apikeys.Verifier).

Jump to

Keyboard shortcuts

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