Repository navigation
gateway
How a server serves through a gateway that multiplexes several servers on one connection, as
agentgateway does. Such a gateway puts a target prefix in front of every address in the structured
fields it passes through, skill://x becoming kb+skill://x, and refuses a read without it. It
never rewrites text. So the server learns the prefix from the route, takes it off every address a
client sends, and writes it into every address in the text it serves, and a link a model copies
out of a served file reads through the gateway. This area covers the prefix input, the incoming
addresses and the outgoing text.
- A model reads
kb+skill://grafana/loki/SKILL.mdthrough a gateway route, follows a link in its body, and the link iskb+skill://grafana/loki/references/logql.md, which the gateway routes back to the same server. - A folder's
_index.md, a prompt's text, an agent's instructions and the server's instructions all carry the prefix, so nothing a model reads names an address the gateway refuses. - The same server on a direct connection, with no prefix, serves the same text without one, and a client that sends a prefixed address to it, or another server's prefix, finds nothing.
-
skills/list, the_manifestand reads agree on every digest, prefix or not, because the prefixed text is what the build holds. - A server that writes its own text, mcp-kb's instructions, prefixes it with the same rule the plugin layer uses.
GW-1. Rewriters, the build and its key are the plugin layer's (PLUG-55 to
PLUG-59). The other inputs, and how every input resolves, the prefix included, are
delivery's (DLV-2, DLV-3, DLV-16). The resource tools (DLV-6), the instructions
(DLV-11) and the _meta that reports what a request resolved (DLV-12) are delivery's too, and each
takes the prefix as that requirement says. Which route injects which prefix belongs to the
deployment.
GW-2. A request may name its prefix as the header X-MCP-Resource-Prefix, the server's own
<Prefix>-Resource-Prefix (DLV-16), or the query parameter prefix, resolved in DLV-3's order. A
route injects it as a header. Of a repeated one the first value is read, and an empty value is none.
Spaces around a header's value are ignored. A space in the query value reads as +, since a URL's
+ decodes to a space. With none, the request has no prefix. A background task's worker has its
request's headers but not its query, so it reads only a header's prefix.
GW-3. A valid prefix is a letter, then letters, digits, +, - or ., ending in +, at most
64 characters: kb+. An invalid one is ignored as DLV-5 says, and the next source answers: an
invalid header falls to the query parameter, then to no prefix.
GW-4. An address of a scheme the plugins serve (skill://, prompts://,
agents://) in resources/read, skills/get and resources/directory/read is taken before any
provider is asked, in this order, so every provider sees the plain address:
- An address holding an escaped
/,%2For%2f, resolves to nothing, with or without a prefix. No escape is decoded here, and a provider that decoded one would find another address. - The request's own prefix is taken off.
- The address's dot segments are resolved, in its path alone: an empty or
.segment goes, a..takes the segment before it, and a..with none before it resolves to nothing. A trailing/is kept, so it names no folder (SKL-11) and misses as it does without a gateway. A query or fragment is kept as sent.
An address with any other prefix, or a prefixed one on a request with none, is left as sent and
finds nothing. An address that resolves to nothing fails as a missing one does: the same code,
message and data, naming the address the client sent. A read answers with the URI the client
sent, and a folder's hint (SKL-18) names the folder as sent. An address of any other scheme is
passed on untouched. skills/get and resources/directory/read answer with the plain address's
entry or children, whose URIs are structured (GW-8).
GW-5. With a prefix, every address of a scheme the plugins serve (skill://,
prompts://, agents://) in text a client reads is written <prefix><address>, except where the
scheme follows a letter, digit, +, - or ., so kb+skill:// and myskill:// stay as they are.
It is the last rewriter of every build (PLUG-56), so it runs after the server's own and sees their
addresses, and no rewriter of the server's sees its output. It runs over skill files, command and
agent files and folder indexes alike: a folder's _index.md and _index.json are rendered from
the request's build and written as text, the URIs in _index.json included. With no prefix nothing
is written, and a build is what it is without a gateway.
GW-6. The prefix is part of a build's key, beside the generation and the view's key (PLUG-55): each (generation, view key, prefix) is built once, and a request with no prefix reuses no prefixed build. When more builds are kept than PLUG-55 allows, a prefixed build is dropped first, so a client naming prefixes never pushes out a build with none.
GW-7. A plugin prompt's rendered text is written with the prefix after its arguments are filled in, so an address an argument brings is prefixed too, and one already prefixed is not prefixed again. The instructions take the prefix as DLV-11 says, and the resource tools' results as DLV-6 says.
GW-8. A structured address is never prefixed, since the gateway prefixes it itself: a listing
row's uri and name, a template's uriTemplate, a Skills entry's uri and each file uri, a
folder child's uri, and an agent's _meta["io.kubed/agent"] skills. A Skills entry's
frontmatter is text and is prefixed, the same text its SKILL.md holds. A _manifest holds
paths, not addresses, so it is the same with a prefix or without one, apart from the digests and
sizes of the files the prefix changed. Behind agentgateway this waits on its 1.8 release, which
prefixes a Skills entry's uri and each file's uri itself
(#82).
GW-9. The resolved prefix is reported in _meta["io.kubed/delivery"] as DLV-12
says.
GW-10. The server's own resources, tools and prompts, those no plugin serves, are not rewritten. A server whose own text names its own addresses behind a gateway prefixes them itself (GW-11).
GW-11. kubed.mcp.gateway.prefix() returns the current request's prefix, resolved
as GW-2 and GW-3 say, or None, and None outside a request. kubed.mcp.gateway.prefixed(text, prefix) returns text written by GW-5's rule under prefix, and text unchanged when prefix is
None. kubed.mcp.gateway.unprefixed(uri, prefix=None) is its inverse for one address: uri less
prefix when it starts with prefix and a scheme the plugins serve, and uri unchanged otherwise
or when prefix is None. It resolves no dot segment and refuses no %2F, which are GW-4's other
steps, and GW-4 takes the request's prefix off with it. A prefix GW-3 refuses raises ValueError
in either.
These pages describe what is on main; the spec says what is built and what is only proposed.
kubed-mcp · MIT