kotlin-sdk/kotlin-sdk-server
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Recoordinate b7047e77cf
fix(server): return INVALID_PARAMS for unknown prompt in prompts/get (#955)
## Problem

`prompts/get` for a name that is not registered responds with JSON-RPC
`-32603` (INTERNAL_ERROR).

`handleGetPrompt` in `Server.kt` throws a bare
`IllegalArgumentException` when the prompt is missing.
`Protocol.respondWithError` maps any non-`McpException` cause to
`INTERNAL_ERROR`, so the client receives `-32603` for what is a
client-side bad parameter.

The sibling handler `handleReadResource` in the same file already throws
a typed `McpException(RESOURCE_NOT_FOUND)` for the equivalent not-found
case, which reaches the client as `-32002`. The two not-found paths are
inconsistent.

In JSON-RPC, `-32603` means the server hit an internal fault. Requesting
a prompt name that does not exist is a client error (an invalid `name`
parameter), so a client cannot tell "the prompt does not exist" apart
from "the server failed" and may retry a request that can never succeed.

## Change

Throw a typed `McpException(INVALID_PARAMS)` from `handleGetPrompt`,
consistent with `handleReadResource`. The message is unchanged.

`AbstractPromptIntegrationTest.testNonExistentPrompt` asserted `-32603`;
it now asserts `INVALID_PARAMS`.

If you would prefer a dedicated error code for this case instead of
`INVALID_PARAMS`, I am glad to adjust.
2026-09-09 19:00:31 +02:00
..
api fix(server): drop inert eventStore from stateless Streamable HTTP (#909) 2026-07-28 15:43:24 +02:00
src fix(server): return INVALID_PARAMS for unknown prompt in prompts/get (#955) 2026-09-09 19:00:31 +02:00
build.gradle.kts refactor: explicit locked detekt config (#729) 2026-04-29 12:31:49 +02:00
detekt-baseline-main.xml refactor: explicit locked detekt config (#729) 2026-04-29 12:31:49 +02:00
Module.md fix!: Migrate Ktor extension functions from Routing to Route (#237) (#531) 2026-02-18 16:43:37 +02:00