SEP-XXX: Sample calls establish new sessions to enable zero-knowledge MCP nesting or chaining.
SEP Type: Standards Track
Status: proposal
Author: @codingjoe
Created: 2025-01-17
Abstract
This SEP proposes extending MCP's sampling feature to support native tool-calling capabilities through session-based capability expansion. Currently, sampling only supports chat completion and relies on unreliable JSON parsing workarounds for tool execution. This enhancement would allow MCP servers to create new sessions with expanded capabilities during sampling operations, using MCP's existing session mechanism (via the Mcp-Session-Id header) to provide an updated context within the sampling context.
The key innovation is that includeContext: "thisServer" would enable servers to present a session with different capabilities, effectively exposing composite servers attached to the server that acts as a proxy. This enables MCP server chaining, where servers can dynamically expose tools from their own MCP clients during sampling operations, creating a rich ecosystem of interconnected capabilities while maintaining backward compatibility and security through existing session management patterns.
This SEP qualifies for the formal SEP process as it represents a significant new feature that adds new API semantics, changes existing message structures, and requires broad community discussion for successful adoption across the MCP ecosystem.
Motivation
The current MCP sampling implementation is limited to basic chat completion, forcing developers to use unreliable workarounds like system prompts that instruct models to output JSON for tool calls. This approach has several critical limitations:
- Reliability: JSON parsing from unstructured LLM output is inherently fragile and error-prone
- Model Capabilities: Modern LLMs have native tool calling support that provides structured, validated function calls
- Developer Experience: Current workarounds require complex prompt engineering and parsing logic
- Dynamic Capabilities: No way to temporarily expand server capabilities for specific sampling operations
- MCP Chaining: Servers cannot effectively provide access to their own MCP client capabilities during sampling
This proposal enables servers to create new sessions with expanded capabilities during sampling operations, leveraging MCP's existing session management infrastructure through Mcp-Session-Id headers.
Rationale
Current Limitations
The existing sampling functionality operates within the static capability set established during the original session initialization. This doesn't enable:
- Dynamic Tool Expansion: Servers cannot expose additional tools just for sampling operations
- MCP Client Chaining: Servers with their own MCP clients cannot expose those capabilities during sampling
- Temporary Resources: No way to provide temporary access to resources needed only during sampling
- Reliable Tool Execution: JSON parsing workarounds are unreliable compared to native function calling
Design Goals
- Backward Compatibility: Existing sampling functionality must continue to work unchanged
- Leverage Existing Infrastructure: Use MCP's established session management patterns
- Security First: Maintain human-in-the-loop controls and existing authorization model
- Consistency with MCP Patterns: Follow existing session header patterns
- Reliability: Leverage native LLM tool calling APIs where available
Session-Based Approach
The key insight is to use MCP's existing session infrastructure where:
- Original Session: The main client-server session with standard capabilities
- Sampling Session: A new session created during sampling with expanded capabilities
- Session Headers: Use existing
Mcp-Session-Id header mechanism.
- Capability Expansion: New session can have different tools, resources, and capabilities
This follows MCP's established pattern where each session has its own state and capabilities.
Specification
Enhanced Sampling with Session-Based Capability Expansion
The sampling message sent from the server to the client will include a Mcp-Session-Id header, which may vary from the original session ID.
This new session ID represents a session with potentially different capabilities, including tool-calling features.
The client will need to validate the capabilities of the session associated with the provided Mcp-Session-Id header.
The actual sampling message does not change, but the context in which it is executed can now include different capabilities.
This approach will only require extensions to the definition of a session and its lifecycle, as well as explicit clarification of session handling in the sampling context.
SEP-XXX: Sample calls establish new sessions to enable zero-knowledge MCP nesting or chaining.
SEP Type: Standards Track
Status: proposal
Author: @codingjoe
Created: 2025-01-17
Abstract
This SEP proposes extending MCP's sampling feature to support native tool-calling capabilities through session-based capability expansion. Currently, sampling only supports chat completion and relies on unreliable JSON parsing workarounds for tool execution. This enhancement would allow MCP servers to create new sessions with expanded capabilities during sampling operations, using MCP's existing session mechanism (via the
Mcp-Session-Idheader) to provide an updated context within the sampling context.The key innovation is that
includeContext: "thisServer"would enable servers to present a session with different capabilities, effectively exposing composite servers attached to the server that acts as a proxy. This enables MCP server chaining, where servers can dynamically expose tools from their own MCP clients during sampling operations, creating a rich ecosystem of interconnected capabilities while maintaining backward compatibility and security through existing session management patterns.This SEP qualifies for the formal SEP process as it represents a significant new feature that adds new API semantics, changes existing message structures, and requires broad community discussion for successful adoption across the MCP ecosystem.
Motivation
The current MCP sampling implementation is limited to basic chat completion, forcing developers to use unreliable workarounds like system prompts that instruct models to output JSON for tool calls. This approach has several critical limitations:
This proposal enables servers to create new sessions with expanded capabilities during sampling operations, leveraging MCP's existing session management infrastructure through
Mcp-Session-Idheaders.Rationale
Current Limitations
The existing sampling functionality operates within the static capability set established during the original session initialization. This doesn't enable:
Design Goals
Session-Based Approach
The key insight is to use MCP's existing session infrastructure where:
Mcp-Session-Idheader mechanism.This follows MCP's established pattern where each session has its own state and capabilities.
Specification
Enhanced Sampling with Session-Based Capability Expansion
The sampling message sent from the server to the client will include a
Mcp-Session-Idheader, which may vary from the original session ID.This new session ID represents a session with potentially different capabilities, including tool-calling features.
The client will need to validate the capabilities of the session associated with the provided
Mcp-Session-Idheader.The actual sampling message does not change, but the context in which it is executed can now include different capabilities.
This approach will only require extensions to the definition of a session and its lifecycle, as well as explicit clarification of session handling in the sampling context.