mcppolicy

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package mcppolicy owns the shared security policy for remote MCP endpoints.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InputHeaders

func InputHeaders(headers map[string]string, secret func(string) bool) (map[string]string, map[string]string)

InputHeaders separates user credential templates from package-fixed credentials.

func PlaceholderURL

func PlaceholderURL(value string) string

PlaceholderURL validates the fixed URL structure before user input is available.

func ReplaceInputs

func ReplaceInputs(value string, replace func(name, fallback string, optional bool) string) string

ReplaceInputs scans once so supplied values cannot introduce executable template syntax.

func SecretInputName

func SecretInputName(name string) bool

func ValidInputName

func ValidInputName(name string) bool

func ValidateHeaders

func ValidateHeaders(fixed, secret map[string]string, source HeaderSource, authEnabled bool) error

ValidateHeaders enforces header syntax, ownership, and duplicate rules. Fixed headers are always package-authored; source identifies secret headers.

func ValidateRemoteURL

func ValidateRemoteURL(raw string) error

ValidateRemoteURL requires an absolute HTTP(S) endpoint and restricts plain HTTP to the exact localhost name or an IP loopback literal.

Types

type Code

type Code string

Code is a stable machine-readable policy failure reason.

const (
	CodeInvalidHeaderName       Code = "invalid_header_name"
	CodeInvalidHeaderValue      Code = "invalid_header_value"
	CodeDuplicateHeader         Code = "duplicate_header"
	CodeReservedHeader          Code = "reserved_header"
	CodePackageCredential       Code = "package_credential_forbidden"
	CodeOperatorCredential      Code = "operator_credential_forbidden"
	CodeOAuthAuthorizationOwned Code = "oauth_authorization_owned"
	CodeInvalidHeaderSource     Code = "invalid_header_source"
)

type Error

type Error struct {
	Code   Code
	Header string
}

Error describes one deterministic header-policy failure.

func (*Error) Error

func (e *Error) Error() string

Error returns the stable code and normalized header involved in the failure.

type HeaderSource

type HeaderSource int

HeaderSource identifies who supplied a header value.

const (
	SourcePackageFixed HeaderSource = iota
	SourceOperatorSecret
	SourceOAuthOwned
)

Jump to

Keyboard shortcuts

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