feat(server): first-class registerResource / registerPrompt + docs - #937
feat(server): first-class registerResource / registerPrompt + docs#937harijoe wants to merge 1 commit into
Conversation
Greptile SummaryThis PR adds first-class resource and prompt registration APIs. The main changes are:
Confidence Score: 4/5The resource registration path needs a guard fix before merging.
packages/core/src/server/server.ts
|
| if (typeof args[0] === "string") { | ||
| return baseFn.call(this, args[0], args[1], args[2], args[3]); |
There was a problem hiding this comment.
When callers use the still-public positional overload, this branch forwards ui://views/ resources directly to the SDK and skips the new guard. A call like registerResource("sneaky", "ui://views/ext-apps/x.html", {}, cb) can register inside the reserved view namespace and collide with Skybridge's internal HTML resources.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/core/src/server/server.ts
Line: 1391-1392
Comment:
**Reserved Namespace Bypass**
When callers use the still-public positional overload, this branch forwards `ui://views/` resources directly to the SDK and skips the new guard. A call like `registerResource("sneaky", "ui://views/ext-apps/x.html", {}, cb)` can register inside the reserved view namespace and collide with Skybridge's internal HTML resources.
How can I resolve this? If you propose a fix, please make it concise.|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
Summary
registerResource/registerPromptconfig-object APIs onMcpServer, consistent withregisterTool(dual-signature: config-object overloads returnthis; SDK positional overloads kept for internal view use).registerResourcesupports staticuriand dynamictemplate(withlist/completecompletions); guard rail throws on the reservedui://views/namespace.registerPromptsupportsargsSchemawithcompletable()argument completions.Docs
build/resources,build/prompts(each with a Completions section and thelist_changedstateless-transport caveat).register-resource,register-prompt; method blurbs added tomcp-server; nav wired indocs.json.Scope
TTools-style type-registry accumulation for resources/prompts (deliberate cut — nothing web-side consumes those types yet).@seelinks repointed from the non-existent/fundamentals/*to/build/*.Tests
register-resource-prompt.test.ts(chaining, e2e read + getPrompt, namespace-guard throw) and.test-d.ts(chainable return type, typed template variables + prompt args). Full core suite green (313), build + lint pass.