ai 4.1.63 → 4.1.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/mcp-stdio/create-child-process.ts +56 -0
- package/mcp-stdio/dist/index.d.mts +169 -0
- package/mcp-stdio/dist/index.d.ts +169 -0
- package/mcp-stdio/dist/index.js +348 -0
- package/mcp-stdio/dist/index.js.map +1 -0
- package/mcp-stdio/dist/index.mjs +333 -0
- package/mcp-stdio/dist/index.mjs.map +1 -0
- package/mcp-stdio/index.ts +4 -0
- package/mcp-stdio/mcp-stdio-transport.test.ts +262 -0
- package/mcp-stdio/mcp-stdio-transport.ts +157 -0
- package/package.json +5 -4
    
        package/CHANGELOG.md
    CHANGED
    
    | @@ -1,5 +1,20 @@ | |
| 1 1 | 
             
            # ai
         | 
| 2 2 |  | 
| 3 | 
            +
            ## 4.1.65
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            ### Patch Changes
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            - 16c444f: fix (ai): expose ai/mcp-stdio
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            ## 4.1.64
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            ### Patch Changes
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            - Updated dependencies [d0c4659]
         | 
| 14 | 
            +
              - @ai-sdk/provider-utils@2.1.15
         | 
| 15 | 
            +
              - @ai-sdk/react@1.1.25
         | 
| 16 | 
            +
              - @ai-sdk/ui-utils@1.1.21
         | 
| 17 | 
            +
             | 
| 3 18 | 
             
            ## 4.1.63
         | 
| 4 19 |  | 
| 5 20 | 
             
            ### Patch Changes
         | 
| @@ -0,0 +1,56 @@ | |
| 1 | 
            +
            import { ChildProcess, spawn } from 'node:child_process';
         | 
| 2 | 
            +
            import { StdioConfig } from './mcp-stdio-transport';
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            export async function createChildProcess(
         | 
| 5 | 
            +
              config: StdioConfig,
         | 
| 6 | 
            +
              signal: AbortSignal,
         | 
| 7 | 
            +
            ): Promise<ChildProcess> {
         | 
| 8 | 
            +
              return spawn(config.command, config.args ?? [], {
         | 
| 9 | 
            +
                env: config.env ?? getDefaultEnvironment(),
         | 
| 10 | 
            +
                stdio: ['pipe', 'pipe', config.stderr ?? 'inherit'],
         | 
| 11 | 
            +
                shell: false,
         | 
| 12 | 
            +
                signal,
         | 
| 13 | 
            +
                windowsHide: globalThis.process.platform === 'win32' && isElectron(),
         | 
| 14 | 
            +
                cwd: config.cwd,
         | 
| 15 | 
            +
              });
         | 
| 16 | 
            +
            }
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            function getDefaultEnvironment(): Record<string, string> {
         | 
| 19 | 
            +
              const DEFAULT_INHERITED_ENV_VARS =
         | 
| 20 | 
            +
                globalThis.process.platform === 'win32'
         | 
| 21 | 
            +
                  ? [
         | 
| 22 | 
            +
                      'APPDATA',
         | 
| 23 | 
            +
                      'HOMEDRIVE',
         | 
| 24 | 
            +
                      'HOMEPATH',
         | 
| 25 | 
            +
                      'LOCALAPPDATA',
         | 
| 26 | 
            +
                      'PATH',
         | 
| 27 | 
            +
                      'PROCESSOR_ARCHITECTURE',
         | 
| 28 | 
            +
                      'SYSTEMDRIVE',
         | 
| 29 | 
            +
                      'SYSTEMROOT',
         | 
| 30 | 
            +
                      'TEMP',
         | 
| 31 | 
            +
                      'USERNAME',
         | 
| 32 | 
            +
                      'USERPROFILE',
         | 
| 33 | 
            +
                    ]
         | 
| 34 | 
            +
                  : ['HOME', 'LOGNAME', 'PATH', 'SHELL', 'TERM', 'USER'];
         | 
| 35 | 
            +
             | 
| 36 | 
            +
              const env: Record<string, string> = {};
         | 
| 37 | 
            +
             | 
| 38 | 
            +
              for (const key of DEFAULT_INHERITED_ENV_VARS) {
         | 
| 39 | 
            +
                const value = globalThis.process.env[key];
         | 
| 40 | 
            +
                if (value === undefined) {
         | 
| 41 | 
            +
                  continue;
         | 
| 42 | 
            +
                }
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                if (value.startsWith('()')) {
         | 
| 45 | 
            +
                  continue;
         | 
| 46 | 
            +
                }
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                env[key] = value;
         | 
| 49 | 
            +
              }
         | 
| 50 | 
            +
             | 
| 51 | 
            +
              return env;
         | 
| 52 | 
            +
            }
         | 
| 53 | 
            +
             | 
| 54 | 
            +
            function isElectron() {
         | 
| 55 | 
            +
              return 'type' in globalThis.process;
         | 
| 56 | 
            +
            }
         | 
| @@ -0,0 +1,169 @@ | |
| 1 | 
            +
            import { IOType } from 'node:child_process';
         | 
| 2 | 
            +
            import { Stream } from 'node:stream';
         | 
| 3 | 
            +
            import { z } from 'zod';
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            declare const JSONRPCMessageSchema: z.ZodUnion<[z.ZodObject<z.objectUtil.extendShape<{
         | 
| 6 | 
            +
                jsonrpc: z.ZodLiteral<"2.0">;
         | 
| 7 | 
            +
                id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
         | 
| 8 | 
            +
            }, {
         | 
| 9 | 
            +
                method: z.ZodString;
         | 
| 10 | 
            +
                params: z.ZodOptional<z.ZodObject<{
         | 
| 11 | 
            +
                    _meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
         | 
| 12 | 
            +
                }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
         | 
| 13 | 
            +
                    _meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
         | 
| 14 | 
            +
                }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
         | 
| 15 | 
            +
                    _meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
         | 
| 16 | 
            +
                }, z.ZodTypeAny, "passthrough">>>;
         | 
| 17 | 
            +
            }>, "strict", z.ZodTypeAny, {
         | 
| 18 | 
            +
                method: string;
         | 
| 19 | 
            +
                jsonrpc: "2.0";
         | 
| 20 | 
            +
                id: string | number;
         | 
| 21 | 
            +
                params?: z.objectOutputType<{
         | 
| 22 | 
            +
                    _meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
         | 
| 23 | 
            +
                }, z.ZodTypeAny, "passthrough"> | undefined;
         | 
| 24 | 
            +
            }, {
         | 
| 25 | 
            +
                method: string;
         | 
| 26 | 
            +
                jsonrpc: "2.0";
         | 
| 27 | 
            +
                id: string | number;
         | 
| 28 | 
            +
                params?: z.objectInputType<{
         | 
| 29 | 
            +
                    _meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
         | 
| 30 | 
            +
                }, z.ZodTypeAny, "passthrough"> | undefined;
         | 
| 31 | 
            +
            }>, z.ZodObject<z.objectUtil.extendShape<{
         | 
| 32 | 
            +
                jsonrpc: z.ZodLiteral<"2.0">;
         | 
| 33 | 
            +
            }, {
         | 
| 34 | 
            +
                method: z.ZodString;
         | 
| 35 | 
            +
                params: z.ZodOptional<z.ZodObject<{
         | 
| 36 | 
            +
                    _meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
         | 
| 37 | 
            +
                }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
         | 
| 38 | 
            +
                    _meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
         | 
| 39 | 
            +
                }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
         | 
| 40 | 
            +
                    _meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
         | 
| 41 | 
            +
                }, z.ZodTypeAny, "passthrough">>>;
         | 
| 42 | 
            +
            }>, "strict", z.ZodTypeAny, {
         | 
| 43 | 
            +
                method: string;
         | 
| 44 | 
            +
                jsonrpc: "2.0";
         | 
| 45 | 
            +
                params?: z.objectOutputType<{
         | 
| 46 | 
            +
                    _meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
         | 
| 47 | 
            +
                }, z.ZodTypeAny, "passthrough"> | undefined;
         | 
| 48 | 
            +
            }, {
         | 
| 49 | 
            +
                method: string;
         | 
| 50 | 
            +
                jsonrpc: "2.0";
         | 
| 51 | 
            +
                params?: z.objectInputType<{
         | 
| 52 | 
            +
                    _meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
         | 
| 53 | 
            +
                }, z.ZodTypeAny, "passthrough"> | undefined;
         | 
| 54 | 
            +
            }>, z.ZodObject<{
         | 
| 55 | 
            +
                jsonrpc: z.ZodLiteral<"2.0">;
         | 
| 56 | 
            +
                id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
         | 
| 57 | 
            +
                result: z.ZodObject<{
         | 
| 58 | 
            +
                    _meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
         | 
| 59 | 
            +
                }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
         | 
| 60 | 
            +
                    _meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
         | 
| 61 | 
            +
                }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
         | 
| 62 | 
            +
                    _meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
         | 
| 63 | 
            +
                }, z.ZodTypeAny, "passthrough">>;
         | 
| 64 | 
            +
            }, "strict", z.ZodTypeAny, {
         | 
| 65 | 
            +
                result: {
         | 
| 66 | 
            +
                    _meta?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
         | 
| 67 | 
            +
                } & {
         | 
| 68 | 
            +
                    [k: string]: unknown;
         | 
| 69 | 
            +
                };
         | 
| 70 | 
            +
                jsonrpc: "2.0";
         | 
| 71 | 
            +
                id: string | number;
         | 
| 72 | 
            +
            }, {
         | 
| 73 | 
            +
                result: {
         | 
| 74 | 
            +
                    _meta?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
         | 
| 75 | 
            +
                } & {
         | 
| 76 | 
            +
                    [k: string]: unknown;
         | 
| 77 | 
            +
                };
         | 
| 78 | 
            +
                jsonrpc: "2.0";
         | 
| 79 | 
            +
                id: string | number;
         | 
| 80 | 
            +
            }>, z.ZodObject<{
         | 
| 81 | 
            +
                jsonrpc: z.ZodLiteral<"2.0">;
         | 
| 82 | 
            +
                id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
         | 
| 83 | 
            +
                error: z.ZodObject<{
         | 
| 84 | 
            +
                    code: z.ZodNumber;
         | 
| 85 | 
            +
                    message: z.ZodString;
         | 
| 86 | 
            +
                    data: z.ZodOptional<z.ZodUnknown>;
         | 
| 87 | 
            +
                }, "strip", z.ZodTypeAny, {
         | 
| 88 | 
            +
                    code: number;
         | 
| 89 | 
            +
                    message: string;
         | 
| 90 | 
            +
                    data?: unknown;
         | 
| 91 | 
            +
                }, {
         | 
| 92 | 
            +
                    code: number;
         | 
| 93 | 
            +
                    message: string;
         | 
| 94 | 
            +
                    data?: unknown;
         | 
| 95 | 
            +
                }>;
         | 
| 96 | 
            +
            }, "strict", z.ZodTypeAny, {
         | 
| 97 | 
            +
                error: {
         | 
| 98 | 
            +
                    code: number;
         | 
| 99 | 
            +
                    message: string;
         | 
| 100 | 
            +
                    data?: unknown;
         | 
| 101 | 
            +
                };
         | 
| 102 | 
            +
                jsonrpc: "2.0";
         | 
| 103 | 
            +
                id: string | number;
         | 
| 104 | 
            +
            }, {
         | 
| 105 | 
            +
                error: {
         | 
| 106 | 
            +
                    code: number;
         | 
| 107 | 
            +
                    message: string;
         | 
| 108 | 
            +
                    data?: unknown;
         | 
| 109 | 
            +
                };
         | 
| 110 | 
            +
                jsonrpc: "2.0";
         | 
| 111 | 
            +
                id: string | number;
         | 
| 112 | 
            +
            }>]>;
         | 
| 113 | 
            +
            type JSONRPCMessage = z.infer<typeof JSONRPCMessageSchema>;
         | 
| 114 | 
            +
             | 
| 115 | 
            +
            /**
         | 
| 116 | 
            +
             * Transport interface for MCP (Model Context Protocol) communication.
         | 
| 117 | 
            +
             * Maps to the `Transport` interface in the MCP spec.
         | 
| 118 | 
            +
             */
         | 
| 119 | 
            +
            interface MCPTransport {
         | 
| 120 | 
            +
                /**
         | 
| 121 | 
            +
                 * Initialize and start the transport
         | 
| 122 | 
            +
                 */
         | 
| 123 | 
            +
                start(): Promise<void>;
         | 
| 124 | 
            +
                /**
         | 
| 125 | 
            +
                 * Send a JSON-RPC message through the transport
         | 
| 126 | 
            +
                 * @param message The JSON-RPC message to send
         | 
| 127 | 
            +
                 */
         | 
| 128 | 
            +
                send(message: JSONRPCMessage): Promise<void>;
         | 
| 129 | 
            +
                /**
         | 
| 130 | 
            +
                 * Clean up and close the transport
         | 
| 131 | 
            +
                 */
         | 
| 132 | 
            +
                close(): Promise<void>;
         | 
| 133 | 
            +
                /**
         | 
| 134 | 
            +
                 * Event handler for transport closure
         | 
| 135 | 
            +
                 */
         | 
| 136 | 
            +
                onclose?: () => void;
         | 
| 137 | 
            +
                /**
         | 
| 138 | 
            +
                 * Event handler for transport errors
         | 
| 139 | 
            +
                 */
         | 
| 140 | 
            +
                onerror?: (error: Error) => void;
         | 
| 141 | 
            +
                /**
         | 
| 142 | 
            +
                 * Event handler for received messages
         | 
| 143 | 
            +
                 */
         | 
| 144 | 
            +
                onmessage?: (message: JSONRPCMessage) => void;
         | 
| 145 | 
            +
            }
         | 
| 146 | 
            +
             | 
| 147 | 
            +
            interface StdioConfig {
         | 
| 148 | 
            +
                command: string;
         | 
| 149 | 
            +
                args?: string[];
         | 
| 150 | 
            +
                env?: Record<string, string>;
         | 
| 151 | 
            +
                stderr?: IOType | Stream | number;
         | 
| 152 | 
            +
                cwd?: string;
         | 
| 153 | 
            +
            }
         | 
| 154 | 
            +
            declare class StdioMCPTransport implements MCPTransport {
         | 
| 155 | 
            +
                private process?;
         | 
| 156 | 
            +
                private abortController;
         | 
| 157 | 
            +
                private readBuffer;
         | 
| 158 | 
            +
                private serverParams;
         | 
| 159 | 
            +
                onclose?: () => void;
         | 
| 160 | 
            +
                onerror?: (error: unknown) => void;
         | 
| 161 | 
            +
                onmessage?: (message: JSONRPCMessage) => void;
         | 
| 162 | 
            +
                constructor(server: StdioConfig);
         | 
| 163 | 
            +
                start(): Promise<void>;
         | 
| 164 | 
            +
                private processReadBuffer;
         | 
| 165 | 
            +
                close(): Promise<void>;
         | 
| 166 | 
            +
                send(message: JSONRPCMessage): Promise<void>;
         | 
| 167 | 
            +
            }
         | 
| 168 | 
            +
             | 
| 169 | 
            +
            export { StdioMCPTransport as Experimental_StdioMCPTransport, StdioConfig };
         | 
| @@ -0,0 +1,169 @@ | |
| 1 | 
            +
            import { IOType } from 'node:child_process';
         | 
| 2 | 
            +
            import { Stream } from 'node:stream';
         | 
| 3 | 
            +
            import { z } from 'zod';
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            declare const JSONRPCMessageSchema: z.ZodUnion<[z.ZodObject<z.objectUtil.extendShape<{
         | 
| 6 | 
            +
                jsonrpc: z.ZodLiteral<"2.0">;
         | 
| 7 | 
            +
                id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
         | 
| 8 | 
            +
            }, {
         | 
| 9 | 
            +
                method: z.ZodString;
         | 
| 10 | 
            +
                params: z.ZodOptional<z.ZodObject<{
         | 
| 11 | 
            +
                    _meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
         | 
| 12 | 
            +
                }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
         | 
| 13 | 
            +
                    _meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
         | 
| 14 | 
            +
                }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
         | 
| 15 | 
            +
                    _meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
         | 
| 16 | 
            +
                }, z.ZodTypeAny, "passthrough">>>;
         | 
| 17 | 
            +
            }>, "strict", z.ZodTypeAny, {
         | 
| 18 | 
            +
                method: string;
         | 
| 19 | 
            +
                jsonrpc: "2.0";
         | 
| 20 | 
            +
                id: string | number;
         | 
| 21 | 
            +
                params?: z.objectOutputType<{
         | 
| 22 | 
            +
                    _meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
         | 
| 23 | 
            +
                }, z.ZodTypeAny, "passthrough"> | undefined;
         | 
| 24 | 
            +
            }, {
         | 
| 25 | 
            +
                method: string;
         | 
| 26 | 
            +
                jsonrpc: "2.0";
         | 
| 27 | 
            +
                id: string | number;
         | 
| 28 | 
            +
                params?: z.objectInputType<{
         | 
| 29 | 
            +
                    _meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
         | 
| 30 | 
            +
                }, z.ZodTypeAny, "passthrough"> | undefined;
         | 
| 31 | 
            +
            }>, z.ZodObject<z.objectUtil.extendShape<{
         | 
| 32 | 
            +
                jsonrpc: z.ZodLiteral<"2.0">;
         | 
| 33 | 
            +
            }, {
         | 
| 34 | 
            +
                method: z.ZodString;
         | 
| 35 | 
            +
                params: z.ZodOptional<z.ZodObject<{
         | 
| 36 | 
            +
                    _meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
         | 
| 37 | 
            +
                }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
         | 
| 38 | 
            +
                    _meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
         | 
| 39 | 
            +
                }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
         | 
| 40 | 
            +
                    _meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
         | 
| 41 | 
            +
                }, z.ZodTypeAny, "passthrough">>>;
         | 
| 42 | 
            +
            }>, "strict", z.ZodTypeAny, {
         | 
| 43 | 
            +
                method: string;
         | 
| 44 | 
            +
                jsonrpc: "2.0";
         | 
| 45 | 
            +
                params?: z.objectOutputType<{
         | 
| 46 | 
            +
                    _meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
         | 
| 47 | 
            +
                }, z.ZodTypeAny, "passthrough"> | undefined;
         | 
| 48 | 
            +
            }, {
         | 
| 49 | 
            +
                method: string;
         | 
| 50 | 
            +
                jsonrpc: "2.0";
         | 
| 51 | 
            +
                params?: z.objectInputType<{
         | 
| 52 | 
            +
                    _meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
         | 
| 53 | 
            +
                }, z.ZodTypeAny, "passthrough"> | undefined;
         | 
| 54 | 
            +
            }>, z.ZodObject<{
         | 
| 55 | 
            +
                jsonrpc: z.ZodLiteral<"2.0">;
         | 
| 56 | 
            +
                id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
         | 
| 57 | 
            +
                result: z.ZodObject<{
         | 
| 58 | 
            +
                    _meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
         | 
| 59 | 
            +
                }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
         | 
| 60 | 
            +
                    _meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
         | 
| 61 | 
            +
                }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
         | 
| 62 | 
            +
                    _meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
         | 
| 63 | 
            +
                }, z.ZodTypeAny, "passthrough">>;
         | 
| 64 | 
            +
            }, "strict", z.ZodTypeAny, {
         | 
| 65 | 
            +
                result: {
         | 
| 66 | 
            +
                    _meta?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
         | 
| 67 | 
            +
                } & {
         | 
| 68 | 
            +
                    [k: string]: unknown;
         | 
| 69 | 
            +
                };
         | 
| 70 | 
            +
                jsonrpc: "2.0";
         | 
| 71 | 
            +
                id: string | number;
         | 
| 72 | 
            +
            }, {
         | 
| 73 | 
            +
                result: {
         | 
| 74 | 
            +
                    _meta?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
         | 
| 75 | 
            +
                } & {
         | 
| 76 | 
            +
                    [k: string]: unknown;
         | 
| 77 | 
            +
                };
         | 
| 78 | 
            +
                jsonrpc: "2.0";
         | 
| 79 | 
            +
                id: string | number;
         | 
| 80 | 
            +
            }>, z.ZodObject<{
         | 
| 81 | 
            +
                jsonrpc: z.ZodLiteral<"2.0">;
         | 
| 82 | 
            +
                id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
         | 
| 83 | 
            +
                error: z.ZodObject<{
         | 
| 84 | 
            +
                    code: z.ZodNumber;
         | 
| 85 | 
            +
                    message: z.ZodString;
         | 
| 86 | 
            +
                    data: z.ZodOptional<z.ZodUnknown>;
         | 
| 87 | 
            +
                }, "strip", z.ZodTypeAny, {
         | 
| 88 | 
            +
                    code: number;
         | 
| 89 | 
            +
                    message: string;
         | 
| 90 | 
            +
                    data?: unknown;
         | 
| 91 | 
            +
                }, {
         | 
| 92 | 
            +
                    code: number;
         | 
| 93 | 
            +
                    message: string;
         | 
| 94 | 
            +
                    data?: unknown;
         | 
| 95 | 
            +
                }>;
         | 
| 96 | 
            +
            }, "strict", z.ZodTypeAny, {
         | 
| 97 | 
            +
                error: {
         | 
| 98 | 
            +
                    code: number;
         | 
| 99 | 
            +
                    message: string;
         | 
| 100 | 
            +
                    data?: unknown;
         | 
| 101 | 
            +
                };
         | 
| 102 | 
            +
                jsonrpc: "2.0";
         | 
| 103 | 
            +
                id: string | number;
         | 
| 104 | 
            +
            }, {
         | 
| 105 | 
            +
                error: {
         | 
| 106 | 
            +
                    code: number;
         | 
| 107 | 
            +
                    message: string;
         | 
| 108 | 
            +
                    data?: unknown;
         | 
| 109 | 
            +
                };
         | 
| 110 | 
            +
                jsonrpc: "2.0";
         | 
| 111 | 
            +
                id: string | number;
         | 
| 112 | 
            +
            }>]>;
         | 
| 113 | 
            +
            type JSONRPCMessage = z.infer<typeof JSONRPCMessageSchema>;
         | 
| 114 | 
            +
             | 
| 115 | 
            +
            /**
         | 
| 116 | 
            +
             * Transport interface for MCP (Model Context Protocol) communication.
         | 
| 117 | 
            +
             * Maps to the `Transport` interface in the MCP spec.
         | 
| 118 | 
            +
             */
         | 
| 119 | 
            +
            interface MCPTransport {
         | 
| 120 | 
            +
                /**
         | 
| 121 | 
            +
                 * Initialize and start the transport
         | 
| 122 | 
            +
                 */
         | 
| 123 | 
            +
                start(): Promise<void>;
         | 
| 124 | 
            +
                /**
         | 
| 125 | 
            +
                 * Send a JSON-RPC message through the transport
         | 
| 126 | 
            +
                 * @param message The JSON-RPC message to send
         | 
| 127 | 
            +
                 */
         | 
| 128 | 
            +
                send(message: JSONRPCMessage): Promise<void>;
         | 
| 129 | 
            +
                /**
         | 
| 130 | 
            +
                 * Clean up and close the transport
         | 
| 131 | 
            +
                 */
         | 
| 132 | 
            +
                close(): Promise<void>;
         | 
| 133 | 
            +
                /**
         | 
| 134 | 
            +
                 * Event handler for transport closure
         | 
| 135 | 
            +
                 */
         | 
| 136 | 
            +
                onclose?: () => void;
         | 
| 137 | 
            +
                /**
         | 
| 138 | 
            +
                 * Event handler for transport errors
         | 
| 139 | 
            +
                 */
         | 
| 140 | 
            +
                onerror?: (error: Error) => void;
         | 
| 141 | 
            +
                /**
         | 
| 142 | 
            +
                 * Event handler for received messages
         | 
| 143 | 
            +
                 */
         | 
| 144 | 
            +
                onmessage?: (message: JSONRPCMessage) => void;
         | 
| 145 | 
            +
            }
         | 
| 146 | 
            +
             | 
| 147 | 
            +
            interface StdioConfig {
         | 
| 148 | 
            +
                command: string;
         | 
| 149 | 
            +
                args?: string[];
         | 
| 150 | 
            +
                env?: Record<string, string>;
         | 
| 151 | 
            +
                stderr?: IOType | Stream | number;
         | 
| 152 | 
            +
                cwd?: string;
         | 
| 153 | 
            +
            }
         | 
| 154 | 
            +
            declare class StdioMCPTransport implements MCPTransport {
         | 
| 155 | 
            +
                private process?;
         | 
| 156 | 
            +
                private abortController;
         | 
| 157 | 
            +
                private readBuffer;
         | 
| 158 | 
            +
                private serverParams;
         | 
| 159 | 
            +
                onclose?: () => void;
         | 
| 160 | 
            +
                onerror?: (error: unknown) => void;
         | 
| 161 | 
            +
                onmessage?: (message: JSONRPCMessage) => void;
         | 
| 162 | 
            +
                constructor(server: StdioConfig);
         | 
| 163 | 
            +
                start(): Promise<void>;
         | 
| 164 | 
            +
                private processReadBuffer;
         | 
| 165 | 
            +
                close(): Promise<void>;
         | 
| 166 | 
            +
                send(message: JSONRPCMessage): Promise<void>;
         | 
| 167 | 
            +
            }
         | 
| 168 | 
            +
             | 
| 169 | 
            +
            export { StdioMCPTransport as Experimental_StdioMCPTransport, StdioConfig };
         |