refscheme

package
v1.169.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 17 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 refscheme is the one reader and writer of the scheme platform references start with (#2776): mcp:asset:<id>, mcp:dataset:(...), and every other kind. A deployment names its scheme once (server.reference_scheme); every reference the platform hands out is written under it, every reference it reads is accepted under it and under mcp:, and everything stored keeps the canonical mcp: form, so changing the setting changes only what is written out. With no setting the scheme is mcp and nothing is rewritten.

Index

Constants

View Source
const (
	Prefix    = "mcp:"
	URIPrefix = "mcp://"
)

Prefix is the canonical start of a reference, and URIPrefix of a resource URI stored under the default scheme.

View Source
const (
	Asset         = "mcp:asset:"
	Prompt        = "mcp:prompt:"
	Collection    = "mcp:collection:"
	KnowledgePage = "mcp:knowledge_page:"
	Connection    = "mcp:connection:"
	Insight       = "mcp:insight:"
	Resource      = "mcp:resource:"
	Memory        = "mcp:memory:"
	Script        = "mcp:script:"
	Call          = "mcp:call:"
	Session       = "mcp:session:"
	Form          = "mcp:form:"
	Endpoint      = "mcp:endpoint:"
	Site          = "mcp:site:"
	Tag           = "mcp:tag:"
)

The canonical start of each kind of reference, written out whole so a search of the source for one finds where it is made.

View Source
const Canonical = "mcp"

Canonical is the scheme every stored reference uses.

Variables

View Source
var Kinds = []string{
	"asset", "prompt", "collection", "knowledge_page", "connection", "insight", "resource", "memory", "script", "call", "session",
	"dataset", "column", "glossary_term", "glossary_node", "tag", "domain", "data_product", "schema_document",
	"form", "endpoint", "site", "catalog",
}

Kinds are every kind a reference names.

View Source
var Prefixes = []string{apiPrefix, "/endpoints/", "/environments/"}

Prefixes are the paths the HTTP boundary rewrites: the JSON API, and the endpoints a managed script answers (/endpoints/<name>, and an environment's /environments/<env>/endpoints/<name>), whose responses leave for a person and whose requests carry back references a response gave out (#2788): a form that sent a reference it was handed was refused by a script that validates the canonical form.

Functions

func Canon

func Canon(s string) string

Canon is a text with every reference under the deployment's scheme written in the canonical form: what the platform reads, before it stores or compares it.

func CanonBytes

func CanonBytes(b []byte) []byte

CanonBytes is Canon over bytes.

func CanonJSONBody added in v1.169.0

func CanonJSONBody(contentType string, body []byte) []byte

CanonJSONBody is a request body with its references canonical when its content type is JSON and a scheme is set, and the body as it is otherwise. An endpoint calls it on the body its binding's limit admitted (#2788).

func Configure

func Configure(scheme, uriScheme string) error

Configure sets the scheme references are written under; "" is mcp. uriScheme is resources.managed.uri_scheme: with none set, resource URIs are stored as mcp:// and written out as <scheme>:// too.

func Display

func Display(s string) string

Display is a text with every canonical reference written under the deployment's scheme: what the platform hands out.

func DisplayBytes

func DisplayBytes(b []byte) []byte

DisplayBytes is Display over bytes.

func HTTP

func HTTP(next http.Handler) http.Handler

HTTP is the HTTP boundary of the scheme for the JSON API (#2776) and the endpoints (#2788): a reference under the deployment's scheme in a request's path, query or JSON body reaches the handler canonical, and every reference in a JSON answer leaves under the deployment's scheme. Any other answer (a file, a stream, a page) is sent as it is. With no scheme set it is the handler itself.

func Middleware

func Middleware(o Options) mcp.Middleware

Middleware is the MCP boundary of the scheme: every reference a request carries under the deployment's scheme reaches the platform in the canonical form, and every reference a result carries leaves under the deployment's scheme: tool results, tool descriptions and schemas, prompts, resources and the server's instructions. The platform's own wording about the reference form is rewritten too (Prose, #2818) wherever the text is the platform's: tools/list, the server's instructions, a refusal, and the result of each tool named in PlatformText. A script's session reads results canonical, and the fields Verbatim names pass both ways untouched (#2788). With no scheme set it passes everything through untouched.

func Of

func Of(kind, rest string) string

Of is the canonical reference of a kind and the rest of it.

func Prose added in v1.169.0

func Prose(s string) string

Prose is Display for text the platform writes about references (#2818): tool descriptions and schemas, instructions and refusals. Besides every whole reference it rewrites the generic forms, mcp:<type>:<key>, "an mcp:dataset reference" and "an mcp: reference", so what the platform teaches is the form the deployment shows.

func ProseBytes added in v1.169.0

func ProseBytes(b []byte) []byte

ProseBytes is Prose over bytes.

func Rewrites

func Rewrites() bool

Rewrites reports whether references are written under a scheme other than mcp, so that anything is rewritten at all.

func Scheme

func Scheme() string

Scheme is the scheme references are written under.

func StoredResourceScheme

func StoredResourceScheme() string

StoredResourceScheme is the scheme resource URIs are stored under: resources.managed.uri_scheme, or mcp. A body is read for this one and mcp:// both.

func Validate

func Validate(scheme string) error

Validate refuses a scheme a deployment may not use, naming the key.

Types

type Options added in v1.169.0

type Options struct {
	// PlatformText names the tools whose whole result is the platform's own
	// text (platform_info), rewritten with Prose (#2818).
	PlatformText []string
	// Canonical reports a session that receives results in the canonical
	// form: a managed script's (#2788). A script is stored code written
	// against the mcp: form, so a result under the deployment's scheme broke
	// every comparison with a literal mcp: prefix the moment an operator set
	// the key. Its requests are still made canonical.
	Canonical func(context.Context) bool
	// Verbatim names, per tool, the argument and result fields that hold code
	// and are neither canonicalized nor displayed (#2788): a script's source
	// is a tool argument, and rewriting it stored s.replace("acme://", ...)
	// as s.replace("mcp://", ...).
	Verbatim map[string][]string
}

Options is what the MCP boundary needs to know about the platform.

Jump to

Keyboard shortcuts

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