Documentation
¶
Index ¶
- Constants
- func NormalizeOrigin(raw string) (string, error)
- type AuthValue
- type AuthzConfig
- type AuthzDecisionPath
- type AuthzHeaders
- type AuthzInput
- type AuthzInputHeaderField
- type Config
- type EdgeAuth
- type EdgeConfig
- type FileFetchConfig
- type Gateway
- type IdentityProfile
- type IdentitySource
- type MCPTransport
- type MemoryConfig
- type OAuth2
- type PairingConfig
- type PairingType
- type RedisConfig
- type S3
- type SQLiteConfig
- type Server
- func (s Server) CallTimeoutOrDefault() time.Duration
- func (s Server) EffectiveSpecRefreshInterval(global time.Duration) time.Duration
- func (s Server) GeneratedToolsFile() string
- func (s *Server) IsMCPBackend() bool
- func (s *Server) IsReverseBackend() bool
- func (s Server) ValidateWithContext(ctx context.Context) error
- type Servers
- type SpecRefreshConfig
- type Storage
- type TokenExchange
- type ToolsConfig
Constants ¶
const ( DefaultAuthzOPAURL = "http://localhost:8181" DefaultAuthzTimeout = 3 * time.Second DefaultAuthzDecisionPathList = "/v1/data/mcp/authz/allowed_tools" DefaultAuthzDecisionPathCall = "/v1/data/mcp/authz/allow" DefaultAuthzDecisionPathCatalog = "/v1/data/mcp/authz/allow_catalog" DefaultAuthzHeaderUserID = "x-user-id" DefaultAuthzHeaderUserGroups = "x-user-groups" DefaultAuthzHeaderBypass = "x-authz-bypass" //nolint: gosec // header name, not a credential DefaultAuthzInputUser = "user" DefaultAuthzInputGroups = "groups" DefaultAuthzInputServer = "server" DefaultAuthzInputTool = "tool" DefaultAuthzInputTools = "tools" DefaultAuthzInputToolName = "name" )
既定値(authz 設定省略時)。
const ( AuthzInputFieldTypeString = "string" AuthzInputFieldTypeList = "list" AuthzInputFieldTypeNumber = "number" )
Value types accepted by AuthzInputHeaderField.Type, naming the JSON type the header's raw value becomes in the decision input. An empty Type is a synonym for AuthzInputFieldTypeString.
const DefaultCallTimeout = 60 * time.Second
DefaultCallTimeout is used when Server.CallTimeout is unset (<= 0) for a reverse transport server.
const DefaultFileFetchMaxSize int64 = 524288000
DefaultFileFetchMaxSize is used when FileFetchConfig.MaxSize is unset (<= 0). 500 MiB (524288000 bytes).
const DefaultIdentityClaim = "sub"
DefaultIdentityClaim is used when IdentityProfile.Claim is unset for a source: jwt profile.
const DefaultIntrospectionCacheTTL = 5 * time.Minute
DefaultIntrospectionCacheTTL is used when IdentityProfile.CacheTTL is unset (<= 0) for a source: introspection profile.
Variables ¶
This section is empty.
Functions ¶
func NormalizeOrigin ¶ added in v1.7.0
NormalizeOrigin validates that raw is a bare origin (scheme + host, no path/query/fragment/userinfo) and returns it with a lowercased scheme and host. Only http/https are accepted.
Types ¶
type AuthzConfig ¶ added in v1.11.0
type AuthzConfig struct {
Enabled bool `mapstructure:"enabled"`
OPAURL string `mapstructure:"opaURL"`
Timeout time.Duration `mapstructure:"timeout"`
DecisionPath AuthzDecisionPath `mapstructure:"decisionPath"`
Headers AuthzHeaders `mapstructure:"headers"`
Input AuthzInput `mapstructure:"input"`
}
AuthzConfig configures the OPA sidecar used as the tool-call PDP. Disabled (Enabled: false) by default, preserving prior behavior.
func (AuthzConfig) ValidateWithContext ¶ added in v1.11.0
func (c AuthzConfig) ValidateWithContext(ctx context.Context) error
func (AuthzConfig) WithDefaults ¶ added in v1.11.0
func (c AuthzConfig) WithDefaults() AuthzConfig
WithDefaults returns a copy of c with zero-value fields replaced by the documented defaults.
type AuthzDecisionPath ¶ added in v1.11.0
type AuthzDecisionPath struct {
List string `mapstructure:"list"`
Call string `mapstructure:"call"`
Catalog string `mapstructure:"catalog"`
}
AuthzDecisionPath is the OPA data path queried for each decision kind (see docs/design/opa-tool-authorization-plan.ja.md「動作」).
func (AuthzDecisionPath) ValidateWithContext ¶ added in v1.11.0
func (c AuthzDecisionPath) ValidateWithContext(ctx context.Context) error
type AuthzHeaders ¶ added in v1.11.0
type AuthzHeaders struct {
UserID string `mapstructure:"userID"`
UserGroups string `mapstructure:"userGroups"`
Bypass string `mapstructure:"bypass"`
}
AuthzHeaders names the inbound HTTP headers an upstream identity/authn layer is expected to inject before Manifold sees the request. AuthzHeaders.Bypass is checked against the literal string "true" (see authz.BypassRequested); it exists so a fronting proxy can disable authz per-request for tenants that opt out, without flipping Enabled globally.
func (AuthzHeaders) ValidateWithContext ¶ added in v1.11.0
func (c AuthzHeaders) ValidateWithContext(ctx context.Context) error
type AuthzInput ¶ added in v1.12.0
type AuthzInput struct {
User string `mapstructure:"user"`
Groups string `mapstructure:"groups"`
Server string `mapstructure:"server"`
Tool string `mapstructure:"tool"`
Tools string `mapstructure:"tools"`
ToolName string `mapstructure:"toolName"`
// FromHeaders maps a decision-input field name to the inbound HTTP
// header it is read from. Resolved values are added as top-level
// fields to every decision input, typed per AuthzInputHeaderField.Type.
// Empty (the default) adds nothing; a required header missing or empty
// on a request denies (authz.ErrMissingInputHeader), while an optional
// one is simply left out of the input.
FromHeaders map[string]AuthzInputHeaderField `mapstructure:"fromHeaders"`
}
AuthzInput names the JSON keys Manifold uses when building the OPA decision input (see OPADecider.Allow / AllowedTools / AllowCatalog). Configurable so a policy author can match an existing input contract instead of Manifold's defaults.
func (AuthzInput) ValidateWithContext ¶ added in v1.12.0
func (c AuthzInput) ValidateWithContext(ctx context.Context) error
ValidateWithContext rejects collisions between keys that appear together in the same OPA input object: user/groups/server/tool (tools/call), user/groups/tools (tools/list), and server/toolName (each tools/list array element). Empty keys are not rejected here: like headers.*, decisionPath.*, opaURL and timeout, a zero value means "unset" and is backfilled by WithDefaults before validation runs.
type AuthzInputHeaderField ¶ added in v1.12.0
type AuthzInputHeaderField struct {
Header string `mapstructure:"header"`
Required *bool `mapstructure:"required"`
Type string `mapstructure:"type"`
}
AuthzInputHeaderField describes one entry of AuthzInput.FromHeaders: the inbound header to read, whether the request is denied when it is absent, and how the raw value is turned into a JSON value.
func (AuthzInputHeaderField) IsRequired ¶ added in v1.12.0
func (f AuthzInputHeaderField) IsRequired() bool
IsRequired reports whether a missing or empty header denies the request. Unset (nil) means required, so omitting the key stays fail-closed while still letting an explicit false through.
type Config ¶
type Config struct {
Gateway Gateway `mapstructure:"gateway"`
MCPServer Servers `mapstructure:"mcpServers"`
Redis *RedisConfig `mapstructure:"redis"`
SQLite *SQLiteConfig `mapstructure:"sqlite"`
Memory *MemoryConfig `mapstructure:"memory"`
Telemetry telemetry.Config `mapstructure:"telemetry"`
FileFetch FileFetchConfig `mapstructure:"fileFetch"`
Storage Storage `mapstructure:"storage"`
Identities map[string]*IdentityProfile `mapstructure:"identities"`
Authz AuthzConfig `mapstructure:"authz"`
}
type EdgeConfig ¶ added in v1.7.0
type EdgeConfig struct {
Auth EdgeAuth `mapstructure:"auth"`
Pairing PairingConfig `mapstructure:"pairing"`
// TrustCloudflare, when true, additionally trusts Cloudflare's published
// edge IP ranges as /edge/pair rate-limit forwarders. Only enable this
// when Manifold is actually deployed behind Cloudflare — see
// docs/design/webmcp-reverse-gateway-phase2.ja.md「Phase 1 からの持ち越し判断事項」.
TrustCloudflare bool `mapstructure:"trustCloudflare"`
// TrustedForwarders adds extra CIDR prefixes to trust as /edge/pair
// rate-limit forwarders, alongside the RFC1918 default and (if enabled)
// Cloudflare's ranges — e.g. an ALB/Ingress subnet outside RFC1918.
TrustedForwarders []string `mapstructure:"trustedForwarders"`
}
EdgeConfig selects how the reverse-connection browser extension binds its WebSocket connection to an identityKey (see docs/design/webmcp-reverse-gateway.ja.md).
func (EdgeConfig) IsStaticPairing ¶ added in v1.7.0
func (c EdgeConfig) IsStaticPairing() bool
IsStaticPairing reports whether this deployment binds the edge connection to a fixed identityKey instead of deriving one per agent request.
func (EdgeConfig) ValidateWithContext ¶ added in v1.7.0
func (c EdgeConfig) ValidateWithContext(ctx context.Context) error
func (EdgeConfig) WithDefaults ¶ added in v1.7.0
func (c EdgeConfig) WithDefaults() EdgeConfig
WithDefaults returns a copy of c with zero-value fields replaced by the documented defaults (pairing/remote — forwardAuth remains config structure only, see docs/design/webmcp-reverse-gateway.ja.md「拡張と identity の紐づけ」).
type FileFetchConfig ¶ added in v1.3.0
type FileFetchConfig struct {
// AllowLocal allows connecting to private/loopback/link-local IP addresses and
// using the http:// scheme. Intended for local development/testing against a
// local stack (e.g. ministack). Defaults to false.
AllowLocal bool `mapstructure:"allowLocal"`
// AllowedHosts, when non-empty, restricts URL downloads to these hosts only
// (exact match against the URL host, with or without port). Empty means all
// hosts are allowed, subject to the private-IP block unless AllowLocal is true.
AllowedHosts []string `mapstructure:"allowedHosts"`
// MaxSize is the maximum number of bytes accepted for a single file value,
// whether downloaded from a URL or provided as base64/text content.
// 0 (or unset) falls back to DefaultFileFetchMaxSize.
MaxSize int64 `mapstructure:"maxSize"`
}
FileFetchConfig controls how outbound file-fetch requests behave — e.g. when an MCP tool caller passes a URL for a file-input field and manifold downloads it on their behalf. This exists to mitigate SSRF: by default, downloads only allow https:// and refuse to connect to private/loopback/link-local IP addresses.
func (FileFetchConfig) WithDefaults ¶ added in v1.3.0
func (c FileFetchConfig) WithDefaults() FileFetchConfig
WithDefaults returns a copy of c with zero-value fields replaced by defaults.
type Gateway ¶
type Gateway struct {
Port int `mapstructure:"port"`
Key string `mapstructure:"key"`
Cert string `mapstructure:"cert"`
EncryptKey string `mapstructure:"encryptKey"`
Edge EdgeConfig `mapstructure:"edge"`
SpecRefresh SpecRefreshConfig `mapstructure:"specRefresh"`
}
type IdentityProfile ¶ added in v1.8.0
type IdentityProfile struct {
Source IdentitySource `mapstructure:"source"`
// source: jwt. Claim defaults to DefaultIdentityClaim; Audience is optional.
Claim string `mapstructure:"claim"`
Issuer string `mapstructure:"issuer"`
JWKSURL string `mapstructure:"jwksURL"`
Audience string `mapstructure:"audience"`
// source: header
Header string `mapstructure:"header"`
Hash bool `mapstructure:"hash"`
// source: introspection. CacheTTL defaults to DefaultIntrospectionCacheTTL.
URL string `mapstructure:"url"`
CredentialHeader string `mapstructure:"credentialHeader"`
CacheTTL time.Duration `mapstructure:"cacheTTL"`
}
IdentityProfile is a named "how to derive an identityKey from an agent request" rule, referenced by reverse Server.Identity (see the "ユーザー識別 (identity プロファイル)" section of docs/design/webmcp-reverse-gateway.ja.md). Only the fields for the selected Source are set; ValidateWithContext rejects fields belonging to another source as a config mistake.
func (IdentityProfile) CacheTTLOrDefault ¶ added in v1.8.0
func (p IdentityProfile) CacheTTLOrDefault() time.Duration
CacheTTLOrDefault returns CacheTTL, falling back to DefaultIntrospectionCacheTTL when unset (<= 0).
func (IdentityProfile) ClaimOrDefault ¶ added in v1.8.0
func (p IdentityProfile) ClaimOrDefault() string
ClaimOrDefault returns Claim, falling back to DefaultIdentityClaim when unset.
func (IdentityProfile) ValidateWithContext ¶ added in v1.8.0
func (p IdentityProfile) ValidateWithContext(ctx context.Context) error
type IdentitySource ¶ added in v1.8.0
type IdentitySource string
const ( IdentitySourceJWT IdentitySource = "jwt" IdentitySourceHeader IdentitySource = "header" IdentitySourceIntrospection IdentitySource = "introspection" )
type MCPTransport ¶
type MCPTransport string
const ( MCPTransportHTTP MCPTransport = "http" MCPTransportStdio MCPTransport = "stdio" MCPTransportReverse MCPTransport = "reverse" )
type MemoryConfig ¶ added in v1.3.0
type MemoryConfig struct {
// Enabled が true の場合、インメモリストレージを使用する。
Enabled bool `mapstructure:"enabled"`
}
MemoryConfig はインメモリストレージの設定。
type OAuth2 ¶
type PairingConfig ¶ added in v1.7.0
type PairingConfig struct {
Type PairingType `mapstructure:"type"`
}
func (PairingConfig) ValidateWithContext ¶ added in v1.7.0
func (c PairingConfig) ValidateWithContext(ctx context.Context) error
type PairingType ¶ added in v1.7.0
type PairingType string
const ( PairingTypeRemote PairingType = "remote" PairingTypeStatic PairingType = "static" )
type RedisConfig ¶
type RedisConfig struct {
URL string `mapstructure:"url"`
Addrs []string `mapstructure:"addrs"`
User string `mapstructure:"user"`
Password string `mapstructure:"password"`
DB int `mapstructure:"db"`
MasterName string `mapstructure:"master_name"`
TLS bool `mapstructure:"tls"`
ClusterMode bool `mapstructure:"cluster_mode"`
}
type S3 ¶ added in v1.3.0
type SQLiteConfig ¶ added in v1.1.0
type SQLiteConfig struct {
// Path はSQLiteデータベースファイルのパス。
// ":memory:" を指定するとインメモリDBとして動作する。
Path string `mapstructure:"path"`
}
SQLiteConfig はSQLiteストレージの設定。
type Server ¶
type Server struct {
Name string
Description string `mapstructure:"description"`
BaseURL string `mapstructure:"baseURL"`
Spec string `mapstructure:"spec"` // ファイル or http(s)(OpenAPI モード)
ExtraHeaders map[string]string `mapstructure:"headers"`
// nil は gateway.specRefresh.interval を使う、0 はこのサーバーのみリフレッシュ無効。
SpecRefreshInterval *time.Duration `mapstructure:"specRefreshInterval"`
// Tools は静的ツールカタログ(生成物)関連の設定。File が指定されると、
// 起動・リフレッシュで spec を取得せず生成物ファイルからツールを読み込む。
Tools *ToolsConfig `mapstructure:"tools"`
AuthValue *AuthValue `mapstructure:"authValue"`
OAuth2 *OAuth2 `mapstructure:"oauth2"`
TokenExchange *TokenExchange `mapstructure:"tokenExchange"`
// MCP バックエンドモード用(Spec が空のとき有効)
Transport MCPTransport `mapstructure:"transport"`
URL string `mapstructure:"url"` // streamable_http 用
Command string `mapstructure:"command"` // stdio 用
Args []string `mapstructure:"args"`
Env map[string]string `mapstructure:"env"`
// reverse トランスポート用(WebMCP reverse connection gateway)
Origin string `mapstructure:"origin"` // ブリッジ対象タブの許可 origin
Identity string `mapstructure:"identity"` // identities プロファイル名の参照
CallTimeout time.Duration `mapstructure:"callTimeout"` // 未設定/0以下は DefaultCallTimeout
}
func (Server) CallTimeoutOrDefault ¶ added in v1.7.0
CallTimeoutOrDefault returns CallTimeout, falling back to DefaultCallTimeout when unset.
func (Server) EffectiveSpecRefreshInterval ¶ added in v1.10.0
EffectiveSpecRefreshInterval returns the refresh interval for this server, falling back to the gateway-wide default. Only OpenAPI mode servers refresh; others always return 0. A server with tools.file set never refreshes (it starts from the generated file, not the live spec), regardless of the gateway-wide default.
func (Server) GeneratedToolsFile ¶ added in v1.14.0
GeneratedToolsFile returns tools.file, or "" when unset (or Tools itself is unset).
func (*Server) IsMCPBackend ¶
IsMCPBackend はこの Server が MCP バックエンドモードかどうかを返す。 Spec が空で Transport が指定されている場合に MCP バックエンドモードとなる。 reverse は別経路(エッジレジストリ)で扱うため除く。
func (*Server) IsReverseBackend ¶ added in v1.7.0
IsReverseBackend はこの Server が WebMCP reverse connection gateway 経由かどうかを返す。
type SpecRefreshConfig ¶ added in v1.10.0
SpecRefreshConfig is the gateway-wide default for re-fetching OpenAPI mode specs after startup, overridable per server with mcpServers.<name>.specRefreshInterval. Interval 0 (unset) disables refreshing.
func (SpecRefreshConfig) ValidateWithContext ¶ added in v1.10.0
func (c SpecRefreshConfig) ValidateWithContext(ctx context.Context) error
type Storage ¶ added in v1.3.0
type TokenExchange ¶ added in v1.3.0
type TokenExchange struct {
URL string `mapstructure:"url"`
}
func (*TokenExchange) ValidateWithContext ¶ added in v1.3.0
func (c *TokenExchange) ValidateWithContext(ctx context.Context) error
type ToolsConfig ¶ added in v1.14.0
type ToolsConfig struct {
File string `mapstructure:"file"`
}
ToolsConfig groups static tool catalog (生成物) settings under mcpServers.<name>.tools. File is the only field in Phase 1; it is an object (rather than tools.file directly) so overrides (exclude/rename/ description) can be added alongside it later without a breaking change.