fix: a build yields to the loop and builds run one at a time, so a cold server keeps answering (#99)
A rewritten build (every prefixed key) was 1-1.5 s of synchronous CPU on
the event loop, made on a new key's first request, usually
server/discover. A reconnect burst over several gateway routes queued
one per route, and /health missed its 1 s timeout behind them.
_make now checkpoints after each skill, command and agent and after
each skill's indexes, and one anyio.Lock per Plugins, taken after the
flight is registered, makes rewritten builds one at a time in the order
asked. An unrewritten build never yields and takes no lock. A build
cancelled at a checkpoint or on the lock leaves no flight and no held
lock.
A rewritten build's skill indexes are listed in one pass per skill
(skills._skill_children) instead of a throwaway EntryOnlySkillProvider
per skill, which reloaded the manifests for every folder; the file-row
decoration is shared with the provider (_served_file), so the indexes
are byte-identical. _Renderer and _Build._renderers are gone.
A build made or waited on is a kubed.mcp.build span (TEL-24) with its
generation, prefix, outcome and counts; a kept build has none. PLUG-55
says builds yield and run in order.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent: done
Agent: done
docs: PLUG-53 and the changelog for an async plugin view (#86)
PLUG-53 says a view may be a coroutine function, awaited in the task
of the read that pins it and never in a worker thread, that a sync
view runs on the loop and must not block, and that a view set while an
async one awaits is called in its place. [Unreleased] gains its Added
line.
The context-variable test now reads the variable from a rewriter while
the read is served, so it asserts both views' value is seen in the
request rather than comparing None with None.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent: done
Agent: done
fix(plugins): a failed pin answers -32603 on both protocols (#90)
The legacy dispatcher answers any exception that isn't an MCPError
with code 0 and the exception's text, so a plugin view or build that
failed reached a legacy client as code 0. _PinScope now raises an
MCPError the pin raised as it is, and anything else as -32603
"Internal server error" from the original, which the scope that
opened the request's pin logs once at error with its traceback.
PLUG-53 states the code, the fixed text and the MCPError opt-in; the
failed-pin tests run in both eras, in-process and over HTTP, and
[Unreleased] gains its Fixed line.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent: done
docs: PLUG-19, PLUG-40 and the changelog for finding skills one level down
Task 3 of the plan for #75, with the whole-branch review's fixes. PLUG-19 says
skills are found as Claude Code finds them and anything else is silently not a
skill; PLUG-40 is withdrawn. PLUG-19, PLUG-16 and the docstrings now say any
skills folder that itself holds a SKILL.md is that one skill, skills/ included,
as the code already does. _read's inner loop no longer rebinds `folder`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent: done
docs: SKL-24 and the changelog for hidden paths in a skill (#72)
SKL-24 says a skill's hidden paths are never served and never drop the
skill; SKL-5, SKL-6, SKL-7 and PLUG-20 follow it, and the changelog says
so under Changed.
The whole-branch review found one gap with FastMCP: rglob skips a folder
it cannot list, and our walk refused the skill there. It now skips that
folder too, pinned against Skill.from_directory, and without_reserved's
docstring reads in order again.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent: done
docs: PLUG-55 and the changelog for listing once per build (#69)
PLUG-55 says a build holds its skills' resources/list rows, made with
it, while whether they are shown, reads, folder children and
skills/list stay per request. The count test now also covers a
rewritten build, the prefix test lists the plain caller after the
prefixed one, and the private import's comment names FastMCP 4.2.
Agent: done
docs: PLUG-53 and the changelog for a view's serve
PLUG-53 now says a set the view serves is the one its request reads,
and [Unreleased] gains the Fixed line. The plugins module docstring no
longer says a request reads the set served when it began, and the
serve-during-a-build test says when its serve lands.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent: done
test(plugins): pin that no served address has a dot segment
A plugin.json or marketplace entry naming commands/../x.md,
commands/sub/../z.md or agents/../b.md gets PLUG-12's note and serves
nothing there, and ./ segments are dropped. No prompts://, agents:// or
folder address a build serves, and no site a rewriter sees, has a . or
.. segment. The test passed without a code change: nothing let a dot
segment through. PLUG-66 says so.
The changelog gains the line for prompts:// and agents:// belonging to
the plugins, and PLUG-3, PLUG-76 and the nesting guard's line now name
both directions it refuses. The material-delivery design records #37
as built: PLUG-75 and PLUG-76.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent: done
feat(plugins): refuse a namespace inside another plugin's skill
A plugin entering a set (add_plugin, staging.add, staging.keep) is
refused when its namespace is, or lies below, a skill a plugin in the
set serves, or when a skill of its holds such a plugin's namespace
(PLUG-76). Keys are compared by whole segments, and a plugin under the
server's own name is checked like any other. The check runs in
PluginSet._carry before the plugin enters, so a refused plugin claims
nothing, and staging.add wraps the reason as keep does.
A set can no longer hold a skill inside another, so the build's
whole-catalogue SkillCatalogProvider check, which failed every request
on such a set, is removed. PLUG-76 is no longer proposed; PLUG-3,
PLUG-18 and PLUG-50 cite it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
feat(skills): read a skill's JSON, YAML and script files as text
A skill's file other than its SKILL.md reads as UTF-8 text when it is
text-like and its bytes are UTF-8, and as a blob of its bytes otherwise
(PLUG-75). Text-like is a fixed table of extensions (.json, .yaml, .toml,
.sh, .ts and the rest), compared in lowercase, or a text media type.
The table gives the same type on every host, where mimetypes guesses .ts
as video/mp2t. The decode is strict, so the digests in _manifest and
skills/list stay those of the bytes served.
The new private module _media owns the rule. EntryOnlySkillProvider
serves each non-entry file as _SkillFile, a SkillFileResource that keeps
every field FastMCP checks, so skills.serve and every plugin build get
it. The build's rewriters use the same text_of, so a rewriter,
to_mcp_form and the gateway prefix reach a skill's JSON and YAML too
(PLUG-58). PLUG-75 is no longer proposed; PLUG-58 and SKL-9 cite it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs(plan): plan #37, skill text files and the nesting guard
Adds PLUG-75 (a skill's text files read as text) and PLUG-76 (no
namespace inside another plugin's skill) to the plugins spec, both
(proposed), and the plan that builds them with #20's two follow-ups.
feat(plugins): reserve prompts:// and agents:// for the plugins
Once a server has a plugin, mcp.resource refuses a resource or template
under prompts:// or agents://, the scheme compared in lowercase. A server
that already has its own resource under either scheme cannot serve its
first plugin: add_plugin, staging.add and mcp.serve refuse it (PLUG-72).
The check reads FastMCP's local store, which is private: if a later
release renames it, the check is skipped with a warning, and a test fails
CI on that bump.
mcp.resource is now a method, with FastMCP's signature and docs (APP-4).
PLUG-72 is no longer proposed. The design records step 4 built, and the
plan records Task 4 as built.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent: done
feat(plugins): answer resources/directory/read from the first plugin, skills or not
The agents extension the first plugin brings now binds resources/
directory/read and asks every provider, so a plugin server that serves
no skill browses its prompts:// and agents:// folders. The first plugin
also adds NameTheIndex when the server has none (PLUG-68).
Whichever of the agents and Skills extensions registers first binds the
method, and the other leaves it out, so it is bound once in every order.
A server's own skills.serve still works before or after its plugins.
skills.serve adds its advertiser and NameTheIndex each only when missing
(SKL-4, SKL-20). PLUG-68 is no longer proposed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
feat(plugins): put each prompt's and agent's registration in its index row
A prompt's row in its folder's _index.json, and in resources/directory/
read, carries io.kubed/prompt. That holds its name, its arguments as
prompts/list gives them, and the invocation keys its served frontmatter
sets (PLUG-69). An agent's row carries what agents/get gives as its
_meta, its name added to io.kubed/agent (PLUG-70). The rows hold those
alone, without FastMCP's own key, and a read of the file carries the same
_meta.
kubed.mcp.prompts exports META_KEY, INVOCATION_KEYS and index_meta.
PLUG-69 and PLUG-70 are no longer proposed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
feat(plugins): serve each prompt and agent file at prompts:// and agents://
A new provider, _Files, serves each file at its address, as markdown, from
the request's build. It is never listed (PLUG-67). A file reads as its
bytes unless a rewriter changed its text. Every folder the files sit in is
a directory resource, the namespace its top. Its children are sorted by
URI, and its _index.md and _index.json are rewritten as a skill folder's
are, so a gateway prefix writes the URIs in them. The resources/
directory/read rows keep the plain URIs (GW-8).
PLUG-66, PLUG-67 and PLUG-71 are no longer proposed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
feat(plugins): give each prompt and agent file its address, claimed as a name is
Each command and agent file now has its prompts:// or agents:// address,
which nothing serves yet. A file under its folder is at its path below it,
and a file the manifest lists from outside the folder is at its path below
the plugin root. A renamed agent is at <name>@<plugin>.md, with @ unquoted.
An address is a claim (PLUG-66). Within a plugin, a later file at a taken
address is skipped whole. Across plugins, a prompt's address refuses the
later plugin, and an agent's skips just that agent, as PLUG-64 skips a
taken <name>@<plugin>, Dr K's ruling on #36. A file at a folder index's
address is skipped. PLUG-18, PLUG-64 and PLUG-66 and the plan say so.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs: plan prompts and agents as unlisted resources (#20)
The plan of record for PLUG-66 to PLUG-72, and the rows reworded with
the calls settled on #20, still proposed until each task builds them.
feat(plugins): name a prompt file x.prompt.md as the prompt x
Copilot's prompt files are x.prompt.md, and VS Code runs one as /x:
.prompt.md is the file type, not part of the name. A command's last
name segment now drops one trailing .prompt, so commands/db/x.prompt.md
is db_x, kit_db_x under kit (PLUG-22, PLUG-62). Nothing else in the
stem changes, x.md beside x.prompt.md clash as any two prompts do, and
the reader's path and the prompt's file URI keep the file name.
PLUG-37 says this one name follows Copilot rather than Claude Code, and
PLUG-62 that prompt files outside commands/ are served by listing them
as manifest commands entries (PLUG-21). The plan gains Task 5.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent: done
feat(plugins): add a server's own agent _meta with mcp.agent_meta
mcp.agent_meta(fn) adds a server's keys to each agent's agents/get
_meta, beside io.kubed/agent: fn(name, plugin) runs once per agent as
its plugin enters a set, after the agent's name is decided, and its
result is stored as its JSON round trip. A returned io.kubed/agent key,
or a result that is not a JSON dict, is dropped with a warning; a raise
leaves just that agent unserved, named in Plugin.skipped, and frees its
name for the set (PLUG-73, PLUG-31, PLUG-33). With no agent_meta, or
one returning None, the objects served are the ones read.
A Plugin a server holds stays the one served when only an agent's meta
changes, so keep() still finds it. _File.meta's default is a
default_factory, which Python 3.11's dataclass requires. PLUG-44 says
the set's skips follow the ones read.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent: done
feat(plugins): serve a clashing agent as name@plugin, with Plugin.agent_files
An agent's served name is decided when its plugin enters a set, from the
plugin as read: one already served there is served as <name>@<plugin>
with a warning, and the plugin is no longer refused. A <name>@<plugin>
already served, or one whose plugin name is not usable, skips just that
agent, named in Plugin.skipped. keep() into a set the earlier owner has
left gives the plain name back, and a rewritten build serves the name
the set gave (PLUG-64, PLUG-65).
Plugin.agent_files holds an AgentFile(name, path, renamed) for each
agent served in its set (PLUG-74). With no clash, entry hands back the
plugin as read, so the objects served are the ones read.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
feat(plugins): read commands through mcp.command_reader
mcp.command_reader(fn) reads the commands of every plugin read from
then on: fn(text, path, name, plugin) returns a FastMCP Prompt to serve,
or the reason the command is skipped. A plugin keeps the reader that
read it, a build reads again only when its rewritten text differs, and
a raise or a wrong result skips that command, never the plugin
(PLUG-62). The default reader, kubed.mcp.prompts.read_command, is
today's parse taking text, so a server that sets none is served as
before.
The gateway prefix wraps any Prompt: _Prefixed renders the wrapped
prompt's own _render, convert_result included, and prefixes each text
message of what it gives (GW-7).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
feat(plugins): prefix prompt and agent names with the namespace's first segment
Under a namespace other than the server's name, a prompt's and an
agent's prefix is now the namespace's first segment and a `_`, so
`greet` under `kit/tools` is `kit_greet`, and two plugins under
`grafana/loki` and `grafana/k6` clash on `grafana_greet` (PLUG-63,
PLUG-17, PLUG-37).
The wiki takes #28's branch first, as Dr K asked: PLUG-50 to PLUG-61
built and the GW rows, with this branch's PLUG-62 to PLUG-74 on top.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs: plan prompt and agent names, and spec PLUG-73 and PLUG-74 (#19)
spec: material delivery, proposed: plugin sets, views, rewriters, prompt and agent resources (PLUG-50 to PLUG-72), delivery (DLV-1 to DLV-14), bundles (BND-1 to BND-12); the design
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs: plugins: Plugin.skipped (PLUG-44)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs: plugins: a marketplace entry merged with plugin.json (PLUG-42, PLUG-43)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs: plugins: one provider of each kind for the whole server (PLUG-41), PLUG-20 reworded
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs: plugins: layout and names built, recursive agents and commands
PLUG-13, 16, 19, 21, 22, 28, 29 and 36 edited in place; PLUG-37 (the
layout table, `:` written `_`), PLUG-38 (the default-folder note),
PLUG-39 (usable built names) and PLUG-40 (nested SKILL.md noted) added.
The design's "Layout and names" is marked built.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs: plugins spec: PLUG-36 unlistable folders, PLUG-18 duplicate warning names both files
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs: plugins: the root namespace withdrawn, an empty namespace is refused
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>