proxy

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 23 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 proxy turns validated tool arguments into an HTTP request and the upstream response into a tool result (SPEC §3.7 steps 5-8).

Every argument is routed by the location the spec declares, under its upstream name; nothing is guessed. The host always comes from the pinned base URL. Path values are percent-encoded and may not be empty, ".", ".." or contain a slash (even percent-encoded); header values may not contain CR, LF or other control characters. Credentials are attached last, only for the pinned origin, and replace anything with the same name.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadArgument = errors.New("bad argument")
	ErrBuild       = errors.New("cannot build request")
)

Sentinel errors callers can match with errors.Is.

Functions

func Build

func Build(ctx context.Context, t model.Tool, args map[string]any, tg Target) (*http.Request, error)

Build creates the request for one call. args are decoded arguments (see schema.DecodeArgs) and should already have passed schema validation; Build re-checks everything it relies on.

Types

type Auth

type Auth struct {
	Type         AuthType
	Header       string
	Param        string
	Secret       string
	Token        func(context.Context) (string, error)
	Unauthorized func()
}

Auth is a resolved credential.

type AuthType

type AuthType string

AuthType is how the credential is attached.

const (
	AuthNone   AuthType = "none"
	AuthBearer AuthType = "bearer"
	AuthHeader AuthType = "header"
	AuthQuery  AuthType = "query"
	AuthBasic  AuthType = "basic"
)

Auth types (SPEC §3.6).

type Fixed

type Fixed struct {
	Name   string
	In     model.Location
	Value  string
	Secret bool
}

Fixed is a resolved fixed parameter. If the tool declares a parameter with this name, the spec's location wins; otherwise In is used (query when unset).

type Result

type Result struct {
	Text      string
	IsError   bool
	Status    int
	Bytes     int
	Truncated bool
}

Result is a tool result, ready for MCP. Text is always redacted.

func Call

func Call(ctx context.Context, doer httpx.Doer, t model.Tool, args map[string]any, tg Target, red *redact.Redactor, pick *jsonpick.Picker) Result

Call builds the request, sends it and shapes the response (SPEC §3.7 steps 5-8). It never returns a Go error: every failure is an isError result whose text starts with the tool name. All text passes through red, so no resolved secret reaches the model, successful responses included.

pick, when not nil, keeps only the tool's response_fields of a complete JSON success response (SPEC M6 design note: response field filtering).

type Target

type Target struct {
	BaseURL   *url.URL
	Auth      Auth
	Fixed     []Fixed
	UserAgent string
	Extra     []string
}

Target is everything about the upstream that isn't per call.

func (Target) SecretValues

func (tg Target) SecretValues() []string

SecretValues lists every value that must be redacted wherever it appears (SPEC T11): the credential, the password part of a Basic credential on its own (an upstream may echo just that), and secret fixed values. literal: fixed values are not secrets.

Jump to

Keyboard shortcuts

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