createStdioServerTransportWithStreams
Result<
Create stdio transport with custom stdin/stdout streams.
Returns Success with the transport or Error with message on failure.
Implementation
Result<StdioServerTransport, String> createStdioServerTransportWithStreams(
JSObject stdin,
JSObject stdout,
) {
try {
final sdkModule = requireModule(
'@modelcontextprotocol/sdk/server/stdio.js',
);
final transportClass = (sdkModule as JSObject)['StdioServerTransport'];
final jsTransportClass = transportClass as JSFunction;
final transport = jsTransportClass.callAsConstructor<StdioServerTransport>(
stdin,
stdout,
);
return Success(transport);
} catch (e) {
return Error('Failed to create stdio transport with streams: $e');
}
}