/**
* Resolve an npm package's bin entry script (the real .js/.mjs file, NOT the
* `node_modules/.bin` shim). `binName` selects which bin when a package exposes
* several; defaults to the package's sole/string bin. Returns an absolute path
* to the script, or null when the package or its bin can't be resolved.
*/
export declare function findPackageBinScript(pkgName: string, binName: string, start?: string): string | null;
/**
* Resolve a bare `npx`/`npm` into something Windows can actually spawn.
*
* Two Windows facts collide here, and the MCP SDK spawns stdio servers with
* `shell: false`, so both apply:
*
* 1. `CreateProcess` does not apply `PATHEXT`, so a bare `npx` is ENOENT —
* the real file is `npx.cmd`.
* 2. Since the CVE-2024-27980 fix, Node REFUSES to spawn a `.cmd`/`.bat` at
* all without `shell: true`, failing with EINVAL.
*
* So resolving `npx` → `npx.cmd` is necessary but NOT sufficient; the batch
* shim is a dead end, and using `shell: true` to get around it would re-open
* the command-injection hole the CVE fix closed. Instead map the shim to the
* Node CLI script it wraps (`
\node_modules\npm\bin\npx-cli.js`, the
* standard Windows Node layout) and run it with `process.execPath` — the same
* "never a shim, always the real script" pattern this module already uses for
* package bins.
*
* Returns null when nothing better than the original command can be found, so
* the caller passes through and fails exactly as it does today.
*/
export declare function resolveWindowsLauncher(command: string, env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform, exists?: (p: string) => boolean): {
command: string;
prefixArgs: string[];
} | null;
/**
* Resolve a bare command name to a real file on Windows by walking
* PATH × PATHEXT, which `CreateProcess` does not do for a shell-less spawn.
*
* No-op off Windows, for an already-extensioned name, or when nothing matches.
* The current directory is deliberately NOT searched — a stray `npx.cmd` in the
* project must not hijack the server.
*/
export declare function resolveWindowsExecutable(command: string, env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform, exists?: (p: string) => boolean): string;
/**
* Parse an `npx`/`npm exec` command + args into the target package spec, or null
* when the command isn't an npx/npm-exec invocation. Skips npx flags (`-y`,
* `--yes`, `-p `, `--package `, `--`) to find the package positional.
* The returned `pkg` keeps any leading `@scope/name`; a trailing `@version` is
* stripped for resolution since the installed copy's version is authoritative.
*/
export declare function parseNpxPackage(command: string, args: readonly string[]): string | null;
/**
* Resolve a package's real bin script from npx's on-demand cache. This is where
* `npx -y ` installs a server on first run, so from the SECOND launch
* onward we can spawn the real bin directly with `process.execPath` and skip
* npx's ~90 MB `npm exec` wrapper — for ANY package, including user-added MCP
* servers we don't (and can't) bundle.
*
* `versionPin` (from a `@x.y.z` spec) is honoured strictly: a cached copy
* is used only when its `package.json` version matches exactly, so a pin never
* silently resolves to the wrong cached version (it falls through to npx, which
* resolves the pin correctly). Unpinned specs take the highest cached version.
* Deterministic fs reads only — no resolver hooks.
*/
export declare function findNpxCachedBinScript(pkgName: string, binName: string, versionPin?: string): string | null;
export interface ResolvedStdioCommand {
command: string;
args: string[];
}
/**
* Rewrite a stdio `{ command, args }` to a direct `node ` invocation
* when it's an `npx`/`npm exec` of a package whose bin script is resolvable
* either from ggcoder's install (bundled/dep) OR from npx's on-demand cache
* (`~/.npm/_npx/...`, populated on the package's first run). Returns the
* original `{ command, args }` unchanged otherwise (non-npx command, or the
* package isn't cached yet — the true first run, which npx then installs).
*/
export declare function resolveStdioCommand(command: string, args?: readonly string[]): ResolvedStdioCommand;
//# sourceMappingURL=resolve-stdio.d.ts.map