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
- Variables
- func Canon(s string) string
- func CanonBytes(b []byte) []byte
- func CanonJSONBody(contentType string, body []byte) []byte
- func Configure(scheme, uriScheme string) error
- func Display(s string) string
- func DisplayBytes(b []byte) []byte
- func HTTP(next http.Handler) http.Handler
- func Middleware(o Options) mcp.Middleware
- func Of(kind, rest string) string
- func Prose(s string) string
- func ProseBytes(b []byte) []byte
- func Rewrites() bool
- func Scheme() string
- func StoredResourceScheme() string
- func Validate(scheme string) error
- type Options
Constants ¶
const ( Prefix = "mcp:" URIPrefix = "mcp://" )
Prefix is the canonical start of a reference, and URIPrefix of a resource URI stored under the default scheme.
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.
const Canonical = "mcp"
Canonical is the scheme every stored reference uses.
Variables ¶
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.
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 ¶
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 CanonJSONBody ¶ added in v1.169.0
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 ¶
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 ¶
Display is a text with every canonical reference written under the deployment's scheme: what the platform hands out.
func HTTP ¶
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 Prose ¶ added in v1.169.0
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
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 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.
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.