registerResource adds a resource to your server: addressable content a host can read by URI, such as reference docs, a data file, or a live-generated report. Pass a uri for a fixed resource or a template for a family of URIs.
Example
A static Markdown document at a fixed URI.server.ts
Signature
registerTool and registerPrompt.
Config
Provide eitheruri (static) or template (dynamic), never both. The remaining fields are the resource’s metadata.
name
Identifier for the resource, unique per server.
uri
The fixed URI a static resource is read from, e.g. docs://pricing. The handler receives this back as a URL.
template
A ResourceTemplate for a family of URIs, described by an RFC 6570 URI template. Use it when the URI carries a variable, such as a record id.
list callback is required (pass undefined to opt out) so a resource family is never accidentally unlistable. See Completions.
mimeType, title, description, _meta
mimeType labels the content (text/markdown, application/json, …). title and description are the discovery surface a host shows. _meta carries free-form metadata, forwarded untouched.
Handler
Runs when the resource is read. A static resource’s handler receives the requesteduri; a template’s also receives the resolved template variables.
text for text resources or blob (base64) for binary. Set each entry’s uri to uri.href so the response echoes the URI that was requested.
Register Resources
The guide, with completions
registerPrompt
Ship reusable prompts
McpServer
The server you register on