modelcontextprotocol/servers · error · Error

Invalid resourceType: ${args?.resourceType}. Must be ${RESOU

Error message

Invalid resourceType: ${args?.resourceType}. Must be ${RESOURCE_TYPE_TEXT} or ${RESOURCE_TYPE_BLOB}.

What it means

Thrown by the `resource-prompt` handler in the Everything server when the `resourceType` prompt argument is not one of the two supported literals (`"Text"` or `"Blob"`). Prompt arguments arrive as strings (the MCP PromptArgument spec has no type field), so the server must validate the value manually before using it to build a resource URI. The check uses RESOURCE_TYPES.includes() against the runtime value.

Source

Thrown at src/everything/prompts/resource.ts:46

  };

  // Register the prompt
  server.registerPrompt(
    "resource-prompt",
    {
      title: "Resource Prompt",
      description: "A prompt that includes an embedded resource reference",
      argsSchema: promptArgsSchema,
    },
    (args) => {
      // Validate resource type argument
      const resourceType = args.resourceType;
      if (
        !RESOURCE_TYPES.includes(
          resourceType as typeof RESOURCE_TYPE_TEXT | typeof RESOURCE_TYPE_BLOB
        )
      ) {
        throw new Error(
          `Invalid resourceType: ${args?.resourceType}. Must be ${RESOURCE_TYPE_TEXT} or ${RESOURCE_TYPE_BLOB}.`
        );
      }

      // Validate resourceId argument
      const resourceId = Number(args?.resourceId);
      if (
        !Number.isFinite(resourceId) ||
        !Number.isInteger(resourceId) ||
        resourceId < 1
      ) {
        throw new Error(
          `Invalid resourceId: ${args?.resourceId}. Must be a finite positive integer.`
        );
      }

      // Get resource based on the resource type
      const uri =

View on GitHub (pinned to 76d64c822f)

Solutions

  1. Pass `resourceType` as exactly `"Text"` or `"Blob"` (capitalized) to the resource-prompt call.
  2. If driving the call programmatically, source the value from the exported RESOURCE_TYPES constant rather than hardcoding.
  3. Use the completion endpoint to discover accepted values before constructing the request.

Example fix

// before
server.getPrompt('resource-prompt', { resourceType: 'text', resourceId: '1' });
// after
server.getPrompt('resource-prompt', { resourceType: 'Text', resourceId: '1' });
Defensive patterns

Strategy: validation

Validate before calling

import { RESOURCE_TYPES } from '../resources/templates.js';
function isValidResourceType(v: unknown): boolean {
  return typeof v === 'string' && RESOURCE_TYPES.includes(v);
}
// before calling the prompt:
if (!isValidResourceType(args.resourceType)) {
  args.resourceType = 'Text'; // or surface a user-facing error
}

Type guard

function isResourceType(v: unknown): v is 'Text' | 'Blob' {
  return v === 'Text' || v === 'Blob';
}

Prevention

When it happens

Trigger: Calling the `resource-prompt` prompt with a `resourceType` argument that is neither `"Text"` nor `"Blob"` — e.g. `"text"` (lowercase), `"file"`, `undefined`, or an empty string. The completer suggests valid values but does not enforce them, so a raw prompt/get call bypassing completion can pass anything.

Common situations: Clients that lowercase the enum, LLMs paraphrasing the type, passing the literal string `resourceType` instead of its value, or omitting the argument entirely when no default exists (unlike the tool variant, the prompt schema has no default).

Related errors


AI-assisted analysis of modelcontextprotocol/servers@76d64c822f (2026-08-12). Data as JSON: /api/errors/31e32fbfb653fff6. Report an issue: GitHub.