### get method usage example Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/postman-api-client.md Example of calling the get method to retrieve the current user's information. Logs the user ID from the response. ```typescript const me = await client.get('/me'); console.log(me.user.id); ``` -------------------------------- ### post method usage example Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/postman-api-client.md Example of calling the post method to create a workspace. Uses ContentType.Json and sends a JSON stringified body. ```typescript import { ContentType } from './clients/postman.js'; await client.post('/workspaces', { body: JSON.stringify({ workspace: { name: 'My Workspace', type: 'personal' } }), contentType: ContentType.Json, }); ``` -------------------------------- ### sessionInit usage example Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/telemetry-client.md Example call to sessionInit, passing the telemetry session and its client capabilities. The server capabilities are set to ['tools', 'resources'] as sent by this repo. ```typescript telemetry.sessionInit(telemetrySession, { clientCapabilities: telemetrySession.clientCapabilities, serverCapabilities: ['tools', 'resources'], }); ``` -------------------------------- ### Import path example Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/telemetry-utilities.md Shows how to import the telemetry utilities from the module. ```TypeScript import { createTelemetryClient, detectPaginationUsed, parseTelemetryFlag, TelemetrySession, type ITelemetryClient } from './telemetry/index.js'; import { generateSrvTrace } from './telemetry/srvTrace.js'; ``` -------------------------------- ### Loading install ID from disk Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/telemetry-session.md Example of calling loadOrCreateInstallIdFromDisk to get the persistent install ID. HTTP mode does not use this method. ```TypeScript const installId = TelemetrySession.loadOrCreateInstallIdFromDisk(); ``` -------------------------------- ### static loadOrCreateInstallIdFromDisk() Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/telemetry-session.md Reads the persistent install ID from disk, creating it with a fresh UUID if missing. Never throws. ```APIDOC ## static loadOrCreateInstallIdFromDisk() ### Description Reads the persistent install ID from `~/.postman/mcp-telemetry-id`, creating the file with a fresh UUID if missing. Best-effort; failures fall back to an ephemeral UUID. HTTP mode does not use this. ### Method `static loadOrCreateInstallIdFromDisk(): string` ### Returns - **string** - The install ID. ### Throws - Never; all filesystem failures are caught. ### Example ```ts const installId = TelemetrySession.loadOrCreateInstallIdFromDisk(); ``` ``` -------------------------------- ### createTelemetryClient usage example Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/telemetry-utilities.md Example of creating a telemetry client with telemetryEnabled parsed from the POSTMAN_MCP_TELEMETRY environment variable and an apiKey. ```TypeScript const telemetry: ITelemetryClient = createTelemetryClient({ telemetryEnabled: parseTelemetryFlag(process.env.POSTMAN_MCP_TELEMETRY) ?? false, apiKey, }); ``` -------------------------------- ### PostmanAPIClient usage example Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/postman-api-client.md Shows how to instantiate PostmanAPIClient with a server context and trace ID, as done in src/index.ts for every tool call. ```TypeScript import { PostmanAPIClient } from './clients/postman.js'; import { ServerContext } from './tools/utils/toolHelpers.js'; const serverContext: ServerContext = { serverType: 'minimal', availableTools: ['getCollection', 'getWorkspaces'], }; const client = new PostmanAPIClient('PMAK-xxxx', undefined, serverContext, 'v=1;t=0123456789abcdef'); ``` -------------------------------- ### Set up and verify the postman-mcp-server development environment Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/CONTRIBUTING.md Clone the repository, install dependencies with pnpm, and run type checking, linting, and unit tests. Unit tests do not require a Postman API key. Avoid running pnpm build for contributions because it compiles into dist/ and creates a large diff. ```bash git clone https://github.com/postmanlabs/postman-mcp-server.git cd postman-mcp-server pnpm install pnpm typecheck # tsc --noEmit pnpm lint # eslint pnpm test:unit # unit tests — no API key needed ``` -------------------------------- ### get method error handling example Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/postman-api-client.md Example of error handling for the get method. Catches McpError, extracts httpStatus and cause from error.data, and logs them. A 404 results in an InternalError code. ```typescript import { McpError } from '@modelcontextprotocol/sdk/types.js'; try { await client.get('/workspaces/no-such-id'); } catch (err) { if (err instanceof McpError) { const { httpStatus, cause } = err.data as { httpStatus?: number; cause?: string }; // 404 → McpError with InternalError code; cause contains the raw body console.error(httpStatus, cause); } } ``` -------------------------------- ### Creating a TelemetrySession instance Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/telemetry-session.md Example of constructing a TelemetrySession with required options. Uses loadOrCreateInstallIdFromDisk for installId and sets region, transport, toolset, and serverVersion. ```TypeScript const session = new TelemetrySession({ installId: TelemetrySession.loadOrCreateInstallIdFromDisk(), region: 'us', transport: 'stdio', toolset: 'minimal', serverVersion: '2.13.0', }); ``` -------------------------------- ### Template example: src/views/getCollections.njk Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/template-renderers.md Example Nunjucks template for the getCollections tool. It renders a header, meta information, and a table of collections using a for loop. The `dump` filter is used for the fork field. ```njk # Collections ## Meta - **total**: {{ meta.total }} - **offset**: {{ meta.offset }} - **limit**: {{ meta.limit }} | id | name | owner | createdAt | updatedAt | uid | fork | isPublic | |---|---|---|---|---|---|---|---| {% for item in collections %}| {{ item.id }} | {{ item.name }} | {{ item.owner }} | {{ item.createdAt }} | {{ item.updatedAt }} | {{ item.uid }} | {{ item.fork | dump }} | {{ item.isPublic }} | {% endfor %} ``` -------------------------------- ### Template example: src/views/errors/getWorkspace.404.njk Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/template-renderers.md Example Nunjucks error template for the getWorkspace tool with a 404 status. It displays the workspace ID from args, optionally shows API detail from the error object, and includes a verification message. ```njk Workspace not found: {{ args.workspaceId }} {% if error and (error.detail or error.message) %} API detail: {{ error.detail or error.message }} {% endif %} Verify the workspace ID is correct and that your API key has access to this workspace. ``` -------------------------------- ### runCollection usage example Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/collection-runner.md Example usage of runCollection with a collection ID, environment ID, and stopOnFailure flag. The returned output is wrapped in a text content block. ```ts const output = await runCollection( { collectionId: '12345-33823532ab9e41c9b6fd12d0fd459b8b', environmentId: 'env-uuid', stopOnFailure: true }, client, progress ); return { content: [{ type: 'text', text: output }] }; ``` -------------------------------- ### detectPaginationUsed usage examples Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/telemetry-utilities.md Examples showing detection of pagination: offset greater than 0 returns true, empty cursor returns false. ```TypeScript detectPaginationUsed({ offset: 25 }); // true detectPaginationUsed({ cursor: '' }); // false ``` -------------------------------- ### Using createTemplateRenderer in src/index.ts Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/template-renderers.md Usage example from src/index.ts showing how to create the renderer and apply it to the text content of every tool result. If rendering succeeds, it returns the rendered text; otherwise it falls through. ```ts // src/index.ts — applied to the text content of every tool result: const viewsDir = join(__dirname, './views'); const renderTemplate = createTemplateRenderer(viewsDir); if (result.content?.[0]?.type === 'text') { const rendered = renderTemplate(toolName, result.content[0].text); if (rendered) { return { content: [{ type: 'text', text: rendered }] }; } } ``` -------------------------------- ### toolCall usage example Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/telemetry-client.md Example call to toolCall with a sample ToolCallParams object. It does not throw on event construction; ingest failures are swallowed by flush. ```typescript telemetry.toolCall(session, { toolName: 'getCollections', args: { workspace: 'abc' }, result: { content: [{ type: 'text', text: '…' }] }, latencyMs: 842, isError: false, authMethod: 'api_key', paginationUsed: true, srvTraceId: 'v=1;t=0123456789abcdef', }); ``` -------------------------------- ### generateSrvTrace usage example Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/telemetry-utilities.md Example of generating a trace ID, e.g., v=1;t=3f6a9c1b2d4e5f80. ```TypeScript const traceId = generateSrvTrace(); // e.g. v=1;t=3f6a9c1b2d4e5f80 ``` -------------------------------- ### Run Postman MCP Server Docker image (minimal and full modes) Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/DOCKER.md Runs the locally built Postman MCP Server image. The minimal command starts the server with default settings; the full command enables the full feature set. Replace $YOUR-POSTMAN-API-KEY with your Postman API key. ```bash docker run -i -e POSTMAN_API_KEY="" postman-api-mcp-stdio ``` ```bash docker run -i -e POSTMAN_API_KEY="" postman-api-mcp-stdio --full ``` -------------------------------- ### Serializing and restoring a session Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/telemetry-session.md Example of serializing a session to JSON and restoring it with fromSerialized, useful for cross-pod persistence. ```TypeScript const json = JSON.stringify(session.serialize()); // … across pods … const restored = TelemetrySession.fromSerialized(JSON.parse(json)); ``` -------------------------------- ### parseTelemetryFlag usage example Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/telemetry-utilities.md Example of parsing the telemetry flag with a fallback to false when undefined. ```TypeScript const telemetryEnabled = parseTelemetryFlag(process.env.POSTMAN_MCP_TELEMETRY) ?? false; ``` -------------------------------- ### patch method usage example with JSON Patch Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/postman-api-client.md Example of calling the patch method with ContentType.JsonPatch to send patch operations to an environment. ```typescript await client.patch(`/environments/${environmentId}`, { body: JSON.stringify(patchOperations), contentType: ContentType.JsonPatch, }); ``` -------------------------------- ### Set custom HTTP agent provider Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/collection-runner.md Example of setting a custom HTTP agent provider. Imports setRequestAgentsProvider from './tools/runner/agents.js' and passes a function that returns an object with a custom http agent. ```typescript import { setRequestAgentsProvider } from './tools/runner/agents.js'; setRequestAgentsProvider(() => ({ http: customHttpAgent })); ``` -------------------------------- ### Build Postman MCP Server Docker image manually Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/DOCKER.md Builds the Postman MCP Server image locally using the Dockerfile in the current directory. Run this before using the docker run commands for manual setup. ```bash docker build -t postman-api-mcp-stdio . ``` -------------------------------- ### loadOrCreateInstallIdFromDisk signature Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/telemetry-session.md Signature for static loadOrCreateInstallIdFromDisk. Reads persistent install id from ~/.postman/mcp-telemetry-id, creating it with a fresh UUID if missing. Never throws; falls back to ephemeral UUID on failure. ```TypeScript static loadOrCreateInstallIdFromDisk(): string ``` -------------------------------- ### get /baseUrl Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/postman-api-client.md Issues an HTTP GET request to the specified endpoint appended to the base URL. Returns parsed JSON for JSON responses, raw text otherwise, and null for HTTP 204. Throws McpError on non-2xx responses. ```APIDOC ## GET /{endpoint} ### Description Issues an HTTP GET against `${baseUrl}${endpoint}`. Returns the parsed JSON body for `application/json` responses, raw text otherwise, and `null` for HTTP 204. Throws `McpError` on non-2xx responses. ### Method GET ### Endpoint `{baseUrl}{endpoint}` ### Parameters #### Path Parameters - **endpoint** (string) - Required - Path appended to `baseUrl`, e.g. `/collections/{id}`. #### Query Parameters - **options** (Omit) - Optional - Headers, `contentType`, and any remaining `RequestInit` fields (minus `method`/`body`). Defaults to `{}`. ### Response #### Success Response (200) - Returns `Promise` - Parsed JSON body for `application/json` responses, raw text otherwise, and `null` for HTTP 204. Set `T` to `any` or an interface describing the Postman API payload. #### Error Response - `McpError` (`ErrorCode.InvalidParams`) - Upstream status 400, 401, 403, or 422. `error.data = { cause, httpStatus }`. - `McpError` (`ErrorCode.InternalError`) - Any other non-2xx upstream status or missing API key. `error.data = { cause, httpStatus }`. ### Example ```ts const me = await client.get('/me'); console.log(me.user.id); ``` ``` -------------------------------- ### Import TelemetrySession from index and session module Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/telemetry-session.md Use the first import to get the TelemetrySession class from the package's index re-export. Use the second import to also bring in the TelemetrySessionOptions type from the session module directly. ```typescript import { TelemetrySession } from './telemetry/index.js'; // re-exported import { TelemetrySession, type TelemetrySessionOptions } from './telemetry/session.js'; ``` -------------------------------- ### get method signature Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/postman-api-client.md Signature for the get method. Issues an HTTP GET against `${baseUrl}${endpoint}`. Returns a Promise that resolves to the parsed JSON body for application/json responses, raw text otherwise, and null for HTTP 204. Throws McpError with InvalidParams for statuses 400, 401, 403, 422, and InternalError for other non-2xx statuses or missing API key. ```typescript async get(endpoint: string, options: Omit = {}): Promise ``` -------------------------------- ### Using createErrorTemplateRenderer in src/index.ts Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/template-renderers.md Usage example from src/index.ts showing how to create the error renderer and use it when an McpError carries numeric httpStatus data. If rendering succeeds, it throws a new McpError with the rendered message. ```ts // src/index.ts — called when an McpError carries numeric httpStatus data: const errorsDir = join(__dirname, './views/errors'); const renderErrorTemplate = createErrorTemplateRenderer(errorsDir); const rendered = renderErrorTemplate(toolName, httpStatus, { toolName, statusCode: httpStatus, args, errorMessage: error.message, errorBody: rawBody, error: errorObj, // unwrapped { error: {...} } API response body, if any }); if (rendered) { throw new McpError(error.code, rendered, error.data); } ``` -------------------------------- ### TelemetrySessionOptions interface Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/telemetry-session.md Defines the configuration options for a TelemetrySession. Includes required fields for install ID, region, transport, toolset, and server version, with optional fields for session IDs, client info, and tool metadata. The installId is caller-supplied, and sessionId defaults to a fresh UUID unless explicitly provided for stability during reconstruction. ```typescript export interface TelemetrySessionOptions { /** Anonymous install identifier. Per-process for stdio (FS-persisted), * per-MCP-session for HTTP (freshly generated). Caller supplies it. */ installId: string; /** MCP protocol session id from the `Mcp-Session-Id` header. Undefined for * stdio. Used as the Redis key for cross-pod hydration in HTTP mode. */ mcpSessionId?: string; /** Telemetry session id (the value emitted as `session_id` in events). * Defaults to a fresh UUID; pass explicitly to keep it stable when * reconstructing a TelemetrySession from Redis on another pod. */ sessionId?: string; region: 'us' | 'eu'; transport: 'stdio' | 'http' | 'sse'; toolset: 'full' | 'minimal' | 'code' | 'learn' | 'contextGraph'; serverVersion: string; clientName?: string; clientVersion?: string; protocolVersion?: string; clientCapabilities?: string[]; toolsetSnapshotId?: string; toolListCount?: number; } ``` -------------------------------- ### Explicit progress reporting in a long tool Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/progress-reporter.md Example of explicit progress reporting inside a long tool, as done by runCollection. It reports progress with a message, performs work, and then sends a heartbeat. ```typescript await progress.report(1, undefined, 'fetching collection'); const collection = await fetchCollection(params.collectionId, client); await progress.heartbeat('fetching environment'); ``` -------------------------------- ### Build and run the server locally (STDIO) Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/CONTRIBUTING.md Build the project and run the STDIO server locally with the full toolset. Requires a Postman API key and a prior build because the published entry point is compiled output. ```bash pnpm build POSTMAN_API_KEY= node dist/src/index.js --full ``` -------------------------------- ### Local server startup command Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/README.md Run the local MCP server. Add --code or --full for Code or Full mode. Set POSTMAN_API_KEY as an environment variable. ```bash npx @postman/postman-mcp-server ``` -------------------------------- ### sessionInit(session: TelemetrySession, params: { clientCapabilities: string[]; serverCapabilities: string[] }): void Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/telemetry-client.md Emits a 'session_init' telemetry event with base fields plus toolset snapshot ID and tool list count. Enqueueing is synchronous and returns void. ```APIDOC ## sessionInit(session: TelemetrySession, params: { clientCapabilities: string[]; serverCapabilities: string[] }): void ### Description Emits one `session_init` event: base fields plus `toolset_snapshot_id` (`session.toolsetSnapshotId`) and `tool_list_count` (`session.getToolListCount()`). Returns `void`; enqueueing is synchronous. ### Parameters - **session** (`TelemetrySession`) - Required - The MCP session the event belongs to. - **params.clientCapabilities** (`string[]`) - Required - MCP capabilities advertised by the client. - **params.serverCapabilities** (`string[]`) - Required - MCP capabilities advertised by the server (this repo sends `['tools', 'resources']`). ### Returns `void` ### Example ```ts telemetry.sessionInit(telemetrySession, { clientCapabilities: telemetrySession.clientCapabilities, serverCapabilities: ['tools', 'resources'], }); ``` ``` -------------------------------- ### constructor(options: TelemetryClientOptions) Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/telemetry-client.md Creates a new TelemetryClient instance with the provided API key. The ingest table is hardcoded to 'mcp_telemetry_events'. ```APIDOC ## constructor(options: TelemetryClientOptions) ### Description Creates a new TelemetryClient instance. The ingest table is hardcoded to `mcp_telemetry_events`; customers cannot override it. ### Parameters - **options.apiKey** (`string`) - Required - API key for the ingest gateway (`x-api-key` header). ### Returns `TelemetryClient` instance. ``` -------------------------------- ### getInstance singleton usage Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/postman-api-client.md Demonstrates the singleton pattern: the first call creates the client, subsequent calls return the same object and ignore their arguments. ```TypeScript const client = PostmanAPIClient.getInstance('PMAK-xxxx'); const same = PostmanAPIClient.getInstance(); // same object ``` -------------------------------- ### Source directory structure Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/README.md Shows the project's source layout, including entry point, constants, environment validation, toolset definitions, HTTP client, telemetry modules, tool modules, and resources. ```text src/ index.ts entry point: CLI parsing, tool loading, MCP registration → api-reference/entry-point.md constants.ts SERVER_NAME, APP_VERSION, USER_AGENT, RUNNER_ACCEPT_HEADER → types.md env.ts validated process.env (zod) → configuration.md enabledResources.ts toolset definitions (full/minimal/code/learn/contextGraph) → api-reference/enabled-resources.md clients/postman.ts PostmanAPIClient HTTP client → api-reference/postman-api-client.md telemetry/ index.ts createTelemetryClient factory + re-exports → api-reference/telemetry-utilities.md client.ts TelemetryClient (buffering/flushing) → api-reference/telemetry-client.md session.ts TelemetrySession (per-MCP-session identity) → api-reference/telemetry-session.md noop.ts NoopTelemetryClient → api-reference/telemetry-client.md flag.ts / pagination.ts / srvTrace.ts helpers → api-reference/telemetry-utilities.md types.ts zod event schemas + error enums → types.md tools/ .ts 200+ tool modules (contract in ToolModule) → api-reference/tool-modules.md runner/ collection execution engine (newman) → api-reference/collection-runner.md utils/ toolHelpers.ts ServerContext, asMcpError, ToolAnnotations → api-reference/tool-modules.md progress.ts createProgressReporter → api-reference/progress-reporter.md templateRenderer.ts Nunjucks view rendering → api-reference/template-renderers.md errorTemplateRenderer.ts Nunjucks error-view rendering → api-reference/template-renderers.md getCollection/ orchestrator + subtools (getCollection, getCollectionMap) → api-reference/tool-modules.md resources/Instructions.md MCP resource content served at postman://instructions views/ .njk templates for getCollections / getWorkspaces + error views ``` -------------------------------- ### sessionInit method signature Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/telemetry-client.md Method signature for sessionInit. It emits a session_init event with base fields plus toolset_snapshot_id and tool_list_count. Enqueueing is synchronous and returns void. ```typescript sessionInit(session: TelemetrySession, params: { clientCapabilities: string[]; serverCapabilities: string[] }): void ``` -------------------------------- ### delete /baseUrl Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/postman-api-client.md Issues an HTTP DELETE request to the specified endpoint. Same contract as `get` (no body). ```APIDOC ## DELETE /{endpoint} ### Description Issues an HTTP DELETE request to the specified endpoint. Same contract as `get` (no body). ### Method DELETE ### Endpoint `{baseUrl}{endpoint}` ### Parameters #### Path Parameters - **endpoint** (string) - Required - Path appended to `baseUrl`. #### Query Parameters - **options** (Omit) - Optional - Headers, `contentType`, and any remaining `RequestInit` fields (minus `method`/`body`). Defaults to `{}`. ### Response #### Success Response (200) - Returns `Promise` - Parsed JSON body for `application/json` responses, raw text otherwise, and `null` for HTTP 204. Set `T` to `any` or an interface describing the Postman API payload. #### Error Response - Same error mapping as `get` (see `get` for details). ### Example ```ts await client.delete('/collections/{id}'); ``` ``` -------------------------------- ### Project layout Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/CONTRIBUTING.md Shows the project directory layout. Everything under src/ is synced; dist/ is compiled output and should never be edited or committed by hand. ```text src/ index.ts # STDIO server entrypoint tools/ # MCP tools clients/ # Postman API client resources/ # bundled instructions/resources telemetry/ # telemetry views/ # response templates tests/ # unit + integration tests dist/ # compiled output — never edit or commit by hand scripts/ # release tooling ``` -------------------------------- ### delete method signature Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/postman-api-client.md Signature for the delete method. HTTP DELETE. Same contract as get (no body). ```typescript async delete(endpoint: string, options: Omit = {}): Promise ``` -------------------------------- ### Toolset selection precedence Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/enabled-resources.md Shows the precedence order for selecting the toolset based on CLI flags. The default is minimal when no flag is provided. ```text --context-graph → enabledResources.contextGraph --learn → enabledResources.learn --code → enabledResources.code --full → enabledResources.full (none) → enabledResources.minimal ← default ``` -------------------------------- ### Run pre-push checks Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/CONTRIBUTING.md Run the project's lint, typecheck, and unit test suites before pushing. This is required by the pull request guidelines to ensure the code passes CI checks. ```bash pnpm lint && pnpm typecheck && pnpm test:unit ``` -------------------------------- ### buildTelemetryPayload Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/collection-runner.md Builds the full TelemetryPayload from the newman summary. ```APIDOC ## buildTelemetryPayload ### Description Builds the full TelemetryPayload from the newman summary. ### Function Signature ```ts export function buildTelemetryPayload( collectionId: string, collectionName: string, result: ExecutionResult ): TelemetryPayload ``` ### Parameters - **collectionId** (string) - Required - The ID of the collection. - **collectionName** (string) - Required - The name of the collection. - **result** (ExecutionResult) - Required - The execution result containing the newman summary. ### Returns - **TelemetryPayload** - The constructed telemetry payload. ### Notes - `collectionRun` uses fresh UUIDs for id and per-request execution ids via `uuidv4`; status hardcoded `'finished'`, source `'postman-cli'`, branch `env.GIT_BRANCH` with `branchSource: 'local'`. - `runOverview` statistics default to zero counts when the summary lacks a section; response times/data summed from `summary.run.executions`. ``` -------------------------------- ### PostmanAPIClient constructor signature Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/postman-api-client.md Creates a new client instance. The apiKey is optional; if omitted, it is resolved per-request from env.POSTMAN_API_KEY. baseUrl defaults to env.POSTMAN_API_BASE_URL (https://api.postman.com). ```TypeScript constructor( apiKey?: string, baseUrl: string = env.POSTMAN_API_BASE_URL, serverContext?: ServerContext, srvTraceId?: string ) ``` -------------------------------- ### IPostmanAPIClient interface definition Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/postman-api-client.md Defines the contract for the Postman API client with generic get, post, put, patch, and delete methods. Used to abstract HTTP operations against the Postman API. ```TypeScript export interface IPostmanAPIClient { get( endpoint: string, options?: Omit ): Promise; post(endpoint: string, options?: PostmanAPIRequestOptions): Promise; put(endpoint: string, options?: PostmanAPIRequestOptions): Promise; patch(endpoint: string, options?: PostmanAPIRequestOptions): Promise; delete( endpoint: string, options?: Omit ): Promise; } ``` -------------------------------- ### Importing progress reporter Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/progress-reporter.md Import path for the progress reporter utilities. ```typescript import { createProgressReporter, type ProgressReporter } from './tools/utils/progress.js'; ``` -------------------------------- ### TestTracker class definition Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/collection-runner.md Defines the TestTracker class with methods to add assertions, display current results, get total stats, and reset. Used to track test results during Newman runs. ```typescript export class TestTracker { addAssertion(assertion: TestResult): void; displayCurrentResults(): string; getTotalStats(): TestStatistics; reset(): void; } ``` -------------------------------- ### new TelemetrySession(options) Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/telemetry-session.md Creates a new TelemetrySession instance with default values applied for unspecified options. ```APIDOC ## new TelemetrySession(options) ### Description Creates a new TelemetrySession instance, applying default values for unspecified options. ### Constructor `new TelemetrySession(options: TelemetrySessionOptions)` ### Parameters - **options** (TelemetrySessionOptions) - Required - Options for the session. Defaults: `sessionId = randomUUID()`, strings → `''`, arrays → `[]`, counts → `0`. ### Example ```ts const session = new TelemetrySession({ installId: TelemetrySession.loadOrCreateInstallIdFromDisk(), region: 'us', transport: 'stdio', toolset: 'minimal', serverVersion: '2.13.0', }); ``` ``` -------------------------------- ### PostmanAPIClient Methods Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/postman-api-client.md Code snippets for the PostmanAPIClient class methods and constructor. ```APIDOC ## PostmanAPIClient.get ### Description Performs an HTTP GET request to the Postman API. The endpoint is appended verbatim to the base URL. ### Method GET ### Endpoint `{baseUrl}{endpoint}` ### Parameters #### Path Parameters - **endpoint** (string) - Required - The API endpoint path to request. #### Query Parameters - **options** (object) - Optional - Additional request options (excluding `method` and `body`). ### Response Returns a promise resolving to the response data of type `T`. ### Example ```ts const client = new PostmanAPIClient('PMAK-xxxx'); const data = await client.get('/collections'); ``` ``` ```APIDOC ## PostmanAPIClient.post ### Description Performs an HTTP POST request to the Postman API. The endpoint is appended verbatim to the base URL. ### Method POST ### Endpoint `{baseUrl}{endpoint}` ### Parameters #### Path Parameters - **endpoint** (string) - Required - The API endpoint path to request. #### Request Body - **options** (object) - Optional - Request options including `body` and other settings. ### Response Returns a promise resolving to the response data of type `T`. ### Example ```ts const client = new PostmanAPIClient('PMAK-xxxx'); const data = await client.post('/collections', { body: { name: 'My Collection' } }); ``` ``` ```APIDOC ## PostmanAPIClient.put ### Description Performs an HTTP PUT request to the Postman API. The endpoint is appended verbatim to the base URL. ### Method PUT ### Endpoint `{baseUrl}{endpoint}` ### Parameters #### Path Parameters - **endpoint** (string) - Required - The API endpoint path to request. #### Request Body - **options** (object) - Optional - Request options including `body` and other settings. ### Response Returns a promise resolving to the response data of type `T`. ### Example ```ts const client = new PostmanAPIClient('PMAK-xxxx'); const data = await client.put('/collections/123', { body: { name: 'Updated' } }); ``` ``` ```APIDOC ## PostmanAPIClient.patch ### Description Performs an HTTP PATCH request to the Postman API. The endpoint is appended verbatim to the base URL. ### Method PATCH ### Endpoint `{baseUrl}{endpoint}` ### Parameters #### Path Parameters - **endpoint** (string) - Required - The API endpoint path to request. #### Request Body - **options** (object) - Optional - Request options including `body` and other settings. ### Response Returns a promise resolving to the response data of type `T`. ### Example ```ts const client = new PostmanAPIClient('PMAK-xxxx'); const data = await client.patch('/collections/123', { body: { name: 'Patched' } }); ``` ``` ```APIDOC ## PostmanAPIClient.delete ### Description Performs an HTTP DELETE request to the Postman API. The endpoint is appended verbatim to the base URL. ### Method DELETE ### Endpoint `{baseUrl}{endpoint}` ### Parameters #### Path Parameters - **endpoint** (string) - Required - The API endpoint path to request. #### Query Parameters - **options** (object) - Optional - Additional request options (excluding `method` and `body`). ### Response Returns a promise resolving to the response data of type `T`. ### Example ```ts const client = new PostmanAPIClient('PMAK-xxxx'); const data = await client.delete('/collections/123'); ``` ``` ```APIDOC ## PostmanAPIClient.getInstance ### Description Returns the process-wide singleton `PostmanAPIClient`. The client is created once on the first call and reused thereafter; subsequent calls ignore their arguments. ### Method static ### Parameters - **apiKey** (string) - Optional - Used only when the singleton does not exist yet. - **baseUrl** (string) - Optional - Used only when the singleton does not exist yet. ### Returns Returns the singleton `PostmanAPIClient` instance. ### Example ```ts const client = PostmanAPIClient.getInstance('PMAK-xxxx'); const same = PostmanAPIClient.getInstance(); // same object ``` ``` ```APIDOC ## PostmanAPIClient.resetInstance ### Description Resets the singleton to `null`, so the next `getInstance()` creates a fresh client. Useful for testing or reconfiguration. ### Method static ### Parameters None. ### Returns Void. ### Example ```ts PostmanAPIClient.resetInstance(); ``` ``` ```APIDOC ## PostmanAPIClient.constructor ### Description Creates a new `PostmanAPIClient` instance. The API key can be provided here or resolved from the environment variable `POSTMAN_API_KEY` per request. ### Parameters - **apiKey** (string) - Optional - Postman API key. If omitted, the key is resolved per-request from `env.POSTMAN_API_KEY`. - **baseUrl** (string) - Optional - Base URL; defaults to `env.POSTMAN_API_BASE_URL` (defaults to `https://api.postman.com`). Endpoints are appended verbatim. - **serverContext** (ServerContext) - Optional - Appends ` (toolset: )` to the outbound `User-Agent` header. - **srvTraceId** (string) - Optional - If set, sent as the `x-srv-trace` request header. ### Throws - **Error** - `"API key is required for requests. Provide it via constructor parameter or set POSTMAN_API_KEY environment variable."` - thrown lazily inside each request when neither the constructor nor the environment supplies a key. ### Example ```ts import { PostmanAPIClient } from './clients/postman.js'; import { ServerContext } from './tools/utils/toolHelpers.js'; const serverContext: ServerContext = { serverType: 'minimal', availableTools: ['getCollection', 'getWorkspaces'], }; const client = new PostmanAPIClient('PMAK-xxxx', undefined, serverContext, 'v=1;t=0123456789abcdef'); ``` ``` -------------------------------- ### Region helper functions for Postman API Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/entry-point.md Defines the supported Postman API regions and helper functions for region validation and environment setup. `setRegionEnvironment` throws `Error('Invalid region: . Supported regions: us, eu')` for unknown values; `run()` pre-validates and exits instead. ```ts const SUPPORTED_REGIONS = { us: 'https://api.postman.com', eu: 'https://api.eu.postman.com', } as const; ``` ```ts function isValidRegion(region: string): region is keyof typeof SUPPORTED_REGIONS ``` ```ts function setRegionEnvironment(region: string): void ``` -------------------------------- ### setClientInfo(clientInfo, protocolVersion) Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/telemetry-session.md Stores client name/version and the negotiated MCP protocol version from the initialize handshake. ```APIDOC ## setClientInfo(clientInfo, protocolVersion) ### Description Stores client name/version and the negotiated MCP protocol version from the `initialize` handshake. ### Method `setClientInfo(clientInfo: { name: string; version: string }, protocolVersion: string): void` ### Parameters - **clientInfo** (object) - Required - Client name and version. - **name** (string) - Required - Client name. - **version** (string) - Required - Client version. - **protocolVersion** (string) - Required - Negotiated MCP protocol version. ``` -------------------------------- ### serialize() Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/telemetry-session.md Returns a plain-object snapshot of the session for JSON or Redis storage. ```APIDOC ## serialize() ### Description Returns a plain-object snapshot of the session for JSON or Redis storage. ### Method `serialize(): SerializedTelemetrySession` ### Returns - **SerializedTelemetrySession** - The serialized session snapshot. ``` -------------------------------- ### setClientCapabilities(capabilities) Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/telemetry-session.md Stores the keys of the client's advertised capabilities object. ```APIDOC ## setClientCapabilities(capabilities) ### Description Stores the keys of the client's advertised capabilities object. ### Method `setClientCapabilities(capabilities: Record | undefined): void` ### Parameters - **capabilities** (Record | undefined) - Required - Client capabilities object; only its keys are stored. ``` -------------------------------- ### getInstance method signature Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/postman-api-client.md Static method that returns the process-wide singleton PostmanAPIClient. The apiKey and baseUrl arguments are used only when the singleton does not exist yet. ```TypeScript static getInstance(apiKey?: string, baseUrl?: string): PostmanAPIClient ``` -------------------------------- ### PostmanAPIClient class declaration Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/postman-api-client.md Implements IPostmanAPIClient with a private constructor, singleton instance, and async methods for HTTP verbs. Includes static getInstance and resetInstance methods. ```TypeScript export class PostmanAPIClient implements IPostmanAPIClient { private readonly baseUrl: string; private readonly apiKey?: string; private readonly serverContext?: ServerContext; private readonly srvTraceId?: string; private static instance: PostmanAPIClient | null = null; constructor( apiKey?: string, baseUrl: string = env.POSTMAN_API_BASE_URL, serverContext?: ServerContext, srvTraceId?: string ); static getInstance(apiKey?: string, baseUrl?: string): PostmanAPIClient; static resetInstance(): void; async get(endpoint: string, options?: Omit): Promise; async post(endpoint: string, options: PostmanAPIRequestOptions = {}): Promise; async put(endpoint: string, options: PostmanAPIRequestOptions = {}): Promise; async patch(endpoint: string, options: PostmanAPIRequestOptions = {}): Promise; async delete(endpoint: string, options: Omit): Promise; } ``` -------------------------------- ### Define learn and contextGraph method arrays Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/enabled-resources.md Defines two readonly arrays of method names: 'learn' contains 'searchLearningCenter' and 'contextGraph' contains 'submitContextGraphAsk' and 'getContextGraphAsk'. The comments indicate source line references. ```ts const learn = ['searchLearningCenter'] as const; // :355 const contextGraph = ['submitContextGraphAsk', 'getContextGraphAsk'] as const; // :362 ``` -------------------------------- ### fetchCollection and fetchEnvironment function signatures Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/collection-runner.md TypeScript signatures for fetching a collection or environment by ID. Both return a promise with { json, name, id } and throw McpError on failure. ```typescript export async function fetchCollection( collectionId: string, client: PostmanAPIClient ): Promise export async function fetchEnvironment( environmentId: string, client: PostmanAPIClient ): Promise ``` -------------------------------- ### PostmanAPIRequestOptions interface Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/postman-api-client.md Extends the standard RequestInit minus headers, adding contentType and typed IsomorphicHeaders (the MCP SDK's header type, which is [string, string][]-compatible). get/delete further omit method and body. ```ts export interface PostmanAPIRequestOptions extends Omit { contentType?: ContentType; headers?: IsomorphicHeaders; } ``` -------------------------------- ### static fromSerialized(snapshot) Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/telemetry-session.md Reconstructs a TelemetrySession from a serialized snapshot, treating missing clientCapabilities as an empty array. ```APIDOC ## static fromSerialized(snapshot) ### Description Reconstructs a TelemetrySession from a serialized snapshot. `clientCapabilities` defaults to `[]` if undefined. ### Method `static fromSerialized(snapshot: SerializedTelemetrySession): TelemetrySession` ### Parameters - **snapshot** (SerializedTelemetrySession) - Required - The serialized session snapshot. ### Returns - **TelemetrySession** - The reconstructed session. ### Example ```ts const restored = TelemetrySession.fromSerialized(JSON.parse(json)); ``` ``` -------------------------------- ### createTelemetryClient Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/telemetry-utilities.md Creates a telemetry client based on provided options. Returns a NoopTelemetryClient if telemetry is disabled or API key is missing, otherwise a real TelemetryClient. ```APIDOC ## createTelemetryClient ### Description Creates a telemetry client instance. If telemetry is disabled or the API key is missing, returns a NoopTelemetryClient; otherwise returns a real TelemetryClient. ### Signature ```ts export function createTelemetryClient(options: CreateTelemetryClientOptions): ITelemetryClient ``` ### Parameters - **options** (CreateTelemetryClientOptions) - Required - Options for creating the telemetry client, including `telemetryEnabled` and inherited `apiKey`. ### Returns - **ITelemetryClient** - A NoopTelemetryClient if `telemetryEnabled` is falsy or `apiKey` is missing/empty; otherwise a TelemetryClient. ### Example ```ts const telemetry: ITelemetryClient = createTelemetryClient({ telemetryEnabled: parseTelemetryFlag(process.env.POSTMAN_MCP_TELEMETRY) ?? false, apiKey, }); ``` ``` -------------------------------- ### SessionInitEventSchema and inferred type Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/types.md Extends the base schema for session initialization events, fixing event_type to 'session_init' and adding capability arrays, a toolset snapshot ID, and tool list count. ```ts export const SessionInitEventSchema = BaseTelemetryEventSchema.extend({ event_type: z.literal('session_init'), client_capabilities: z.array(z.string()), server_capabilities: z.array(z.string()), toolset_snapshot_id: z.string(), tool_list_count: z.number(), }); export type SessionInitEvent = z.infer; ``` -------------------------------- ### Importing template renderers Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/template-renderers.md Import statements for both renderer factory functions from their respective source files. ```ts import { createTemplateRenderer } from './tools/utils/templateRenderer.js'; import { createErrorTemplateRenderer } from './tools/utils/errorTemplateRenderer.js'; ``` -------------------------------- ### List templated tools Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/enabled-resources.md Lists tools that have Nunjucks views rendered by createTemplateRenderer. The views are src/views/getCollections.njk and src/views/getWorkspaces.njk. ```ts const templated = ['getCollections', 'getWorkspaces'] as const; // src/enabledResources.ts:412 ``` -------------------------------- ### ToolAnnotations interface (toolHelpers.ts) Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/types.md Defines the annotation fields every tool must provide. All fields are required (a compile error occurs otherwise). The `destructiveHint` and `openWorldHint` comments explain the safety semantics that clients rely on for confirmation prompts. ```ts export interface ToolAnnotations { /** Human-readable tool name shown to users. */ title: string; /** True when the tool only reads and never writes. */ readOnlyHint: boolean; /** * True when the tool may destroy, revoke, or displace something: it removes data, * takes away access someone had, moves rather than copies, or runs code the caller * did not write. Clients gate confirmation prompts on this, so understating it is * the dangerous direction to be wrong in. */ destructiveHint: boolean; /** True when repeating the call with the same arguments has no additional effect. */ idempotentHint: boolean; /** * True when the tool reaches an open-ended set of external systems. Reads and * writes confined to Postman are closed; running a user-authored collection, whose * requests may point anywhere, is not. */ openWorldHint: boolean; } ``` -------------------------------- ### resetInstance method signature Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/postman-api-client.md Resets the singleton to null, so the next getInstance() creates a fresh client. Useful for testing or reconfiguration. ```TypeScript static resetInstance(): void ``` -------------------------------- ### Remote server URL for MCP host configuration Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/README.md Add this URL to your MCP host's configuration to use the remote server. Change /minimal to /code or /mcp for Code or Full mode. For EU or API key auth, pass Authorization: Bearer as a header. ```bash https://mcp.postman.com/minimal ``` -------------------------------- ### Import PostmanAPIClient and ContentType Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/_autodocs/api-reference/postman-api-client.md Import the internal Postman API client module from the clients directory. This is used in tool files within the src/tools directory. ```typescript import { PostmanAPIClient, ContentType } from '../clients/postman.js'; ``` -------------------------------- ### Run Postman MCP Server image in Docker Source: https://github.com/postmanlabs/postman-mcp-server/blob/main/DOCKER.md Runs the Postman MCP Server image directly from Docker Hub. Docker automatically discovers, downloads, and runs the image. Requires your Postman API key. ```bash docker run -i -e POSTMAN_API_KEY="" mcp/postman ```