import { LIB_VERSION } from "./version-BaA5pxTW.js";
import * as Sentry from "@sentry/node";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";

//#region src/transports/stdio.ts
/**
* Starts the MCP server with stdio transport and telemetry.
*
* Connects the server using stdio transport for process-based communication.
* Context is already captured in tool handler closures during buildServer().
* All operations are wrapped in Sentry tracing for observability.
*
* @param server - Configured and instrumented MCP server instance (with context in closures)
* @param context - Server context with authentication and configuration (for telemetry attributes)
*
* @example CLI Integration
* ```typescript
* import { buildServer } from "./server.js";
* import { startStdio } from "./transports/stdio.js";
*
* const context = {
*   accessToken: userToken,
*   sentryHost: "sentry.io",
*   userId: "user-123",
*   clientId: "cursor-ide",
*   constraints: {}
* };
*
* const server = buildServer({ context }); // Context captured in closures
* await startStdio(server, context);
* ```
*/
async function startStdio(server, context) {
	await Sentry.startNewTrace(async () => {
		return await Sentry.startSpan({
			name: "mcp.server/stdio",
			attributes: {
				"mcp.transport": "stdio",
				"network.transport": "pipe",
				"service.version": LIB_VERSION
			}
		}, async () => {
			const transport = new StdioServerTransport();
			await server.connect(transport);
		});
	});
}

//#endregion
export { startStdio };
//# sourceMappingURL=stdio-BfZ7eu3Q.js.map