Skip to content

Conversation

koic
Copy link
Member

@koic koic commented Jul 23, 2025

Motivation and Context

The response of the init method can include instructions. https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle

instructions appear to be supported starting from the 2025-03-26 specification.

If instructions is used with an unsupported protocol version, an ArgumentError will be raised.

How Has This Been Tested?

Existing tests have been updated and new tests have been added.

Breaking Changes

None.

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

As additional context, the TypeScript SDK also treats instructions as optional. https://github.com/modelcontextprotocol/typescript-sdk/blob/1.16.0/src/types.ts#L356-L361

if @configuration.protocol_version == "2024-11-05" && @instructions
message = "`instructions` supported by protocol version 2025-03-26 or higher"
raise ArgumentError, message
end
Copy link
Member Author

Choose a reason for hiding this comment

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

If accepting the instructions parameter with the older "2024-11-05" protocol version is considered preferable, this logic could be removed as it only introduces unnecessary complexity.

Copy link
Contributor

@atesgoral atesgoral Aug 3, 2025

Choose a reason for hiding this comment

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

In case there are picky clients that could error on unexpected properties, I think being safe (backwards compatible) is good here.

But are we doing this kind of check uniformly for all features? Is there a Ruby-friendly annotation technique we could adopt to start doing this more declaratively...

I'm happy with this change as it is, though.

Copy link
Member Author

Choose a reason for hiding this comment

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

At some point, it would be ideal to enable declarative descriptions using a DSL instead of procedural ones.

The response of the `init` method can include `instructions`.
https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle

`instructions` appear to be supported starting from the 2025-03-26 specification.

- https://modelcontextprotocol.io/specification/2025-03-26/basic/lifecycle (supports `instructions`)
- https://modelcontextprotocol.io/specification/2024-11-05/basic/lifecycle (does not support `instructions`)

If `instructions` is used with an unsupported protocol version, an `ArgumentError` will be raised.

As additional context, the TypeScript SDK also treats `instructions` as optional.
https://github.com/modelcontextprotocol/typescript-sdk/blob/1.16.0/src/types.ts#L356-L361
@koic koic force-pushed the add_instructions_support_to_mcp_server branch from e51e562 to f6f064a Compare August 7, 2025 03:18
@koic koic merged commit 930173a into modelcontextprotocol:main Aug 8, 2025
5 checks passed
@koic koic deleted the add_instructions_support_to_mcp_server branch August 8, 2025 18:22
@koic koic mentioned this pull request Aug 31, 2025
9 tasks
@atesgoral atesgoral mentioned this pull request Sep 14, 2025
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.

2 participants