UNPKG

@postman/postman-mcp-server

Version:

Postman MCP Server — connect AI agents (Claude Code, Cursor, VS Code Copilot, Gemini CLI) to your Postman collections, specifications, and environments via Model Context Protocol (MCP)

32 lines (31 loc) • 1.35 kB
import { z } from 'zod'; import { asMcpError, McpError, defineToolAnnotations } from './utils/toolHelpers.js'; export const method = 'getResponseContext'; export const title = 'Get response context'; export const description = 'Returns a markdown-formatted summary of a saved response example within a collection request, including its status code, headers, body, and the original request details.'; export const parameters = z.object({ collectionId: z.string().describe("The collection's ID."), requestId: z.string().describe("The parent request's ID."), responseId: z.string().describe("The response's ID."), }); export const annotations = defineToolAnnotations({ title: 'Get response context', readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false, }); export async function handler(args, extra) { try { const result = await extra.client.get(`/context/collections/${encodeURIComponent(String(args.collectionId))}/requests/${encodeURIComponent(String(args.requestId))}/responses/${encodeURIComponent(String(args.responseId))}`, { headers: extra.headers }); return { content: [{ type: 'text', text: result }], }; } catch (e) { if (e instanceof McpError) { throw e; } throw asMcpError(e); } }