goose icon indicating copy to clipboard operation
goose copied to clipboard

feat(mcp): support sampling in a scoped way

Open alexhancock opened this issue 2 months ago • 2 comments

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 SHOULD for 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

Screenshot 2025-10-24 at 5 28 49 PM Screenshot 2025-10-24 at 5 31 13 PM

alexhancock avatar Oct 24 '25 21:10 alexhancock

@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.

alexhancock avatar Oct 28 '25 21:10 alexhancock

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

alexhancock avatar Oct 29 '25 21:10 alexhancock