> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mcp-use.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Resources

> Expose readable content with static resources and resource templates.

Resources expose content clients can discover and read by URI. Use a static
resource for one stable URI and a resource template for a family of URIs.

## Register a static resource

A static callback receives the requested `URL` and request context:

```typescript theme={null}
import { MCPServer } from "mcp-use";

const server = new MCPServer({
  name: "inventory-server",
  version: "1.0.0",
});

server.resource(
  {
    name: "inventory-summary",
    uri: "inventory://summary",
    mimeType: "application/json",
  },
  async (uri, ctx) => ({
    contents: [
      {
        uri: uri.href,
        mimeType: "application/json",
        text: JSON.stringify({
          lowStock: await inventory.lowStock({ signal: ctx.signal }),
        }),
      },
    ],
  }),
);

export default server;
```

Return the raw `{ contents: [...] }` resource envelope. Each entry identifies
its own URI and contains either text or a base64 blob with an appropriate MIME
type.

## Register a resource template

A template callback receives `(uri, params, ctx)`. Inferred template values
are `string | string[]` because RFC 6570 expressions can expand one or many
values.

```typescript theme={null}
server.resourceTemplate(
  {
    name: "customer-profile",
    uriTemplate: "customer://{customerId}/profile",
    complete: {
      customerId: async (value) =>
        (await customers.search(value)).map((customer) => customer.id),
    },
  },
  async (uri, { customerId }, ctx) => {
    const id = Array.isArray(customerId) ? customerId[0] : customerId;
    const customer = await customers.get(id, { signal: ctx.signal });

    return {
      contents: [
        {
          uri: uri.href,
          mimeType: "application/json",
          text: JSON.stringify(customer),
        },
      ],
    };
  },
);
```

Completion providers belong in the definition's top-level `complete` map.
Use a string array for fixed suggestions or a callback for live lookup.

## Return several content entries

One resource read may return several entries:

```typescript theme={null}
async (uri) => ({
  contents: [
    {
      uri: uri.href,
      mimeType: "text/markdown",
      text: report.summary,
    },
    {
      uri: `${uri.href}/chart`,
      mimeType: "image/png",
      blob: report.chartBase64,
    },
  ],
});
```

Deprecated response-helper results are accepted as conversion inputs, but raw
resource envelopes are the direct return path and make URIs and MIME types
explicit.

## Notify listeners

Publish a list invalidation when the available resources or templates change:

```typescript theme={null}
await server.notifyResourcesChanged();
```

Publish a URI invalidation when existing content changes:

```typescript theme={null}
await server.notifyResourceUpdated("inventory://summary");
```

Clients with an active subscription listener re-read the authoritative
resource. Delivery is non-durable; see
[Resource Subscriptions](/v2/typescript/server/subscriptions).

## Test resources

Run `mcp-use dev`, then use the built-in inspector to list resources, read
static and templated URIs, exercise autocomplete, and verify successful and
not-found results.
