@juspay/neurolink
Version:
The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002
40 lines (39 loc) • 2.11 kB
TypeScript
/**
* URL policy for the network MCP transports (http, sse, websocket).
*
* An MCP server URL names where every tool call, and every configured
* header, is sent. Until this policy existed, nothing checked it: a project
* config could point a server at `http://169.254.169.254/` or at an
* attacker's plaintext host and the SDK would connect. The rules, in order:
*
* 1. The scheme is one of `https:`, `wss:`, `http:`, `ws:`.
* 2. A loopback host (`localhost`, `*.localhost`, `127.0.0.0/8`, `::1`) may
* use any of the four. Local development servers are the common case
* for plaintext and they never leave the machine.
* 3. Otherwise plaintext is refused, and a host that is — or resolves to —
* a private, link-local, CGNAT, multicast or cloud-metadata address is
* refused too, so a tool call cannot be turned into a request against
* the machine's own network.
* 4. `allowPrivateNetwork: true` on that server's config lifts rule 3 for
* private addresses, and lets plaintext reach them. A public host still
* needs TLS.
*
* `utils/ssrfGuard.ts` is deliberately not reused: it is HTTPS-only and treats
* loopback as blocked, which is right for a server fetching an untrusted URL
* and wrong for a client talking to a local MCP server.
*/
import type { McpTransportAddressClass, McpTransportUrlPolicyOptions } from "../types/index.js";
/**
* Classify one IP literal. Throws when `ip` is not an IP address at all, so a
* caller never silently treats a host name as public.
*/
export declare function classifyMcpTransportAddress(ip: string): McpTransportAddressClass;
/**
* Enforce the policy described in this module's header on `rawUrl`.
*
* Rejection is an `Error` whose message names the rule and, where one
* applies, the opt-out (`allowPrivateNetwork`). The URL itself is quoted so
* an operator can find the offending server entry; it never carries
* credentials, because `headers` are not part of the URL.
*/
export declare function assertMcpTransportUrlAllowed(rawUrl: string, options: McpTransportUrlPolicyOptions): Promise<void>;