fix(everything): implement graceful HTTP elicitation degradation

Implement graceful degradation for elicitation on HTTP transport:
- STDIO: Full elicitation works via sendRequest
- HTTP: Catches elicitation failure, uses default interpretation
- Task completes successfully on both transports

simulate-research-query now uses try-catch around sendRequest and
includes explanatory message when elicitation is skipped on HTTP.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
olaservo
2026-01-18 19:19:32 -07:00
parent 1cda86effb
commit 5156cff9dc
4 changed files with 87 additions and 51 deletions

View File

@@ -1,10 +1,37 @@
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
import { InMemoryEventStore } from "@modelcontextprotocol/sdk/examples/shared/inMemoryEventStore.js";
import { StreamableHTTPServerTransport, EventStore } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
import express, { Request, Response } from "express";
import { createServer } from "../server/index.js";
import { randomUUID } from "node:crypto";
import cors from "cors";
// Simple in-memory event store for SSE resumability
class InMemoryEventStore implements EventStore {
private events: Map<string, { streamId: string; message: unknown }> = new Map();
async storeEvent(streamId: string, message: unknown): Promise<string> {
const eventId = randomUUID();
this.events.set(eventId, { streamId, message });
return eventId;
}
async replayEventsAfter(
lastEventId: string,
{ send }: { send: (eventId: string, message: unknown) => Promise<void> }
): Promise<string> {
const entries = Array.from(this.events.entries());
const startIndex = entries.findIndex(([id]) => id === lastEventId);
if (startIndex === -1) return lastEventId;
let lastId: string = lastEventId;
for (let i = startIndex + 1; i < entries.length; i++) {
const [eventId, { message }] = entries[i];
await send(eventId, message);
lastId = eventId;
}
return lastId;
}
}
console.log("Starting Streamable HTTP server...");
// Express app with permissive CORS for testing with Inspector direct connect mode