-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat(mcp): support sampling in a scoped way #5367
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
Conversation
jamadeo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
| ClientHandler, Peer, RoleClient, ServiceError, ServiceExt, | ||
| ClientHandler, ErrorData as McpError, ErrorData, Peer, RoleClient, ServiceError, ServiceExt, | ||
| }; | ||
| use schemars::_private::NoSerialize; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suspicious-looking import!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was needed for e.maybe_to_value() but no longer using that, so it's gone!
|
|
||
| let result = extension_manager | ||
| .add_extension(config) | ||
| .add_extension(config, None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably fine for now, but I suppose we will want to allow this to work too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory I fixed this in the most recent commit, which changes the approach of how the extension manager has a reference to a provider. Didn't text explicitly for sampling through extension_manager managed extensions, but I think it may work now. I'll add a note to follow up on it.
DOsinga
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This generally looks good and would allow us to ship something. I'm a little concerned on how we handle providers. within the context of mcp, I don't think they should be optional - we can't have an MCP call without a provider, right?
the other is that we now set a provider on the extension_manager. in some scenarios we might not have it yet, maybe that's why it is optional? but I don't think we can be sure we're using the right provider if the user switches models, providers etc.
we should use the provider of the agent I think.
| ErrorData::new( | ||
| ErrorCode::INTERNAL_ERROR, | ||
| "Unexpected error while completing the prompt", | ||
| e.maybe_to_value(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why maybe_to_value()? I think ti would return None here, we should probably return the relevant string though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjusted
30943fd to
c84f539
Compare
c84f539 to
93afbd6
Compare
DOsinga
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how do we test this?
| })?; | ||
|
|
||
| // convert back to MCP messages | ||
| let response_content = if let Some(content) = response.content.first() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only first?
fa587e7 to
1680290
Compare
1680290 to
3e2bc35
Compare
Signed-off-by: fbalicchia <[email protected]>
Signed-off-by: Blair Allan <[email protected]>
Implements basic support for MCP Sampling
SHOULDfor clients in the MCP spec, but added significant overhead to the initial implementation so the idea is to get a scoped and working implementation out and then iterateDemos of it working in CLI and Desktop with the everything server the prompt