UNPKG

@cyanheads/filesystem-mcp-server

Version:

A Model Context Protocol (MCP) server for platform-agnostic file capabilities, including advanced search and replace, and directory tree traversal

24 lines (23 loc) 1.42 kB
/** * @fileoverview Handles the setup and management of the Streamable HTTP MCP transport. * Implements the MCP Specification 2025-03-26 for Streamable HTTP. * This includes creating an Express server, configuring middleware (CORS, Authentication), * defining request routing for the single MCP endpoint (POST/GET/DELETE), * managing server-side sessions, handling Server-Sent Events (SSE) for streaming, * and binding to a network port with retry logic for port conflicts. * * Specification Reference: * https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/docs/specification/2025-03-26/basic/transports.mdx#streamable-http * @module src/mcp-server/transports/httpTransport */ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { RequestContext } from "../../utils/internal/requestContext.js"; /** * Sets up and starts the Streamable HTTP transport layer for the MCP server. * * @param createServerInstanceFn - An asynchronous factory function that returns a new `McpServer` instance. * @param parentContext - Logging context from the main server startup process. * @returns A promise that resolves when the HTTP server is successfully listening. * @throws {Error} If the server fails to start after all port retries. */ export declare function startHttpTransport(createServerInstanceFn: () => Promise<McpServer>, parentContext: RequestContext): Promise<void>;