mcptester

package
v0.28.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package mcptester contains the provider-neutral contracts and adapters used by the stateless MCP tester chat endpoint.

Index

Constants

View Source
const (
	ModelProxyModel        = "gpt-6-luna"
	ModelProxyMaxBodyBytes = 2 << 20
	ModelProxyTimeout      = 10 * time.Minute
)
View Source
const (
	ModelProxyUsageTimeout = 5 * time.Second
)

Variables

This section is empty.

Functions

func BuildModelProxyRequest

func BuildModelProxyRequest(request types.MCPTesterChatRequest, instruction string) ([]byte, error)

func BuildModelRequest

func BuildModelRequest(request types.MCPTesterChatRequest, model ResolvedModel, systemInstruction string) ([]byte, error)

BuildModelRequest validates the public request and converts it into the resolved model's native request dialect. The model and system instruction are server-owned and cannot be supplied by the browser.

func IsModelResolutionError

func IsModelResolutionError(err error, kind ModelResolutionErrorKind) bool

func NewLLMProxyRequest

func NewLLMProxyRequest(ctx context.Context, serverURL string, model ResolvedModel, body []byte, inbound http.Header) (*http.Request, error)

NewLLMProxyRequest builds the request the tester handler will send through Obot's existing LLM gateway. Reusing the browser request's authentication headers makes the gateway reconstruct the same user principal, so model access policies, message policies, usage metering, and audit identity remain on the established proxy path. serverURL must be Obot's own listener rather than its public hostname, which may be unreachable from inside Obot's host. The supplied context propagates cancellation.

func NewModelProxyHTTPClient

func NewModelProxyHTTPClient() *http.Client

func NewModelProxyRequest

func NewModelProxyRequest(ctx context.Context, endpoint *url.URL, body []byte, licenseKey, fingerprint string, inbound http.Header) (*http.Request, error)

NewModelProxyRequest forwards only the inbound IP headers. The installation license and machine fingerprint authenticate the request.

func NewModelProxyUsageHTTPClient

func NewModelProxyUsageHTTPClient() *http.Client

func NewModelProxyUsageRequest

func NewModelProxyUsageRequest(ctx context.Context, responsesURL *url.URL, licenseKey, fingerprint string, inbound http.Header) (*http.Request, error)

NewModelProxyUsageRequest derives the sibling endpoint from the validated Responses URL without losing a deployment prefix or its escaped path.

func NormalizeStream

func NormalizeStream(ctx context.Context, dialect llmtypes.Dialect, tools []types.MCPTesterTool, input io.Reader, emit EventEmitter) error

NormalizeStream converts provider SSE into the MCP tester event contract. Provider event names and partial argument encoding never cross this boundary.

func ParseModelProxyURL

func ParseModelProxyURL(value string, development bool) (*url.URL, error)

ParseModelProxyURL validates local configuration without contacting the proxy. An empty value disables model proxy; callers supply the default only when unset.

func ReadModelProxyUsage

func ReadModelProxyUsage(response *http.Response) (types.ModelProxyUsage, error)

func ValidateChatRequest

func ValidateChatRequest(request types.MCPTesterChatRequest) error

Types

type EventEmitter

type EventEmitter func(types.MCPTesterStreamEvent) error

type LicenseSource

type LicenseSource interface {
	LicenseKey(context.Context) (string, error)
	MachineFingerprint() string
}

type ModelAccessResolver

type ModelAccessResolver interface {
	UserHasAccessToModel(kuser.Info, string) (bool, error)
}

type ModelProxyAvailability

type ModelProxyAvailability struct {
	HasModelProvider *bool
	Enabled          bool
}

ModelProxyAvailability distinguishes confirmed provider absence from an unknown configuration. Only confirmed absence can permit the external model service.

func ResolveModelProxyAvailability

func ResolveModelProxyAvailability(ctx context.Context, endpoint *url.URL, providers ProviderConfigurationResolver, settings ModelProxySettingsReader) (ModelProxyAvailability, error)

type ModelProxySettingsReader

type ModelProxySettingsReader interface {
	ModelProxyEnabled(context.Context) (bool, error)
}

type ModelProxyUsageError

type ModelProxyUsageError struct {
	Status     int
	Message    string
	RetryAfter string
}

ModelProxyUsageError contains only local messages, never upstream bodies or URLs.

func (*ModelProxyUsageError) Error

func (e *ModelProxyUsageError) Error() string

type ModelResolutionError

type ModelResolutionError struct {
	Kind ModelResolutionErrorKind
	Err  error
}

func (*ModelResolutionError) Error

func (e *ModelResolutionError) Error() string

func (*ModelResolutionError) Unwrap

func (e *ModelResolutionError) Unwrap() error

type ModelResolutionErrorKind

type ModelResolutionErrorKind string
const (
	ModelResolutionErrorMissing      ModelResolutionErrorKind = "missing"
	ModelResolutionErrorInactive     ModelResolutionErrorKind = "inactive"
	ModelResolutionErrorInaccessible ModelResolutionErrorKind = "inaccessible"
	ModelResolutionErrorInvalid      ModelResolutionErrorKind = "invalid"
)

type ProviderConfigurationResolver

type ProviderConfigurationResolver interface {
	HasModelProvider(context.Context) (bool, error)
}

type ResolvedModel

type ResolvedModel struct {
	ID        string
	Target    string
	Provider  string
	Dialect   llmtypes.Dialect
	ProxyPath string
	APIPath   string
}

func ResolveDefaultModel

func ResolveDefaultModel(ctx context.Context, client kclient.Client, helper ModelAccessResolver, user kuser.Info) (ResolvedModel, error)

ResolveDefaultModel resolves only the configured llm alias. It intentionally has no modelProxy: a missing, unbound, inactive, non-LLM, inaccessible, or unsupported model makes tester Chat unavailable while leaving MCP inspection unaffected.

Jump to

Keyboard shortcuts

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