Skip to main content

What are Resources?

Resources in MCP represent any kind of data that an MCP server wants to make available to clients. This can include:
  • File contents
  • Screenshots and images
  • Log files
  • Database records
  • API responses
  • And more
Each resource is identified by a unique URI and can contain either text or binary data.

Basic Usage

Add a resource to your server using the addResource method:

Resource Properties

URI

The unique identifier for the resource. Use standard URI schemes:

MIME Type

Optional MIME type for the resource:

Return Types

Text Content

Return text data using the text property:

Binary Content

Return binary data using the blob property (base64-encoded):

Multiple Resources

The load function can return an array of resources:
Returning multiple resources is useful for directory listings or collections of related data.

Resource Templates

Resource templates allow you to define dynamic resources with URI parameters:

URI Templates

Use URI templates with placeholders:

Multiple Arguments

Templates can have multiple arguments:

Optional Arguments

Mark arguments as optional:

Argument Auto-completion

Provide auto-completion for resource template arguments:

Completion Response

The complete function returns a completion object:
Example with metadata:

Embedded Resources

The embedded() method simplifies including resources in tool responses:

Basic Example

With Resource Templates

Authentication Context

Resources can access authentication context:

Complete Example

Here’s a complete example combining multiple features:

API Reference

Resource Type

ResourceTemplate Type

ResourceResult Type