feat(prompts): parameterized workflow prompts + server instructions + project prompt files#46
Open
dehuaichendragonplus wants to merge 1 commit into
Open
Conversation
…roject prompt files
Turn MCP prompts from canned one-liners into real parameterized workflows, add
server-level usage instructions, and let projects register their own prompts
without forking.
- Built-in prompts (edit_prefab_safely, verify_compilation, enter_play_and_recover,
wire_serialized_references, create_playable_prototype) now declare real arguments
(required ones enforced) and expand in prompts/get into an ordered sequence of
actual tool calls with the caller's arguments interpolated, plus a Guidance
section. Prompts acting on live state embed the relevant read-only resource
inline (compile errors / selection / active scene), best-effort.
- initialize now returns server-level `instructions` (cross-client conventions:
structured {success,...} envelopes, no hand-editing serialized assets, the
request_recompile/Play Mode/domain-reload sequence, instanceId reuse, etc.).
- Projects can drop mcp-prompts/*.md files (front-matter name/description/arguments
+ {arg} body template) to register their own workflow prompts; reserved built-in
names cannot be shadowed; malformed files are skipped with a logged warning.
Declarative PromptSpec table is the single source of truth for names, arguments,
and embedded resource. Adds 22 EditMode tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The built-in MCP prompts were canned one-liners: all declared zero
arguments, andprompts/getignored its input and returned a singlerole:usermessage that just restated the prompt's own description — no real tool names, no parameters, no guidance. They were effectively undiscoverable workflow stubs.Two more gaps:
What changed
1. Built-in prompts → parameterized workflow templates.
edit_prefab_safely,verify_compilation,enter_play_and_recover,wire_serialized_references,create_playable_prototypeeach now declare realarguments, andprompts/getexpands into an ordered sequence of actual tool calls with the caller's arguments interpolated, plus a Guidance section on that workflow's pitfalls. Declared-required arguments are enforced (a missing one returns a clear message instead of a body full of unfilled placeholders). A single declarativePromptSpectable is the source of truth for names, arguments, and the embedded resource.2. Live resource embedding. Prompts that act on current state embed the relevant read-only resource inline in
prompts/get—verify_compilation→unity://errors/compilation,wire_serialized_references→unity://selection/current,create_playable_prototype→unity://scene/active— so the model sees that state without a separate fetch. Best-effort: silently skipped if the resource provider is unavailable or the read fails.3. Server-level
instructions. Theinitializeresult now returns aninstructionsstring with the cross-cutting conventions a client needs (structured{success,…}envelopes and branching oncode; never hand-editing serialized assets; therequest_recompile/ Play Mode /get_reload_recovery_statussequence;instanceIdreuse viafind_method=by_id;group_duplicateslogs; small-payload screenshots). This reaches every MCP client, not just Claude Code.4. Project-authored prompts. A project can drop
mcp-prompts/*.mdfiles in its root to register its own workflow prompts — no fork, no C#. Format: a---front-matter fence (name,description,arguments: a(required), b) + a body template referencing{arg}placeholders. They appear inprompts/listalongside the built-ins and interpolate arguments inprompts/get. Reserved built-in names cannot be shadowed; malformed files are skipped with a logged warning (not fatal). Parsing is dependency-free (no YAML library).Benefits
instructionsfix "conventions only Claude Code knows": every client gets them at handshake.Compatibility
MCPPromptProvider's new constructor parameter is optional (resourceProvider = null), so existing construction still compiles;initializegains one field; no tool signatures change.fix_compile_errors→verify_compilation,runtime_validation→enter_play_and_recover,auto_wire_references→wire_serialized_references, plus newedit_prefab_safely). Prompts are user-selected, not a hard API; README updated. Flagging it since it is a visible rename.instructionsis part of theinitializeresult in protocol2024-11-05(the version this server declares), so no protocol-version bump is needed.Dependency / sequencing
The
edit_prefab_safelyprompt and one line ofinstructionsreferenceset_prefab_property, the stage-free prefab-edit tool proposed in #45 (fix(prefab): edit prefab assets without prefab-stage save corruption). This PR is text-only with respect to that tool — it compiles, and all tests pass, on the currentmainwithout #45 — but the guidance names a tool that only exists once #45 lands. Recommended merge order: land #45 first, then this PR; or merge this one knowing theedit_prefab_safelysingle-field path references a not-yet-present tool until #45 merges. Nothing else in this PR depends on #45.Testing & verification
6000.3.13f1editor via the MCP tools:prompts/listreturns the reworked built-ins with their arguments;prompts/getinterpolates arguments into the real tool sequences; a projectmcp-prompts/*.mdfile is picked up and interpolated; reserved built-in names are not shadowable.MCPServerInstructionsTests,MCPPromptProviderTests,ProjectPromptLoaderTests: instructions content, prompt argument declarations + interpolation + required-arg enforcement, live-resource embedding, front-matter parsing (valid / missing name / missing fence / arg spec), folder scan + malformed-skip, provider merge, and the built-in-name-cannot-be-shadowed guard. All pass; no regressions in the rest of the EditMode suite.Changelog
Added under
## Unreleased.