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)

24 lines (23 loc) • 783 B
import { existsSync } from 'node:fs'; import { join } from 'node:path'; import nunjucks from 'nunjucks'; export function createErrorTemplateRenderer(errorsDir) { const env = nunjucks.configure(errorsDir, { autoescape: true, noCache: false, throwOnUndefined: false, }); env.addFilter('default', (val, defaultVal = '') => val === undefined || val === null ? defaultVal : val); return (toolName, statusCode, context) => { const templateFile = `${toolName}.${statusCode}.njk`; const templatePath = join(errorsDir, templateFile); if (!existsSync(templatePath)) return null; try { return env.render(templateFile, context); } catch { return null; } }; }