Skip to content

Conversation

@elliette
Copy link
Contributor

@elliette elliette commented Dec 4, 2025

Work towards #326

@github-actions
Copy link

github-actions bot commented Dec 4, 2025

PR Health

Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

This check can be disabled by tagging the PR with skip-changelog-check.

Copy link
Contributor

@jakemac53 jakemac53 left a comment

Choose a reason for hiding this comment

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

Looks good but see my suggestion about simplifying this a bunch

@elliette elliette changed the title [Draft] Add service extension for sending a sampling request to the MCP server Add service extension for sending a sampling request to the MCP server Dec 5, 2025
@elliette elliette marked this pull request as ready for review December 5, 2025 19:05
Comment on lines 292 to 296
await dtd.registerService(
McpServiceConstants.serviceName,
McpServiceConstants.samplingRequest,
_handleSamplingRequest,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I just also realized this should probably be guarded behind a check that the client actually supports sampling, something like:

Suggested change
await dtd.registerService(
McpServiceConstants.serviceName,
McpServiceConstants.samplingRequest,
_handleSamplingRequest,
);
if (clientCapabilities.sampling != null) {
await dtd.registerService(
McpServiceConstants.serviceName,
McpServiceConstants.samplingRequest,
_handleSamplingRequest,
);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, do we need to make sure this service isn't already registered on DTD by some other client?

Copy link
Contributor Author

@elliette elliette Dec 5, 2025

Choose a reason for hiding this comment

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

Oof good point! Done.

Re checking if another client has already registered it - can there be multiple Dart MCP servers connected to the same DTD connection? I didn't think there could. I don't know why another client would have registered it on DTD.

Copy link
Contributor

@jakemac53 jakemac53 Dec 5, 2025

Choose a reason for hiding this comment

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

There can be yes - if multiple chat clients connect to the DTD instance started by an IDE.

For instance if somebody has two instances of Gemini CLI running at once for some reason, or two different chat bots.

@jakemac53
Copy link
Contributor

Also just to clarify I am fine with landing this as is and following up with something to handle multiple clients trying to register the same method, if that is easier

@elliette
Copy link
Contributor Author

elliette commented Dec 6, 2025

Also just to clarify I am fine with landing this as is and following up with something to handle multiple clients trying to register the same method, if that is easier

Good because that was my plan 😄

@elliette elliette merged commit c5ee303 into dart-lang:main Dec 6, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants