Skip to content

SEP-2164 compliance: return ResourceNotFound/InvalidParams error codes for unknown resources and prompts #75

Description

@carldebilly

Problem (2026-07-28 spec compliance, see modelcontextprotocol/csharp-sdk#1539)

SEP-2164 standardizes the resource not found error code, and the SDK 2.0 line exposes McpErrorCode.ResourceNotFound with McpProtocolException(message, code). Repl.Mcp currently throws code-less McpException for unknown lookups, which surfaces as generic InternalError (-32603):

  • McpServerHandler.ReadResourceAsync: throw new McpException($"Unknown resource: {uri}") → should be McpErrorCode.ResourceNotFound (-32002).
  • McpServerHandler.GetPromptAsync: throw new McpException($"Unknown prompt: {promptName}") → should be McpErrorCode.InvalidParams (-32602), the JSON-RPC code for prompts/get with a bad name.

Hosts branch on these codes to distinguish 'gone' from 'broken'.

Ready-made regressions

Two RED tests already exist (parked during PR #71 review to keep that PR scoped): When_ReadingUnknownResource_Then_ResourceNotFoundCodeIsReturned and When_GettingUnknownPrompt_Then_InvalidParamsCodeIsReturned — observed failures: InternalError -32603 in both cases.

Dependency

Requires the SDK 2.0 line (PR #71): McpProtocolException(message, McpErrorCode) does not exist in 1.4.1. Land as a small follow-up PR right after #71 merges.

Related compliance notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions