server.ts
registerResource returns the server, so it chains next to your tool registrations. The handler runs when the host reads the URI and returns the content: text for text, blob (base64) for binary.
Register resources up front, at startup. Adding or removing them at runtime relies on
list_changed notifications, which the stateless JSON transport can’t deliver, so hosts won’t see the change.Static vs. dynamic
A static resource lives at one fixeduri. A dynamic resource uses a template, an RFC 6570 URI template, to cover a family of URIs that share a shape:
server.ts
variables as its second argument.
Completions
A dynamic resource can help the host discover and complete its URIs. TheResourceTemplate constructor takes two callbacks:
server.ts
list is required: pass undefined to opt out, so a template is never accidentally unlistable. complete is optional, one callback per template variable, returning the candidate values for what the user has typed so far.
Go Further
registerResource
Full config and handler reference
Register Prompts
Ship reusable prompts
Register Tools
The action primitive