@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
53 lines • 2.52 kB
TypeScript
/**
* SDK object construction for the transport layer.
*
* `transport.ts` validates a server config synchronously (its typed create
* errors are part of the public contract) and describes the transport as a
* plain spec; everything that needs a class out of
* `@modelcontextprotocol/sdk` — the stdio/HTTP transports, the client, the
* elicitation handler — is built here, behind `sdk.lazy.ts`, when the
* connection is first materialized on the async connect path.
*/
import type { Client } from "@modelcontextprotocol/sdk/client/index.js";
import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
import type { McpOAuthProvider } from "./auth/oauth-provider.ts";
import type { McpElicitationUiProvider } from "./elicitation.ts";
import type { McpLogger } from "./log.ts";
import type { ModernProtocolState } from "./modern/request.ts";
import { type McpAsyncErrorSink } from "./wrap.ts";
export type McpStdioTransportSpec = {
readonly projectPolicy?: boolean;
readonly resolveBeforeStart?: () => Promise<McpStdioTransportSpec>;
readonly kind: "stdio";
readonly command: string;
readonly args: string[] | undefined;
readonly cwd: string | undefined;
/** Config + caller env, already merged; the SDK default environment is layered underneath. */
readonly env: Record<string, string>;
readonly authProvider: McpOAuthProvider | undefined;
};
export type McpHttpTransportSpec = {
readonly kind: "http";
readonly url: URL;
readonly authProvider: McpOAuthProvider | undefined;
readonly requestInit: RequestInit | undefined;
};
export type McpTransportSpec = McpStdioTransportSpec | McpHttpTransportSpec;
export interface McpMaterializedTransport {
readonly transport: Transport;
readonly client: Client;
/** Root pid of a stdio child, or null for HTTP and before start. */
readPid(): number | null;
close(): Promise<void>;
}
export interface MaterializeMcpTransportOptions {
readonly spec: McpTransportSpec;
readonly logger: McpLogger;
readonly sink: McpAsyncErrorSink;
readonly elicitationUiProvider: McpElicitationUiProvider | undefined;
readonly elicitationEnabled?: boolean;
/** Invoked once the stdio child has started, so the caller can capture its pid. */
readonly onStart: () => void;
}
export declare function materializeMcpTransport(options: MaterializeMcpTransportOptions, protocol?: ModernProtocolState): Promise<McpMaterializedTransport>;
//# sourceMappingURL=transport-sdk.d.ts.map