Skip to content
This repository was archived by the owner on May 29, 2026. It is now read-only.

mcp sampling#1722

Merged
pelikhan merged 10 commits into
devfrom
mcp-sampling
Jul 9, 2025
Merged

mcp sampling#1722
pelikhan merged 10 commits into
devfrom
mcp-sampling

Conversation

@pelikhan

@pelikhan pelikhan commented Jul 9, 2025

Copy link
Copy Markdown
Member

Pull Request Summary

MCP Client Sampling Integration 🚀

  • Introduced MCP Client Sampling Support:

    • Added a new language model provider "mcp" that enables sampling via the Model Context Protocol (MCP) client.
    • Implemented mcpRequestSample to handle chat completion requests through the MCP server and return responses using a streaming protocol.
  • Worker Language Model Bridge 🧑‍💻

    • Created a createWorkerLanguageModel utility, allowing worker threads to delegate language model requests back to the parent process for sampling.
    • Enhanced worker and API logic to support passing chat completion requests and responses between processes.
  • API and Server Enhancements 🔗

    • Extended the run API to support an onMessage callback with a postMessage function for bidirectional communication.
    • Enabled the server to detect and use client sampling capabilities, forwarding chat completion requests to the client when "mcp" is the selected model.
    • Updated server initialization to check client capabilities and set up the appropriate language model bridge.
  • Resource Management Improvements 🗂️

    • Fixed a typo in resource upsert method (upsetResourceupsertResource).
    • Ensured resource updates are handled correctly via event listeners and upsert logic.
  • LLM Data and Model Resolution Updates 🧠

    • Registered "mcp" as a valid model provider and updated model resolution logic to support it.
    • Added metadata and configuration for the "mcp" provider in the LLMs data registry.
  • Sample Script Update 📝

    • Modified the emojifier sample script to use the new "mcp" model provider for demonstration.
  • Type and Code Quality Improvements 🧹

    • Improved type annotations and consistency across multiple modules.
    • Refactored event handling and watcher logic for better reliability and maintainability.

These changes collectively enable MCP-based client sampling for language model completions, allowing for advanced, pluggable model usage and improved extensibility in the platform.

AI-generated content by prd may be incorrect.

@pelikhan pelikhan merged commit b9a28f1 into dev Jul 9, 2025
11 of 13 checks passed
@pelikhan pelikhan deleted the mcp-sampling branch July 9, 2025 15:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant