context

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetExcludeTools

func GetExcludeTools(ctx context.Context) []string

GetExcludeTools retrieves the excluded tools from the context

func GetGraphQLFeatures

func GetGraphQLFeatures(ctx context.Context) []string

GetGraphQLFeatures retrieves GraphQL feature flags from the context

func GetHeaderFeatures

func GetHeaderFeatures(ctx context.Context) []string

GetHeaderFeatures retrieves the raw feature flags from context

func GetTokenScopes

func GetTokenScopes(ctx context.Context) ([]string, bool)

GetTokenScopes retrieves token scopes from the context

func GetTools

func GetTools(ctx context.Context) []string

GetTools retrieves the tools from the context

func GetToolsets

func GetToolsets(ctx context.Context) []string

GetToolsets retrieves the active toolsets from the context

func IsInsidersMode

func IsInsidersMode(ctx context.Context) bool

IsInsidersMode retrieves the insiders mode state from the context

func IsLockdownMode

func IsLockdownMode(ctx context.Context) bool

IsLockdownMode retrieves the lockdown mode state from the context

func IsReadonly

func IsReadonly(ctx context.Context) bool

IsReadonly retrieves the read-only mode state from the context

func WithExcludeTools

func WithExcludeTools(ctx context.Context, tools []string) context.Context

WithExcludeTools adds the excluded tools to the context

func WithGraphQLFeatures

func WithGraphQLFeatures(ctx context.Context, features ...string) context.Context

withGraphQLFeatures adds GraphQL feature flags to the context

func WithHeaderFeatures

func WithHeaderFeatures(ctx context.Context, features []string) context.Context

WithHeaderFeatures stores the raw feature flags from the X-MCP-Features header into context

func WithInsidersMode

func WithInsidersMode(ctx context.Context, enabled bool) context.Context

WithInsidersMode adds insiders mode state to the context

func WithLockdownMode

func WithLockdownMode(ctx context.Context, enabled bool) context.Context

WithLockdownMode adds lockdown mode state to the context

func WithMCPMethodInfo

func WithMCPMethodInfo(ctx context.Context, info *MCPMethodInfo) context.Context

WithMCPMethodInfo stores the MCPMethodInfo in the context.

func WithReadonly

func WithReadonly(ctx context.Context, enabled bool) context.Context

WithReadonly adds read-only mode state to the context

func WithTokenInfo

func WithTokenInfo(ctx context.Context, tokenInfo *TokenInfo) context.Context

WithTokenInfo adds TokenInfo to the context

func WithTokenScopes

func WithTokenScopes(ctx context.Context, scopes []string) context.Context

WithTokenScopes adds token scopes to the context

func WithTools

func WithTools(ctx context.Context, tools []string) context.Context

WithTools adds the tools to the context

func WithToolsets

func WithToolsets(ctx context.Context, toolsets []string) context.Context

WithToolsets adds the active toolsets to the context

Types

type MCPMethodInfo

type MCPMethodInfo struct {
	// Method is the MCP method being called (e.g., "tools/call", "tools/list", "initialize")
	Method string
	// ItemName is the name of the specific item being accessed (tool name, resource URI, prompt name)
	// Only populated for call/get methods (tools/call, prompts/get, resources/read)
	ItemName string
	// Owner is the repository owner from tool call arguments, if present
	Owner string
	// Repo is the repository name from tool call arguments, if present
	Repo string
	// Arguments contains the raw tool arguments for tools/call requests
	Arguments map[string]any
}

MCPMethodInfo contains pre-parsed MCP method information extracted from the JSON-RPC request. This is populated early in the request lifecycle to enable:

  • Inventory filtering via ForMCPRequest (only register needed tools/resources/prompts)
  • Avoiding duplicate JSON parsing in middlewares (secret-scanning, scope-challenge)
  • Performance optimization for per-request server creation

func MCPMethod

func MCPMethod(ctx context.Context) (*MCPMethodInfo, bool)

MCPMethod retrieves the MCPMethodInfo from the context.

type TokenInfo

type TokenInfo struct {
	Token     string
	TokenType utils.TokenType
}

func GetTokenInfo

func GetTokenInfo(ctx context.Context) (*TokenInfo, bool)

GetTokenInfo retrieves the authentication token from the context

Jump to

Keyboard shortcuts

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