Skip to content

fix: model content annotations as nested objects #242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

LucaButBoring
Copy link
Contributor

@LucaButBoring LucaButBoring commented May 16, 2025

Updates all Content types to represent annotations as nested objects instead of directly on the content itself. The existing ctors have been moved to deprecated shim ctors for backwards-compat.

This brings the implementation in line with the content types as modeled by the specification. An integration test has been added to ensure this doesn't drift in the future.

Motivation and Context

Content annotations have been incorrect for at least six months. The integration test added in this PR fails without the related schema changes.

How Has This Been Tested?

Newly-implemented integration test, leveraging the appropriate tool from everything.

Breaking Changes

None; the old constructor has been maintained for backwards-compatibility purposes. The old auto-generated record properties (.audience() and .priority()) have also been maintained.

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

Additional context

Updates all Content types to represent annotations as nested objects
instead of directly on the content itself. The existing ctors have
been moved to deprecated shim ctors for backwards-compat.

This brings the implementation in line with the content types as
modeled by the specification. An integration test has been added
to ensure this doesn't drift in the future.

https://github.com/modelcontextprotocol/modelcontextprotocol/blob/c87a0da6d8c2436d56a6398023c80b0562224454/schema/2025-03-26/schema.json#L1970-L1973
@LucaButBoring LucaButBoring mentioned this pull request May 16, 2025
9 tasks
Copy link
Contributor

@tzolov tzolov left a comment

Choose a reason for hiding this comment

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

Thank you @LucaButBoring ! An important alignment of the schema to comply with the spec!
I've left few recommendations to improve the formatting and the test coverage.

@tzolov tzolov self-assigned this Jun 15, 2025
@tzolov tzolov added this to the 0.11.0 milestone Jun 15, 2025
@tzolov tzolov added waiting for user Waiting for user feedback or more details labels Jun 16, 2025
- Moves annotation test from stdio suite to abstract suite
- Adds async version of sync annotation test
- Fixes wildcard import
… into fix/content-annotations

# Conflicts:
#	mcp-test/src/main/java/io/modelcontextprotocol/client/AbstractMcpAsyncClientTests.java
#	mcp-test/src/main/java/io/modelcontextprotocol/client/AbstractMcpSyncClientTests.java
#	mcp/src/test/java/io/modelcontextprotocol/client/AbstractMcpAsyncClientTests.java
#	mcp/src/test/java/io/modelcontextprotocol/client/AbstractMcpSyncClientTests.java
@LucaButBoring
Copy link
Contributor Author

LucaButBoring commented Jun 16, 2025

Is it possible to rerun workflows? The failing test here appears to be unrelated to the modified code (and appears to be flaky, based on local runs):

StdioMcpAsyncClientTests.testListToolsWithoutInitialization expectation "expectNextCount(1)" failed (expected: count = 1; actual: counted = 0; signal: onError(io.modelcontextprotocol.spec.McpError: Client failed to initialize listing tools))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MCP Schema waiting for user Waiting for user feedback or more details
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants