Skip to content

Conversation

@KKonstantinov
Copy link
Contributor

@KKonstantinov KKonstantinov commented Nov 6, 2025

Implemented modelcontextprotocol/modelcontextprotocol#1692, which lead to opportunities to remove .passthrough() on many places.

NOTE: Added all spec types, however spec tests will still fail until modelcontextprotocol/modelcontextprotocol#1770 gets merged, which fixes an accidental change of CallToolRequestParams, arguments to be { [key: string]: string }; instead of { [key: string]: unknown }; in modelcontextprotocol/modelcontextprotocol#1692

EDIT: #1770 in the spec repo has been merged, so no issues in spec type checks.

Motivation and Context

Implement SEP-1319, fix spec tests failures, remove passthrough where possibly (although the PR could possibly be achieved without removing .passthrough() as well).

How Has This Been Tested?

Unit tests, examples

Breaking Changes

Any client(s) and server(s) passing through any invalid properties will get typecheck errors. Our examples and tests contained such, which previously slipped through due to type checks not working. Examples of such can be seen in this PR's changes. Any client(s) / server(s) copying from such examples in our codebase would get a typecheck error.

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

protected assertRequestHandlerCapability(method: string): void {
switch (method) {
case 'sampling/createMessage':
if (!this._capabilities.sampling) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Servers do not have sampling capabilities, thus removed. Swapped with completions capabilities.

street: { type: 'string' },
city: { type: 'string' },
// @ts-expect-error - pattern is not a valid property by MCP spec, however it is making use of the Ajv validator
zipCode: { type: 'string', pattern: '^[0-9]{5}$' },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Patterns not supported by the spec. Passing them will work, but the TS error needs ignoring.


// Create first client
const client1 = new Client({
id: clientId,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No such property.

type: 'string',
title: 'Start Time',
description: 'Event start time (HH:MM)',
pattern: '^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pattern could be left here, but needs ts-ignore, as not supported by the spec. We could allow it on an optional basis and still match the spec if we wanted.

switch (request.params.ref.type) {
case 'ref/prompt':
assertCompleteRequestPrompt(request);
return this.handlePromptCompletion(request, request.params.ref);
Copy link
Contributor Author

@KKonstantinov KKonstantinov Nov 7, 2025

Choose a reason for hiding this comment

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

When passthrough removed, assertions are needed to proceed with a narrowed type to alleviate type errors downstream.

{
name: 'new client',
version: '1.0',
protocolVersion: LATEST_PROTOCOL_VERSION
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Property doesn't exist.

@KKonstantinov
Copy link
Contributor Author

The npm run check step is failing because step.types.ts (the main protocol spec) is failing our linting. Have ignored the file from linting, as it's not within the SDK's control.

@KKonstantinov KKonstantinov marked this pull request as ready for review November 7, 2025 11:58
@KKonstantinov KKonstantinov requested a review from a team as a code owner November 7, 2025 11:58
Copy link
Member

@pcarleton pcarleton left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@pcarleton pcarleton merged commit f59996a into modelcontextprotocol:main Nov 7, 2025
2 checks passed
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