import type { RequestHeaderBag } from '../types'; /** * Reads the HTTP request headers off the `extra` (v1) / `ctx` (v2) object the * MCP SDK hands a request handler, and returns them as a plain object with * lowercase keys. Returns `undefined` when the request did not come over HTTP — * stdio and in-memory transports carry no headers at all. * * The two SDK majors put them in different places and in different shapes: v1 * attaches a plain object at `extra.requestInfo.headers`, while v2 attaches the * WHATWG `Request` at `ctx.http.req`, whose `headers` is a `Headers` instance * that only answers to `.get()`. A v1-shaped read returns `undefined` on v2, * which is why this exists. * * Normalisation is **by shape, not by source**: a framework is free to hand us a * plain object where the SDK hands `Headers`, so both fields are checked for * both shapes. `Headers` is duck-typed on `.entries` rather than `instanceof` — * workerd and other edge runtimes are a different realm and would fail the * identity check on a perfectly good object. * * Exported from the package for host callbacks. `identify`, `intentFallback`, * `eventProperties` and `beforeSend` receive the SDK's `extra` unchanged — we * deliberately do not synthesise a v1 shape on v2, because a fabricated * `requestInfo` is a convincing partial lie about a shape the SDK removed on * purpose. So a host that reads headers reads them through this instead: * * ```ts * import { getRequestHeaders } from '@posthog/mcp' * * identify: async (request, extra) => { * const auth = getRequestHeaders(extra)?.['authorization'] * // ... * } * ``` */ export declare function getRequestHeaders(extra: unknown): RequestHeaderBag | undefined; //# sourceMappingURL=request-headers.d.ts.map