feat(mcp): support sampling in a scoped way#5367
Conversation
| 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.
suspicious-looking import!
There was a problem hiding this comment.
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.
probably fine for now, but I suppose we will want to allow this to work too
There was a problem hiding this comment.
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.
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.
why maybe_to_value()? I think ti would return None here, we should probably return the relevant string though
30943fd to
c84f539
Compare
c84f539 to
93afbd6
Compare
| })?; | ||
|
|
||
| // convert back to MCP messages | ||
| let response_content = if let Some(content) = response.content.first() { |
fa587e7 to
1680290
Compare
1680290 to
3e2bc35
Compare
Signed-off-by: fbalicchia <fbalicchia@gmail.com>
Signed-off-by: Blair Allan <Blairallan@icloud.com>
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