Skip to content

Conversation

@gaaclarke
Copy link
Contributor

fixes #196

This makes sure that the map for the InitializationResult doesn't include a instructions entry if the value is null.


  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
Contribution guidelines:

Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.

@gaaclarke
Copy link
Contributor Author

This is a pretty tricky way to hide a bug. I wonder if using extension types for InitializationResult is actually buying us anything.

@gaaclarke
Copy link
Contributor Author

I'm not sure what the release protocol is for this, do you want me to update the changelog.md and bump the version too?

Comment on lines 59 to 69
}) {
final map = {
'protocolVersion': protocolVersion.versionString,
'capabilities': serverCapabilities,
'serverInfo': serverInfo,
};
if (instructions != null) {
map['instructions'] = instructions;
}
return InitializeResult.fromMap(map);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
}) {
final map = {
'protocolVersion': protocolVersion.versionString,
'capabilities': serverCapabilities,
'serverInfo': serverInfo,
};
if (instructions != null) {
map['instructions'] = instructions;
}
return InitializeResult.fromMap(map);
}
}) => InitializeResult.fromMap({
'protocolVersion': protocolVersion.versionString,
'capabilities': serverCapabilities,
'serverInfo': serverInfo,
'instructions': ?instructions,
});

Copy link
Contributor

Choose a reason for hiding this comment

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

Or if our language version doesn't support that, we can do if (instructions != null) 'instructions': instructions,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We needed 3.8 for ?instructions, done.

@jakemac53
Copy link
Contributor

I'm not sure what the release protocol is for this, do you want me to update the changelog.md and bump the version too?

Yes, bump the version to 0.3.1-wip please and then add a new entry to the changelog.

@gaaclarke
Copy link
Contributor Author

Yes, bump the version to 0.3.1-wip please and then add a new entry to the changelog.

done

@gaaclarke gaaclarke requested a review from jakemac53 July 14, 2025 16:59
@gaaclarke gaaclarke requested a review from jakemac53 July 14, 2025 17:03
@github-actions
Copy link

PR Health

Changelog Entry ✔️
Package Changed Files

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

@jakemac53 jakemac53 merged commit c1a1027 into dart-lang:main Jul 14, 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.

DartMCPServer's instructions are required for Gemini and Claude code MCP integrations.

2 participants