---
title: "Directories & layers"
description: "Choose where an MCP server finds its definitions, override single files with ordered directories, and share tools, resources, and prompts via Nuxt layers."
canonical_url: "https://mcp-toolkit.nuxt.dev/1.x/servers/directories-layers"
---
# Directories & layers

> Choose where an MCP server finds its definitions, override single files with ordered directories, and share tools, resources, and prompts via Nuxt layers.

Each server scans one or more directories relative to the `server/` directory of your app and of every Nuxt layer it extends. When the same relative file exists in several places, the first one wins: earlier directories beat later ones, and your app beats its layers. A layer can ship a complete MCP server that an app extends and overrides one file at a time.

## Choose a directory

```ts [nuxt.config.ts]
export default defineNuxtConfig({
  modules: ['@nuxtjs/mcp-toolkit'],
  mcp: { dir: 'assistant' },
})
```

The server scans `server/assistant/{tools,resources,prompts}` for `.ts`, `.js`, `.mts`, and `.mjs` files (ignoring `.d.ts` files). Don't include `server/` in `dir`. Named servers default to `mcp-<key>`.

## Share definitions through a layer

A layer's `server/mcp` directory is scanned the same way as your app's own:

```text [Project structure]
layers/base/
  server/mcp/
    tools/search.ts
    tools/get-page.ts
app/
  server/mcp/
    tools/search.ts      # replaces the layer's search tool
    tools/orders.ts      # adds a tool
```

The server registers `search` (from the app), `get-page` (from the layer), and `orders`. Overriding works by relative path, not by tool name: two different files that declare the same name fail validation.

## Overlay directories

Pass an array of directories ordered from highest to lowest priority:

```ts [nuxt.config.ts]
export default defineNuxtConfig({
  modules: ['@nuxtjs/mcp-toolkit'],
  mcp: { dir: ['mcp-overrides', 'mcp'] },
})
```

`server/mcp-overrides/tools/search.ts` replaces `server/mcp/tools/search.ts`, while every other file in `server/mcp` is still served. Within each directory, your app comes before its extended layers.

The [`index.ts`](https://mcp-toolkit.nuxt.dev/1.x/servers/server-file) and `extensions.ts` files follow the same rule: the first root that contains one provides it.

The following diagram traces how `dir: ['mcp-overrides', 'mcp']` resolves across an app and an extended layer into one merged registry:

<servers-layer-resolution>



</servers-layer-resolution>

## Groups from subdirectories

Subdirectories inside `tools`, `resources`, and `prompts` set the definition's `group`:

```text [Subdirectory groups]
server/mcp/tools/
  billing/refund.ts         # group: 'billing'
  billing/eu/vat.ts         # group: 'billing/eu'
  search.ts                 # no group
```

An explicit `group` property in the definition overrides the subdirectory name. Groups label entries for clients and catalogs; they don't change the definition's name or restrict access.

## Check what was discovered

Every build prints each server's route, scanned directories, and definition counts:

```text [Build output]
[mcp] /mcp serves 3 tools, 1 resource, 1 prompt from server/mcp, with index.ts
```

The report warns when a directory has no definitions or contains a near-miss folder name such as `tool/` instead of `tools/`. In development, new files and directories are picked up without a restart.

At runtime, read the same list from the server's [`definitions`](https://mcp-toolkit.nuxt.dev/1.x/servers/catalogs).

## Next

- [Compose a server by hand](https://mcp-toolkit.nuxt.dev/1.x/servers/composition) with explicit definition lists.
- [Inspect and publish a server's catalog](https://mcp-toolkit.nuxt.dev/1.x/servers/catalogs) at runtime.


## Sitemap

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