Skip to content

Conversation

koic
Copy link
Member

@koic koic commented Oct 2, 2025

Motivation and Context

Follow-up to #147.

According to the specification schema, content is not optional and therefore cannot be omitted:

interface CallToolResult {
  _meta?: { [key: string]: unknown };
  content: ContentBlock[];
  isError?: boolean;
  structuredContent?: { [key: string]: unknown };
  [key: string]: unknown;
}

https://modelcontextprotocol.io/specification/2025-06-18/schema#calltoolresult

Instead of nil, an empty array is set as the default value.

There may be a better value for content, but at the very least it should not be missing.

How Has This Been Tested?

The related test code has been updated.

Breaking Changes

#147 is unreleased, there are no breaking changes on the main branch.

Types of changes

  • 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

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

atesgoral
atesgoral previously approved these changes Oct 2, 2025
error = deprecated_error
end

@content = content
Copy link
Contributor

@juharris juharris Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we instead handle when nil is passed to this method?

Suggested change
@content = content || []

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that makes sense! I've added test code for that case and updated this PR.

Follow-up to modelcontextprotocol#147.

According to the specification schema, `content` is not optional and therefore cannot be omitted:

```typescript
interface CallToolResult {
  _meta?: { [key: string]: unknown };
  content: ContentBlock[];
  isError?: boolean;
  structuredContent?: { [key: string]: unknown };
  [key: string]: unknown;
}
```

https://modelcontextprotocol.io/specification/2025-06-18/schema#calltoolresult

Instead of `nil`, an empty array is set as the default value.

There may be a better value for `content`, but at the very least it should not be missing.
@koic koic force-pushed the set_default_content_to_an_empty_array_instead_of_nil branch from 1f614c2 to 0034952 Compare October 2, 2025 14:54
@koic koic merged commit c5f2f98 into modelcontextprotocol:main Oct 3, 2025
5 checks passed
@koic koic deleted the set_default_content_to_an_empty_array_instead_of_nil branch October 3, 2025 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants