You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Complete elicitation pass-through so MCP servers can issue elicitation/create during tool execution, and the gateway forwards those requests to the originating client session, then returns the client response upstream. Add structured logging and metrics for elicitation lifecycle events.
Why Now?
MCP Compliance: The 2025-06-18 spec defines elicitation as a core capability for interactive tool workflows
Agentic Workflows: AI agents need to request user confirmation or additional input during tool execution
Session Correlation: Current implementation may route elicitation to wrong client in multi-user deployments
Observability Gap: No structured logging or metrics for elicitation events makes debugging difficult
📖 User Stories
US-1: MCP Server - Request User Input During Tool Execution
As an MCP Server developer I want to send elicitation/create requests during tool execution So that I can request user confirmation or additional input before proceeding
Acceptance Criteria:
Scenario: Server requests user confirmation via elicitationGiven an MCP server executing tool "delete_files"And the tool needs user confirmation before proceeding
When the server sends elicitation/create with message "Delete 50 files?"Then the gateway should forward the request to the originating client
And the client should display the confirmation dialog
And the client response should be returned to the server
And the tool execution should continue based on user response
Scenario: Elicitation reaches correct client in multi-user deploymentGiven user A is executing tool "sensitive_action" via session S1
And user B has an active session S2
When the server sends elicitation/create
Then the request should be routed ONLY to session S1
And session S2 should NOT receive the elicitation request
Scenario: Elicitation timeout returns error to serverGiven an elicitation request is pending
And the client does not respond within timeout period
When the timeout expires
Then the server should receive an error response
And the error should indicate "Elicitation timed out"
Technical Requirements:
Add elicitation_callback when creating ClientSession in tool_service.py
Map tool invocation to downstream session ID for routing
Use RequestContext.meta.related_request_id for correlation
US-2: Gateway - Route Elicitation to Correct Session
As a Platform Administrator I want elicitations to be routed to the correct client session So that the right user receives the request in multi-user deployments
Acceptance Criteria:
Scenario: Track session mapping during tool invocationGiven a tool invocation from client session "sess-123"When the upstream MCP server sends elicitation/create
Then the gateway should lookup the originating session "sess-123"And forward the elicitation to that specific session
And NOT broadcast to all elicitation-capable sessions
Scenario: Handle missing session gracefullyGiven an elicitation request with unknown session mapping
When the gateway attempts to route the request
Then a clear error should be returned to the server
And the error should indicate "No client session available"And the error should be logged with context
As a Client developer I want my client to advertise elicitation capability So that servers know they can request user input
Acceptance Criteria:
Scenario: Client without elicitation capabilityGiven a client that did not advertise capabilities.elicitation
When an MCP server sends elicitation/create via gateway
Then the gateway should return error to server immediately
And the error code should be -32601 (method not found)
And no forwarding should be attempted
Scenario: Client with elicitation capabilityGiven a client that advertised capabilities.elicitation
When the client connects and initializes
Then the session_registry should record elicitation=true
And elicitation requests should be routable to this client
Technical Requirements:
Check session.capabilities.elicitation before forwarding
Return clear error if capability not advertised
US-4: Operator - Monitor Elicitation Events
As a Platform Operator I want structured logging and metrics for elicitation events So that I can monitor and debug elicitation workflows
Acceptance Criteria:
Scenario: Log elicitation lifecycle eventsGiven structured logging is enabled
When an elicitation request is created
Then a log entry should contain:
| Field | Value | | event | elicitation.created | | request_id | {request_id} | | upstream_session | {server_session} | | downstream_session | {client_session} | | message | {elicitation_message} |When the client responds
Then a log entry should contain:
| Field | Value | | event | elicitation.completed | | action | accept/decline/cancel | | duration_ms | {elapsed_time} |Scenario: Metrics for elicitation eventsGiven Prometheus metrics are enabled
Then the following metrics should be exposed:
| Metric | Type | | elicitation_requests_total | Counter | | elicitation_completed_total | Counter (byaction) | | elicitation_timeout_total | Counter | | elicitation_duration_seconds | Histogram |
Technical Requirements:
Emit structured log events for created, delivered, completed, timeout, error
Add Prometheus counters and histograms
Include latency histogram for response time
🏗 Architecture
Elicitation Flow with Session Mapping
sequenceDiagram
participant Client as MCP Client (User A)
participant Gateway
participant Registry as SessionRegistry
participant Server as MCP Server
Client->>Gateway: Initialize (capabilities.elicitation=true)
Gateway->>Registry: Store session "sess-123" with elicitation=true
Client->>Gateway: tools/call "delete_files"
Gateway->>Gateway: Store mapping: call-456 -> sess-123
Gateway->>Server: Execute tool
Server->>Gateway: elicitation/create
Gateway->>Gateway: Lookup session for call-456
Gateway->>Registry: Get session "sess-123"
Gateway->>Client: Forward elicitation request
Client->>Gateway: Elicitation response (action: "accept")
Gateway->>Server: ElicitResult
Server->>Gateway: Tool result
Gateway->>Client: Tool response
Loading
Current vs Proposed Behavior
Aspect
Current
Proposed
Upstream elicitation callback
Not set (uses default reject)
Custom callback forwarding to gateway
Session routing
First elicitation-capable session
Mapped originating session
Streamable HTTP
Not explicit
Explicit handling in transport
Logging
Basic logger.info
Structured events + metrics
📋 Implementation Tasks
Phase 1: Elicitation Callback in Tool Service
Add elicitation_callback parameter when creating ClientSession in tool_service.py
Implement callback that uses ElicitationService to forward request
Store downstream_session_id in request context before tool invocation
Use RequestContext.meta.related_request_id for correlation
📨 Feature: Elicitation Pass-Through and Logging
Goal
Complete elicitation pass-through so MCP servers can issue
elicitation/createduring tool execution, and the gateway forwards those requests to the originating client session, then returns the client response upstream. Add structured logging and metrics for elicitation lifecycle events.Why Now?
📖 User Stories
US-1: MCP Server - Request User Input During Tool Execution
As an MCP Server developer
I want to send
elicitation/createrequests during tool executionSo that I can request user confirmation or additional input before proceeding
Acceptance Criteria:
Technical Requirements:
elicitation_callbackwhen creatingClientSessionintool_service.pyRequestContext.meta.related_request_idfor correlationUS-2: Gateway - Route Elicitation to Correct Session
As a Platform Administrator
I want elicitations to be routed to the correct client session
So that the right user receives the request in multi-user deployments
Acceptance Criteria:
Technical Requirements:
tool_call_id -> downstream_session_id-32601error if no session availableUS-3: Client - Advertise Elicitation Capability
As a Client developer
I want my client to advertise elicitation capability
So that servers know they can request user input
Acceptance Criteria:
Technical Requirements:
session.capabilities.elicitationbefore forwardingUS-4: Operator - Monitor Elicitation Events
As a Platform Operator
I want structured logging and metrics for elicitation events
So that I can monitor and debug elicitation workflows
Acceptance Criteria:
Technical Requirements:
🏗 Architecture
Elicitation Flow with Session Mapping
sequenceDiagram participant Client as MCP Client (User A) participant Gateway participant Registry as SessionRegistry participant Server as MCP Server Client->>Gateway: Initialize (capabilities.elicitation=true) Gateway->>Registry: Store session "sess-123" with elicitation=true Client->>Gateway: tools/call "delete_files" Gateway->>Gateway: Store mapping: call-456 -> sess-123 Gateway->>Server: Execute tool Server->>Gateway: elicitation/create Gateway->>Gateway: Lookup session for call-456 Gateway->>Registry: Get session "sess-123" Gateway->>Client: Forward elicitation request Client->>Gateway: Elicitation response (action: "accept") Gateway->>Server: ElicitResult Server->>Gateway: Tool result Gateway->>Client: Tool responseCurrent vs Proposed Behavior
📋 Implementation Tasks
Phase 1: Elicitation Callback in Tool Service
elicitation_callbackparameter when creatingClientSessionintool_service.pyElicitationServiceto forward requestdownstream_session_idin request context before tool invocationRequestContext.meta.related_request_idfor correlationPhase 2: Session Mapping Registry
tool_call_id -> downstream_session_idPhase 3: Capability Enforcement
session.capabilities.elicitationbefore forwarding-32601error if client lacks capabilityPhase 4: Streamable HTTP Support
streamablehttp_transport.pyPhase 5: Structured Logging
elicitation.createdevent with request detailselicitation.deliveredevent when forwarded to clientelicitation.completedevent with action and durationelicitation.timeoutevent when timeout occurselicitation.errorevent for failuresPhase 6: Metrics
elicitation_requests_totalcounterelicitation_completed_totalcounter withactionlabelelicitation_timeout_totalcounterelicitation_duration_secondshistogram/metricsendpointPhase 7: Testing
⚙️ Configuration Example
✅ Success Criteria
elicitation/createand receive response🏁 Definition of Done
make verify📝 Additional Notes
MCP Specification References
Current Implementation (Gaps)
ElicitationServicesession_registrytool_service.ClientSessionelicitation_callback🔗 Related Issues
mcpgateway/services/elicitation_service.pymcpgateway/cache/session_registry.py