kotlin-sdk/kotlin-sdk-server
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Pavel Gorgulov 20e4e44509
Fix: Return CallToolResult with isError for tool errors to conform with MCP spec (#354)
Update server-side tool error handling to return `CallToolResult` with
`isError: true` instead of throwing protocol-level exceptions,
conforming with MCP specification

## Motivation and Context
[The MCP specification
states](https://modelcontextprotocol.io/specification/2025-06-18/schema#calltoolresult):
> Any errors that originate from the tool SHOULD be reported inside the
result object, with isError set to true, not as an MCP protocol-level
error response. Otherwise, the LLM would not be able
  to see that an error occurred and self-correct.

This PR updates the kotlin sdk to match this behavior

## How Has This Been Tested?
All tests pass successfully with the new behavior

## Breaking Changes
None

## Types of changes
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update

## Checklist
- [x] I have read the [MCP
Documentation](https://modelcontextprotocol.io)
- [x] My code follows the repository's style guidelines
- [x] New and existing tests pass locally
- [x] I have added appropriate error handling
- [x] I have added or updated documentation as needed

## Additional context

The TypeScript SDK was recently updated
[#1044](https://github.com/modelcontextprotocol/typescript-sdk/pull/1044)
to conform with the MCP specification regarding tool error handling.
That’s why we got exceptions in the integration tests
2025-10-30 12:19:23 +01:00
..
api Adds 'instructions' string to the Server and propagates to the InitializeResult (#290) 2025-10-03 18:12:37 +02:00
src Fix: Return CallToolResult with isError for tool errors to conform with MCP spec (#354) 2025-10-30 12:19:23 +01:00
build.gradle.kts Refactor WebSocket dependency (#350) 2025-10-28 11:52:07 +01:00
Module.md Add module documentation and enhance Dokka configuration (#261) 2025-09-15 17:44:43 +02:00