Add an explicit Streamable HTTP entry for environment/gateway hosts while keeping stdio registrations and default behavior. Preserve the shared provider/session owner across DELETE and replacement; fence and drain tool/completion work before handover or teardown. Bound HTTP input and plain-response admission, cancel refused bodies, join whole exchanges and asynchronous response cleanup before provider hooks, gate startup readiness, and reject queued HTTP/1.1 pipelining while retaining sequential keep-alive. Validation: 8 static/build tasks, 83 adapter tests and registry metadata pass. A real installed gh binary produces seven equivalent CLI/stdio/HTTP reports with DELETE/replacement and clean signal shutdown. Broader local native-provider/ownership failures reproduce on clean main and are documented with limitations in the PR. Co-authored-by: Edgar Arakelyan <edgar.arakelyan@scale.com> Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
34 lines
1.3 KiB
TypeScript
34 lines
1.3 KiB
TypeScript
import type { McpServerFactory } from "@modelcontextprotocol/server";
|
|
import type { Logger } from "pino";
|
|
|
|
import type { OptionalProviderLoadResult } from "../application/OptionalObservationProviders.js";
|
|
|
|
/** Teardown handle every MCP transport returns to the runtime. */
|
|
export interface McpServerHandle {
|
|
/** Optional transport barrier before shared provider teardown. */
|
|
readonly prepareShutdown?: () => Promise<void>;
|
|
readonly close: () => Promise<void>;
|
|
}
|
|
|
|
/** Runtime inputs shared by the stdio and streamable HTTP transports. */
|
|
export interface McpServeOptions {
|
|
readonly onerror?: (error: Error) => void;
|
|
readonly logger?: Logger;
|
|
}
|
|
|
|
/** Start one transport around the server factory; a listener binds asynchronously. */
|
|
export type McpServe = (
|
|
factory: McpServerFactory,
|
|
options: McpServeOptions,
|
|
) => McpServerHandle | Promise<McpServerHandle>;
|
|
|
|
export interface RuntimeDependencies {
|
|
readonly env: NodeJS.ProcessEnv;
|
|
readonly serve: McpServe;
|
|
readonly writeStderr: (text: string) => void;
|
|
readonly setExitCode: (code: number) => void;
|
|
readonly registerShutdown: (handler: () => void) => () => void;
|
|
readonly createServer?: typeof import("../server/createServer.js").createServer;
|
|
readonly loadOptionalProviders?: () => Promise<OptionalProviderLoadResult>;
|
|
}
|