Skip to content

mcp: initial sampling implementation #249946

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

Merged
merged 3 commits into from
May 28, 2025
Merged

mcp: initial sampling implementation #249946

merged 3 commits into from
May 28, 2025

Conversation

connor4312
Copy link
Member

  • MCP servers get a prompt when they ask for sampling. Usage in tool
    calls (i.e. a sampling request within a concurrent tool request) is a
    separate prompt from 'ambient' usage. Sampling is 'just' a request to
    the client and can technically happen at any time.
  • By default MCP servers will get the default model in chat. But that is
    configurable by users. Multiple models can be configured and if they
    are then the model will be picked based on the rough 'model hints' we
    get from the server.
  • Not sure where the config should live. I have it in user settings in
    this demo. Having it in mcp.json would be a natural place to put it,
    but that doesn't work for extension-provided servers or servers from
    other config files (e.g. claude desktop configs) so that could not
    be the only place.
  • There are some limitations from MCP such as Inconsistent Content Type Definitions in MCP Schema modelcontextprotocol/modelcontextprotocol#91

- MCP servers get a prompt when they ask for sampling. Usage in tool
  calls (i.e. a sampling request within a concurrent tool request) is a
  separate prompt from 'ambient' usage. Sampling is 'just' a request to
  the client and can technically happen at any time.
- By default MCP servers will get the default model in chat. But that is
  configurable by users. Multiple models can be configured and if they
  are then the model will be picked based on the rough 'model hints' we
  get from the server.
- Not sure where the config should live. I have it in user settings in
  this demo. Having it in mcp.json would be a natural place to put it,
  but that doesn't work for extension-provided servers or servers from
  other config files (e.g. claude desktop configs) so that could not
  be the only place.
- There are some limitations from MCP such as modelcontextprotocol/modelcontextprotocol#91

const model = await this._getMatchingModel(opts);
// todo@connor4312: nullExtensionDescription.identifier -> undefined with API update
const response = await this._languageModelsService.sendChatRequest(model, new ExtensionIdentifier('Github.copilot-chat'), messages, {}, token);
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a 🩸, but to keep this PR focused I'll open a second PR for the necessary API change. Sampling is rarely used yet today so I do not expect any big issues.

@connor4312 connor4312 marked this pull request as ready for review May 28, 2025 20:41
@connor4312 connor4312 enabled auto-merge May 28, 2025 20:41
@vs-code-engineering vs-code-engineering bot added this to the May 2025 milestone May 28, 2025
@connor4312 connor4312 merged commit 73944df into main May 28, 2025
8 checks passed
@connor4312 connor4312 deleted the connor4312/sampling-1 branch May 28, 2025 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants