---
title: "DF0084: Invalid MCP Resource Template"
description: "MCP resource template \"{name}\" has an invalid `uriTemplate` \"{uriTemplate}\": {reason}"
canonical_url: "https://devfra.me/errors/df0084"
---
# DF0084: Invalid MCP Resource Template

> MCP resource template "\{name}" has an invalid \`uriTemplate\` "\{uriTemplate}": \{reason}

## Message

> MCP resource template "`{name}`" has an invalid `uriTemplate` "`{uriTemplate}`": `{reason}`

## Cause

An entry in the `resourceTemplates` list of the MCP route options (or of `createMcpServer` / `createMcpFetchHandler`) has a `uriTemplate` that goes beyond RFC 6570 level 1. The MCP server supports plain `{name}` expressions only. A name is made of letters, digits, `_` and `.`, and each name appears once. An operator (`{+path}`, `{?q}`, `{/id}`), a modifier (`{path*}`, `{id:3}`), a list of names (`{a,b}`), an empty expression (`{}`), two expressions with nothing between them (`{a}{b}`, where a URI cannot show where one value ends), or a `{` or `}` outside an expression throws this. The check runs once, when the MCP route mounts or `createMcpServer` starts, so no request is served with a broken template.

## Example

```ts
initDevframe(myDevframe, {
  mcp: {
    resourceTemplates: [
      {
        uriTemplate: 'my-tool://file/{+path}', // `+` is a level 2 operator → DF0084
        name: 'file',
        read: ({ path }) => ({
          text: readFileSync(path, 'utf8')
        }),
      }
    ],
  },
})
```

## Fix

Use a plain `{name}` expression for each value. A value matches one URI segment, so a value with a `/` (such as a file path) comes in percent-encoded (`my-tool://file/src%2Fmain.ts`) and reaches `read` decoded (`src/main.ts`):

```ts
const template = {
  uriTemplate: 'my-tool://file/{path}',
  name: 'file',
  read: ({ path }) => ({
    text: readFileSync(path, 'utf8')
  })
}
```

## Source

- [`packages/agentic/src/mcp/build-server.ts`](https://github.com/devframes/devframe/blob/main/packages/agentic/src/mcp/build-server.ts): `compileResourceTemplates()` throws this for a `uriTemplate` beyond RFC 6570 level 1. `createMcpFetchHandler()` (which `mountMcpHttp()` and the MCP route use) and `createMcpServer()` call it once, before they serve any request.


## Sitemap

See the full [sitemap](https://devfra.me/sitemap.md) for all pages.
