---
title: "Static resources & structure"
description: "File-backed resources, naming, and the shape of defineMcpResource."
canonical_url: "https://mcp-toolkit.nuxt.dev/resources/static-and-structure"
---
# Static resources & structure

> File-backed resources, naming, and the shape of defineMcpResource.

## Static Resources

Static resources have a fixed URI that doesn't change.

### Simple File Resources

The easiest way to expose a local file is using the `file` property. This automatically handles the URI generation, MIME type detection, and file reading.

```typescript [server/mcp/resources/readme.ts]
import { defineMcpResource } from '@nuxtjs/mcp-toolkit/server'

export default defineMcpResource({
  name: 'readme',
  description: 'Project README file',
  file: 'README.md', // Relative to project root
})
```

This generates:

- **URI**: `file:///path/to/project/README.md`
- **Handler**: Automatically reads the file content
- **MIME Type**: Automatically detected (e.g., `text/markdown`)

### Custom Static Resources

For more control, you can define the `uri` and `handler` manually:

```typescript [server/mcp/resources/custom-readme.ts]
import { readFile } from 'node:fs/promises'
import { fileURLToPath } from 'node:url'
import { defineMcpResource } from '@nuxtjs/mcp-toolkit/server'

export default defineMcpResource({
  name: 'custom-readme',
  title: 'README',
  description: 'Project README file',
  uri: 'file:///README.md',
  metadata: {
    mimeType: 'text/markdown',
  },
  handler: async (uri: URL) => {
    const filePath = fileURLToPath(uri)
    const content = await readFile(filePath, 'utf-8')
    return {
      contents: [{
        uri: uri.toString(),
        mimeType: 'text/markdown',
        text: content,
      }],
    }
  },
})
```

## Auto-Generated Name and Title

You can omit `name` and `title` - they will be automatically generated from the filename:

```typescript [server/mcp/resources/project-readme.ts]
import { defineMcpResource } from '@nuxtjs/mcp-toolkit/server'

export default defineMcpResource({
  // name and title are auto-generated from filename:
  // name: 'project-readme'
  // title: 'Project Readme'
  file: 'README.md'
})
```

The filename `project-readme.ts` automatically becomes:

- `name`: `project-readme` (kebab-case)
- `title`: `Project Readme` (title case)

You can still provide `name` or `title` explicitly to override the auto-generated values.

## Resource Structure

A resource definition consists of:

<code-group>

```typescript [File Resource]
import { defineMcpResource } from '@nuxtjs/mcp-toolkit/server'

export default defineMcpResource({
  name: 'resource-name',
  file: 'path/to/file.txt', // Local file path
  metadata: { ... }
})
```

```typescript [Custom Resource]
import { defineMcpResource } from '@nuxtjs/mcp-toolkit/server'

export default defineMcpResource({
  name: 'resource-name',  // Unique identifier
  uri: 'uri://...',      // Static URI or ResourceTemplate
  handler: async (uri) => { // Handler function
    return { contents: [...] }
  },
})
```

</code-group>


## Sitemap

See the full [sitemap](https://mcp-toolkit.nuxt.dev/sitemap.md) for all pages.
