feat(mcp): support sampling in a scoped way
Implements basic support for MCP Sampling
- MCP servers can now request sampling and it will be handled by goose to route a sampling message to the provider for completion
- Works for desktop and CLI
- Does not yet implement human in the loop approval of these, which is a
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 iterate - Sampling is supposed to be text, image, or audio. This does not handle audio, because interestingly goose does not handle audio message content. Can be a followup when we support it generally.
Demos of it working in CLI and Desktop with the everything server the prompt
Use the sampleLLM tool in the everything extension to have the mcp server request sampling from the model. Have the mcp server ask the model for a quote from the great gatsby
@jamadeo @DOsinga Updated it to always uses the agent's current provider via a shared reference. Verified by the llm_request logs that it uses different models for sampling after switching providers.
Draft of a couple different approaches to integration testing for sampling https://github.com/block/goose/pull/5456
Wanted to make a separate PR to get feedback on which one seems most valuable
@jamadeo @DOsinga