UNPKG

@ai-sdk/mcp

Version:

The **Model Context Protocol (MCP) client** for the [AI SDK](https://ai-sdk.dev/docs) lets you connect to MCP servers and use their tools with AI SDK functions like `generateText` and `streamText`.

22 lines (19 loc) 619 B
import { spawn, type ChildProcess } from 'node:child_process'; import { getEnvironment } from './get-environment'; import type { StdioConfig } from './mcp-stdio-transport'; export function createChildProcess( config: StdioConfig, signal: AbortSignal, ): ChildProcess { return spawn(config.command, config.args ?? [], { env: getEnvironment(config.env), stdio: ['pipe', 'pipe', config.stderr ?? 'inherit'], shell: false, signal, windowsHide: globalThis.process.platform === 'win32' && isElectron(), cwd: config.cwd, }); } function isElectron() { return 'type' in globalThis.process; }