@postman/postman-mcp-server 2.1.4 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dist/package.json +1 -1
  2. package/dist/src/clients/postman.js +68 -29
  3. package/dist/src/enabledResources.js +3 -2
  4. package/dist/src/index.js +38 -17
  5. package/dist/src/tools/createCollection.js +4 -5
  6. package/dist/src/tools/createCollectionComment.js +5 -6
  7. package/dist/src/tools/createCollectionFolder.js +4 -5
  8. package/dist/src/tools/createCollectionFork.js +4 -5
  9. package/dist/src/tools/createCollectionRequest.js +4 -5
  10. package/dist/src/tools/createCollectionResponse.js +4 -5
  11. package/dist/src/tools/createEnvironment.js +13 -8
  12. package/dist/src/tools/createFolderComment.js +5 -6
  13. package/dist/src/tools/createMock.js +4 -5
  14. package/dist/src/tools/createMonitor.js +5 -5
  15. package/dist/src/tools/createRequestComment.js +5 -6
  16. package/dist/src/tools/createResponseComment.js +5 -6
  17. package/dist/src/tools/createSpec.js +17 -29
  18. package/dist/src/tools/createSpecFile.js +4 -5
  19. package/dist/src/tools/createWorkspace.js +4 -5
  20. package/dist/src/tools/deleteApiCollectionComment.js +3 -5
  21. package/dist/src/tools/deleteCollection.js +3 -5
  22. package/dist/src/tools/deleteCollectionComment.js +3 -5
  23. package/dist/src/tools/deleteCollectionFolder.js +3 -5
  24. package/dist/src/tools/deleteCollectionRequest.js +3 -5
  25. package/dist/src/tools/deleteCollectionResponse.js +3 -5
  26. package/dist/src/tools/deleteEnvironment.js +3 -5
  27. package/dist/src/tools/deleteFolderComment.js +3 -5
  28. package/dist/src/tools/deleteMock.js +3 -5
  29. package/dist/src/tools/deleteMonitor.js +3 -5
  30. package/dist/src/tools/deletePanElementOrFolder.js +3 -5
  31. package/dist/src/tools/deleteRequestComment.js +3 -5
  32. package/dist/src/tools/deleteResponseComment.js +3 -5
  33. package/dist/src/tools/deleteSpec.js +3 -5
  34. package/dist/src/tools/deleteSpecFile.js +3 -5
  35. package/dist/src/tools/deleteWorkspace.js +3 -5
  36. package/dist/src/tools/duplicateCollection.js +4 -5
  37. package/dist/src/tools/generateCollection.js +8 -5
  38. package/dist/src/tools/generateSpecFromCollection.js +4 -5
  39. package/dist/src/tools/getAllElementsAndFolders.js +3 -5
  40. package/dist/src/tools/getAllPanAddElementRequests.js +3 -5
  41. package/dist/src/tools/getAllSpecs.js +3 -5
  42. package/dist/src/tools/getAsyncSpecTaskStatus.js +3 -5
  43. package/dist/src/tools/getAuthenticatedUser.js +3 -5
  44. package/dist/src/tools/getCollection.js +3 -5
  45. package/dist/src/tools/getCollectionComments.js +3 -5
  46. package/dist/src/tools/getCollectionFolder.js +3 -5
  47. package/dist/src/tools/getCollectionForks.js +3 -5
  48. package/dist/src/tools/getCollectionRequest.js +3 -5
  49. package/dist/src/tools/getCollectionResponse.js +3 -5
  50. package/dist/src/tools/getCollectionTags.js +3 -5
  51. package/dist/src/tools/getCollectionUpdatesTasks.js +3 -5
  52. package/dist/src/tools/getCollections.js +3 -5
  53. package/dist/src/tools/getCollectionsForkedByUser.js +3 -5
  54. package/dist/src/tools/getDuplicateCollectionTaskStatus.js +3 -5
  55. package/dist/src/tools/getEnvironment.js +3 -5
  56. package/dist/src/tools/getEnvironments.js +3 -5
  57. package/dist/src/tools/getFolderComments.js +3 -5
  58. package/dist/src/tools/getGeneratedCollectionSpecs.js +3 -5
  59. package/dist/src/tools/getMock.js +3 -5
  60. package/dist/src/tools/getMocks.js +3 -5
  61. package/dist/src/tools/getMonitor.js +3 -5
  62. package/dist/src/tools/getMonitors.js +3 -5
  63. package/dist/src/tools/getRequestComments.js +3 -5
  64. package/dist/src/tools/getResponseComments.js +3 -5
  65. package/dist/src/tools/getSourceCollectionStatus.js +3 -5
  66. package/dist/src/tools/getSpec.js +3 -5
  67. package/dist/src/tools/getSpecCollections.js +3 -5
  68. package/dist/src/tools/getSpecDefinition.js +3 -5
  69. package/dist/src/tools/getSpecFile.js +3 -5
  70. package/dist/src/tools/getSpecFiles.js +3 -5
  71. package/dist/src/tools/{getStatusOfAnAsyncTask.js → getStatusOfAnAsyncApiTask.js} +4 -6
  72. package/dist/src/tools/getTaggedEntities.js +3 -5
  73. package/dist/src/tools/getWorkspace.js +3 -5
  74. package/dist/src/tools/getWorkspaceGlobalVariables.js +3 -5
  75. package/dist/src/tools/getWorkspaceTags.js +3 -5
  76. package/dist/src/tools/getWorkspaces.js +3 -5
  77. package/dist/src/tools/mergeCollectionFork.js +57 -0
  78. package/dist/src/tools/patchCollection.js +12 -16
  79. package/dist/src/tools/patchEnvironment.js +5 -7
  80. package/dist/src/tools/postPanElementOrFolder.js +3 -5
  81. package/dist/src/tools/publishDocumentation.js +4 -5
  82. package/dist/src/tools/publishMock.js +3 -5
  83. package/dist/src/tools/pullCollectionChanges.js +3 -5
  84. package/dist/src/tools/putCollection.js +4 -5
  85. package/dist/src/tools/putEnvironment.js +13 -8
  86. package/dist/src/tools/resolveCommentThread.js +3 -5
  87. package/dist/src/tools/runMonitor.js +5 -7
  88. package/dist/src/tools/syncCollectionWithSpec.js +3 -5
  89. package/dist/src/tools/syncSpecWithCollection.js +3 -5
  90. package/dist/src/tools/transferCollectionFolders.js +4 -5
  91. package/dist/src/tools/transferCollectionRequests.js +4 -5
  92. package/dist/src/tools/transferCollectionResponses.js +4 -5
  93. package/dist/src/tools/unpublishDocumentation.js +3 -5
  94. package/dist/src/tools/unpublishMock.js +3 -5
  95. package/dist/src/tools/updateApiCollectionComment.js +4 -5
  96. package/dist/src/tools/updateCollectionComment.js +4 -5
  97. package/dist/src/tools/updateCollectionFolder.js +4 -5
  98. package/dist/src/tools/updateCollectionRequest.js +4 -5
  99. package/dist/src/tools/updateCollectionResponse.js +4 -5
  100. package/dist/src/tools/updateCollectionTags.js +4 -5
  101. package/dist/src/tools/updateFolderComment.js +4 -5
  102. package/dist/src/tools/updateMock.js +4 -5
  103. package/dist/src/tools/updateMonitor.js +5 -5
  104. package/dist/src/tools/updatePanElementOrFolder.js +3 -5
  105. package/dist/src/tools/updateRequestComment.js +4 -5
  106. package/dist/src/tools/updateResponseComment.js +4 -5
  107. package/dist/src/tools/updateSpecFile.js +4 -5
  108. package/dist/src/tools/updateSpecProperties.js +4 -5
  109. package/dist/src/tools/updateWorkspace.js +4 -5
  110. package/dist/src/tools/updateWorkspaceGlobalVariables.js +5 -5
  111. package/dist/src/tools/updateWorkspaceTags.js +4 -5
  112. package/package.json +1 -1
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postman/postman-mcp-server",
3
- "version": "2.1.4",
3
+ "version": "2.2.0",
4
4
  "description": "A simple MCP server to operate on the Postman API",
5
5
  "main": "dist/src/index.js",
6
6
  "type": "module",
@@ -1,31 +1,77 @@
1
- import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
1
+ import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
2
2
  import packageJson from '../../package.json' with { type: 'json' };
3
- const BASE_URL = 'https://api.postman.com';
4
3
  export var ContentType;
5
4
  (function (ContentType) {
6
5
  ContentType["Json"] = "application/json";
7
6
  ContentType["JsonPatch"] = "application/json-patch+json";
8
7
  })(ContentType || (ContentType = {}));
9
- export async function fetchPostmanAPI(endpoint, options) {
10
- const apiKey = options.apiKey || process.env.POSTMAN_API_KEY;
11
- if (!apiKey) {
12
- throw new Error('API key is required.');
13
- }
14
- const contentType = options.contentType || ContentType.Json;
15
- const userAgentHeader = options.headers && 'user-agent' in options.headers
16
- ? `${options.headers['user-agent']}/${packageJson.name}/${packageJson.version}`
17
- : `${packageJson.name}/${packageJson.version}`;
18
- const headers = {
19
- 'content-type': contentType,
20
- 'x-api-key': apiKey,
21
- 'user-agent': userAgentHeader,
22
- };
23
- const { headers: _, ...optionsWithoutHeaders } = options;
24
- const response = await fetch(`${BASE_URL}${endpoint}`, {
25
- ...optionsWithoutHeaders,
26
- headers,
27
- });
28
- if (!response.ok) {
8
+ export class PostmanAPIClient {
9
+ baseUrl;
10
+ apiKey;
11
+ static instance = null;
12
+ constructor(apiKey, baseUrl = process.env.POSTMAN_API_BASE_URL || 'https://api.postman.com') {
13
+ if (!apiKey && !process.env.POSTMAN_API_KEY) {
14
+ throw new Error('API key is required. Provide it as parameter or set POSTMAN_API_KEY environment variable.');
15
+ }
16
+ this.apiKey = apiKey || process.env.POSTMAN_API_KEY;
17
+ this.baseUrl = baseUrl;
18
+ }
19
+ static getInstance(apiKey, baseUrl) {
20
+ if (!PostmanAPIClient.instance) {
21
+ const key = apiKey || process.env.POSTMAN_API_KEY;
22
+ if (!key) {
23
+ throw new Error('API key is required. Provide it as parameter or set POSTMAN_API_KEY environment variable.');
24
+ }
25
+ PostmanAPIClient.instance = new PostmanAPIClient(key, baseUrl);
26
+ }
27
+ return PostmanAPIClient.instance;
28
+ }
29
+ static resetInstance() {
30
+ PostmanAPIClient.instance = null;
31
+ }
32
+ async get(endpoint, options = {}) {
33
+ return this.request(endpoint, { ...options, method: 'GET' });
34
+ }
35
+ async post(endpoint, options = {}) {
36
+ return this.request(endpoint, { ...options, method: 'POST' });
37
+ }
38
+ async put(endpoint, options = {}) {
39
+ return this.request(endpoint, { ...options, method: 'PUT' });
40
+ }
41
+ async patch(endpoint, options = {}) {
42
+ return this.request(endpoint, { ...options, method: 'PATCH' });
43
+ }
44
+ async delete(endpoint, options = {}) {
45
+ return this.request(endpoint, { ...options, method: 'DELETE' });
46
+ }
47
+ async request(endpoint, options) {
48
+ const contentType = options.contentType || ContentType.Json;
49
+ const userAgentHeader = options.headers && 'user-agent' in options.headers
50
+ ? `${options.headers['user-agent']}/${packageJson.name}/${packageJson.version}`
51
+ : `${packageJson.name}/${packageJson.version}`;
52
+ const headers = {
53
+ 'content-type': contentType,
54
+ 'x-api-key': this.apiKey,
55
+ 'user-agent': userAgentHeader,
56
+ ...options.headers,
57
+ };
58
+ const { headers: _, ...optionsWithoutHeaders } = options;
59
+ const response = await fetch(`${this.baseUrl}${endpoint}`, {
60
+ ...optionsWithoutHeaders,
61
+ headers,
62
+ });
63
+ if (!response.ok) {
64
+ await this.handleErrorResponse(response);
65
+ }
66
+ if (response.status === 204)
67
+ return null;
68
+ const responseContentType = response.headers.get('content-type') || '';
69
+ if (responseContentType.includes('application/json')) {
70
+ return response.json();
71
+ }
72
+ return response.text();
73
+ }
74
+ async handleErrorResponse(response) {
29
75
  const errorText = await response.text();
30
76
  switch (response.status) {
31
77
  case 400:
@@ -41,11 +87,4 @@ export async function fetchPostmanAPI(endpoint, options) {
41
87
  });
42
88
  }
43
89
  }
44
- if (response.status === 204)
45
- return null;
46
- const responseContentType = response.headers.get('content-type') || '';
47
- if (responseContentType.includes('application/json')) {
48
- return response.json();
49
- }
50
- return response.text();
51
90
  }
@@ -19,7 +19,7 @@ const full = [
19
19
  'getCollectionsForkedByUser',
20
20
  'pullCollectionChanges',
21
21
  'createCollectionFork',
22
- 'collection-merges',
22
+ 'mergeCollectionFork',
23
23
  'createCollectionFolder',
24
24
  'deleteCollectionFolder',
25
25
  'getCollectionFolder',
@@ -99,7 +99,7 @@ const full = [
99
99
  'publishDocumentation',
100
100
  'unpublishDocumentation',
101
101
  'getAsyncSpecTaskStatus',
102
- 'getStatusOfAnAsyncTask',
102
+ 'getStatusOfAnAsyncApiTask',
103
103
  'getAuthenticatedUser',
104
104
  'getTaggedEntities',
105
105
  'transferCollectionFolders',
@@ -148,6 +148,7 @@ const minimal = [
148
148
  'createCollectionRequest',
149
149
  'createCollectionResponse',
150
150
  'duplicateCollection',
151
+ 'getStatusOfAnAsyncApiTask',
151
152
  ];
152
153
  const excludedFromGeneration = ['createCollection', 'putCollection'];
153
154
  export const enabledResources = {
package/dist/src/index.js CHANGED
@@ -9,6 +9,20 @@ import { readdir } from 'node:fs/promises';
9
9
  import { join, dirname } from 'node:path';
10
10
  import { fileURLToPath } from 'node:url';
11
11
  import { enabledResources } from './enabledResources.js';
12
+ import { PostmanAPIClient } from './clients/postman.js';
13
+ const SUPPORTED_REGIONS = {
14
+ us: 'https://api.postman.com',
15
+ eu: 'https://api.eu.postman.com',
16
+ };
17
+ function isValidRegion(region) {
18
+ return region in SUPPORTED_REGIONS;
19
+ }
20
+ function setRegionEnvironment(region) {
21
+ if (!isValidRegion(region)) {
22
+ throw new Error(`Invalid region: ${region}. Supported regions: us, eu`);
23
+ }
24
+ process.env.POSTMAN_API_BASE_URL = SUPPORTED_REGIONS[region];
25
+ }
12
26
  function log(level, message, context) {
13
27
  const timestamp = new Date().toISOString();
14
28
  const suffix = context ? ` ${JSON.stringify(context)}` : '';
@@ -74,17 +88,33 @@ dotenv.config();
74
88
  const SERVER_NAME = packageJson.name;
75
89
  const APP_VERSION = packageJson.version;
76
90
  export const USER_AGENT = `${SERVER_NAME}/${APP_VERSION}`;
77
- let currentApiKey = undefined;
78
91
  let clientInfo = undefined;
79
- const allGeneratedTools = await loadAllTools();
80
- log('info', 'Server initialization starting', {
81
- serverName: SERVER_NAME,
82
- version: APP_VERSION,
83
- toolCount: allGeneratedTools.length,
84
- });
85
92
  async function run() {
86
93
  const args = process.argv.slice(2);
87
94
  const useFull = args.includes('--full');
95
+ const regionIndex = args.findIndex((arg) => arg === '--region');
96
+ if (regionIndex !== -1 && regionIndex + 1 < args.length) {
97
+ const region = args[regionIndex + 1];
98
+ if (isValidRegion(region)) {
99
+ setRegionEnvironment(region);
100
+ log('info', `Using region: ${region}`, {
101
+ region,
102
+ baseUrl: process.env.POSTMAN_API_BASE_URL,
103
+ });
104
+ }
105
+ else {
106
+ log('error', `Invalid region: ${region}`);
107
+ console.error(`Supported regions: ${Object.keys(SUPPORTED_REGIONS).join(', ')}`);
108
+ process.exit(1);
109
+ }
110
+ }
111
+ const client = PostmanAPIClient.getInstance();
112
+ const allGeneratedTools = await loadAllTools();
113
+ log('info', 'Server initialization starting', {
114
+ serverName: SERVER_NAME,
115
+ version: APP_VERSION,
116
+ toolCount: allGeneratedTools.length,
117
+ });
88
118
  const fullTools = allGeneratedTools.filter((t) => enabledResources.full.includes(t.method));
89
119
  const minimalTools = allGeneratedTools.filter((t) => enabledResources.minimal.includes(t.method));
90
120
  const tools = useFull ? fullTools : minimalTools;
@@ -110,12 +140,8 @@ async function run() {
110
140
  const args = request.params.arguments || {};
111
141
  try {
112
142
  const start = Date.now();
113
- if (!currentApiKey) {
114
- log('error', 'Missing API key for tool invocation', { toolName });
115
- throw new McpError(ErrorCode.InvalidParams, 'API key is required.');
116
- }
117
143
  const result = await tool.handler(args, {
118
- apiKey: currentApiKey,
144
+ client,
119
145
  headers: {
120
146
  ...extra.requestInfo?.headers,
121
147
  'user-agent': clientInfo?.name,
@@ -148,11 +174,6 @@ async function run() {
148
174
  }));
149
175
  return { tools: transformedTools };
150
176
  });
151
- currentApiKey = process.env.POSTMAN_API_KEY;
152
- if (!currentApiKey) {
153
- log('error', 'POSTMAN_API_KEY is required');
154
- process.exit(1);
155
- }
156
177
  log('info', 'Starting stdio transport');
157
178
  const transport = new StdioServerTransport();
158
179
  transport.onmessage = (message) => {
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { fetchPostmanAPI, ContentType } from '../clients/postman.js';
2
+ import { ContentType } from '../clients/postman.js';
3
3
  import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
4
4
  function asMcpError(error) {
5
5
  const cause = error?.cause ?? String(error);
@@ -797,13 +797,12 @@ export async function handler(params, extra) {
797
797
  const bodyPayload = {};
798
798
  if (params.collection !== undefined)
799
799
  bodyPayload.collection = params.collection;
800
- const result = await fetchPostmanAPI(url, {
801
- method: 'POST',
800
+ const options = {
802
801
  body: JSON.stringify(bodyPayload),
803
802
  contentType: ContentType.Json,
804
- apiKey: extra.apiKey,
805
803
  headers: extra.headers,
806
- });
804
+ };
805
+ const result = await extra.client.post(url, options);
807
806
  return {
808
807
  content: [
809
808
  {
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { fetchPostmanAPI, ContentType } from '../clients/postman.js';
2
+ import { ContentType } from '../clients/postman.js';
3
3
  import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
4
4
  function asMcpError(error) {
5
5
  const cause = error?.cause ?? String(error);
@@ -17,7 +17,7 @@ export const parameters = z.object({
17
17
  .optional(),
18
18
  tags: z
19
19
  .object({
20
- userName: z
20
+ '{{userName}}': z
21
21
  .object({
22
22
  type: z.literal('user').describe('The `user` value.'),
23
23
  id: z.string().describe("The user's ID."),
@@ -46,13 +46,12 @@ export async function handler(params, extra) {
46
46
  bodyPayload.threadId = params.threadId;
47
47
  if (params.tags !== undefined)
48
48
  bodyPayload.tags = params.tags;
49
- const result = await fetchPostmanAPI(url, {
50
- method: 'POST',
49
+ const options = {
51
50
  body: JSON.stringify(bodyPayload),
52
51
  contentType: ContentType.Json,
53
- apiKey: extra.apiKey,
54
52
  headers: extra.headers,
55
- });
53
+ };
54
+ const result = await extra.client.post(url, options);
56
55
  return {
57
56
  content: [
58
57
  {
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { fetchPostmanAPI, ContentType } from '../clients/postman.js';
2
+ import { ContentType } from '../clients/postman.js';
3
3
  import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
4
4
  function asMcpError(error) {
5
5
  const cause = error?.cause ?? String(error);
@@ -31,13 +31,12 @@ export async function handler(params, extra) {
31
31
  bodyPayload.name = params.name;
32
32
  if (params.folder !== undefined)
33
33
  bodyPayload.folder = params.folder;
34
- const result = await fetchPostmanAPI(url, {
35
- method: 'POST',
34
+ const options = {
36
35
  body: JSON.stringify(bodyPayload),
37
36
  contentType: ContentType.Json,
38
- apiKey: extra.apiKey,
39
37
  headers: extra.headers,
40
- });
38
+ };
39
+ const result = await extra.client.post(url, options);
41
40
  return {
42
41
  content: [
43
42
  {
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { fetchPostmanAPI, ContentType } from '../clients/postman.js';
2
+ import { ContentType } from '../clients/postman.js';
3
3
  import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
4
4
  function asMcpError(error) {
5
5
  const cause = error?.cause ?? String(error);
@@ -28,13 +28,12 @@ export async function handler(params, extra) {
28
28
  const bodyPayload = {};
29
29
  if (params.label !== undefined)
30
30
  bodyPayload.label = params.label;
31
- const result = await fetchPostmanAPI(url, {
32
- method: 'POST',
31
+ const options = {
33
32
  body: JSON.stringify(bodyPayload),
34
33
  contentType: ContentType.Json,
35
- apiKey: extra.apiKey,
36
34
  headers: extra.headers,
37
- });
35
+ };
36
+ const result = await extra.client.post(url, options);
38
37
  return {
39
38
  content: [
40
39
  {
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { fetchPostmanAPI, ContentType } from '../clients/postman.js';
2
+ import { ContentType } from '../clients/postman.js';
3
3
  import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
4
4
  function asMcpError(error) {
5
5
  const cause = error?.cause ?? String(error);
@@ -34,13 +34,12 @@ export async function handler(params, extra) {
34
34
  const bodyPayload = {};
35
35
  if (params.name !== undefined)
36
36
  bodyPayload.name = params.name;
37
- const result = await fetchPostmanAPI(url, {
38
- method: 'POST',
37
+ const options = {
39
38
  body: JSON.stringify(bodyPayload),
40
39
  contentType: ContentType.Json,
41
- apiKey: extra.apiKey,
42
40
  headers: extra.headers,
43
- });
41
+ };
42
+ const result = await extra.client.post(url, options);
44
43
  return {
45
44
  content: [
46
45
  {
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { fetchPostmanAPI, ContentType } from '../clients/postman.js';
2
+ import { ContentType } from '../clients/postman.js';
3
3
  import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
4
4
  function asMcpError(error) {
5
5
  const cause = error?.cause ?? String(error);
@@ -31,13 +31,12 @@ export async function handler(params, extra) {
31
31
  const bodyPayload = {};
32
32
  if (params.name !== undefined)
33
33
  bodyPayload.name = params.name;
34
- const result = await fetchPostmanAPI(url, {
35
- method: 'POST',
34
+ const options = {
36
35
  body: JSON.stringify(bodyPayload),
37
36
  contentType: ContentType.Json,
38
- apiKey: extra.apiKey,
39
37
  headers: extra.headers,
40
- });
38
+ };
39
+ const result = await extra.client.post(url, options);
41
40
  return {
42
41
  content: [
43
42
  {
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { fetchPostmanAPI, ContentType } from '../clients/postman.js';
2
+ import { ContentType } from '../clients/postman.js';
3
3
  import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
4
4
  function asMcpError(error) {
5
5
  const cause = error?.cause ?? String(error);
@@ -13,12 +13,18 @@ export const parameters = z.object({
13
13
  .object({
14
14
  name: z.string().describe("The environment's name."),
15
15
  values: z
16
- .array(z.object({
16
+ .array(z
17
+ .object({
17
18
  enabled: z.boolean().describe('If true, the variable is enabled.').optional(),
18
19
  key: z.string().describe("The variable's name.").optional(),
19
20
  value: z.string().describe("The variable's value.").optional(),
20
- type: z.enum(['secret', 'default']).describe('The variable type.').optional(),
21
- }))
21
+ type: z
22
+ .enum(['secret', 'default'])
23
+ .describe("The variable's type:\n- `secret` — The variable value is masked.\n- `default` — The variable value is visible in plain text.\n")
24
+ .optional(),
25
+ description: z.string().max(512).describe("The variable's description.").optional(),
26
+ })
27
+ .describe("Information about the environment's variables."))
22
28
  .describe("Information about the environment's variables.")
23
29
  .optional(),
24
30
  })
@@ -41,13 +47,12 @@ export async function handler(params, extra) {
41
47
  const bodyPayload = {};
42
48
  if (params.environment !== undefined)
43
49
  bodyPayload.environment = params.environment;
44
- const result = await fetchPostmanAPI(url, {
45
- method: 'POST',
50
+ const options = {
46
51
  body: JSON.stringify(bodyPayload),
47
52
  contentType: ContentType.Json,
48
- apiKey: extra.apiKey,
49
53
  headers: extra.headers,
50
- });
54
+ };
55
+ const result = await extra.client.post(url, options);
51
56
  return {
52
57
  content: [
53
58
  {
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { fetchPostmanAPI, ContentType } from '../clients/postman.js';
2
+ import { ContentType } from '../clients/postman.js';
3
3
  import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
4
4
  function asMcpError(error) {
5
5
  const cause = error?.cause ?? String(error);
@@ -18,7 +18,7 @@ export const parameters = z.object({
18
18
  .optional(),
19
19
  tags: z
20
20
  .object({
21
- userName: z
21
+ '{{userName}}': z
22
22
  .object({
23
23
  type: z.literal('user').describe('The `user` value.'),
24
24
  id: z.string().describe("The user's ID."),
@@ -47,13 +47,12 @@ export async function handler(params, extra) {
47
47
  bodyPayload.threadId = params.threadId;
48
48
  if (params.tags !== undefined)
49
49
  bodyPayload.tags = params.tags;
50
- const result = await fetchPostmanAPI(url, {
51
- method: 'POST',
50
+ const options = {
52
51
  body: JSON.stringify(bodyPayload),
53
52
  contentType: ContentType.Json,
54
- apiKey: extra.apiKey,
55
53
  headers: extra.headers,
56
- });
54
+ };
55
+ const result = await extra.client.post(url, options);
57
56
  return {
58
57
  content: [
59
58
  {
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { fetchPostmanAPI, ContentType } from '../clients/postman.js';
2
+ import { ContentType } from '../clients/postman.js';
3
3
  import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
4
4
  function asMcpError(error) {
5
5
  const cause = error?.cause ?? String(error);
@@ -40,13 +40,12 @@ export async function handler(params, extra) {
40
40
  const bodyPayload = {};
41
41
  if (params.mock !== undefined)
42
42
  bodyPayload.mock = params.mock;
43
- const result = await fetchPostmanAPI(url, {
44
- method: 'POST',
43
+ const options = {
45
44
  body: JSON.stringify(bodyPayload),
46
45
  contentType: ContentType.Json,
47
- apiKey: extra.apiKey,
48
46
  headers: extra.headers,
49
- });
47
+ };
48
+ const result = await extra.client.post(url, options);
50
49
  return {
51
50
  content: [
52
51
  {
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { fetchPostmanAPI, ContentType } from '../clients/postman.js';
2
+ import { ContentType } from '../clients/postman.js';
3
3
  import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
4
4
  function asMcpError(error) {
5
5
  const cause = error?.cause ?? String(error);
@@ -36,6 +36,7 @@ export const parameters = z.object({
36
36
  .describe('The number of times to reattempt a monitor run if it fails or errors. This may impact your [monitor usage](https://learning.postman.com/docs/monitoring-your-api/monitor-usage/#view-monitor-usage).')
37
37
  .optional(),
38
38
  })
39
+ .describe("Information about the monitor's retry settings.")
39
40
  .optional(),
40
41
  options: z
41
42
  .object({
@@ -130,13 +131,12 @@ export async function handler(params, extra) {
130
131
  const bodyPayload = {};
131
132
  if (params.monitor !== undefined)
132
133
  bodyPayload.monitor = params.monitor;
133
- const result = await fetchPostmanAPI(url, {
134
- method: 'POST',
134
+ const options = {
135
135
  body: JSON.stringify(bodyPayload),
136
136
  contentType: ContentType.Json,
137
- apiKey: extra.apiKey,
138
137
  headers: extra.headers,
139
- });
138
+ };
139
+ const result = await extra.client.post(url, options);
140
140
  return {
141
141
  content: [
142
142
  {
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { fetchPostmanAPI, ContentType } from '../clients/postman.js';
2
+ import { ContentType } from '../clients/postman.js';
3
3
  import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
4
4
  function asMcpError(error) {
5
5
  const cause = error?.cause ?? String(error);
@@ -20,7 +20,7 @@ export const parameters = z.object({
20
20
  .optional(),
21
21
  tags: z
22
22
  .object({
23
- userName: z
23
+ '{{userName}}': z
24
24
  .object({
25
25
  type: z.literal('user').describe('The `user` value.'),
26
26
  id: z.string().describe("The user's ID."),
@@ -49,13 +49,12 @@ export async function handler(params, extra) {
49
49
  bodyPayload.threadId = params.threadId;
50
50
  if (params.tags !== undefined)
51
51
  bodyPayload.tags = params.tags;
52
- const result = await fetchPostmanAPI(url, {
53
- method: 'POST',
52
+ const options = {
54
53
  body: JSON.stringify(bodyPayload),
55
54
  contentType: ContentType.Json,
56
- apiKey: extra.apiKey,
57
55
  headers: extra.headers,
58
- });
56
+ };
57
+ const result = await extra.client.post(url, options);
59
58
  return {
60
59
  content: [
61
60
  {
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { fetchPostmanAPI, ContentType } from '../clients/postman.js';
2
+ import { ContentType } from '../clients/postman.js';
3
3
  import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
4
4
  function asMcpError(error) {
5
5
  const cause = error?.cause ?? String(error);
@@ -18,7 +18,7 @@ export const parameters = z.object({
18
18
  .optional(),
19
19
  tags: z
20
20
  .object({
21
- userName: z
21
+ '{{userName}}': z
22
22
  .object({
23
23
  type: z.literal('user').describe('The `user` value.'),
24
24
  id: z.string().describe("The user's ID."),
@@ -47,13 +47,12 @@ export async function handler(params, extra) {
47
47
  bodyPayload.threadId = params.threadId;
48
48
  if (params.tags !== undefined)
49
49
  bodyPayload.tags = params.tags;
50
- const result = await fetchPostmanAPI(url, {
51
- method: 'POST',
50
+ const options = {
52
51
  body: JSON.stringify(bodyPayload),
53
52
  contentType: ContentType.Json,
54
- apiKey: extra.apiKey,
55
53
  headers: extra.headers,
56
- });
54
+ };
55
+ const result = await extra.client.post(url, options);
57
56
  return {
58
57
  content: [
59
58
  {
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { fetchPostmanAPI, ContentType } from '../clients/postman.js';
2
+ import { ContentType } from '../clients/postman.js';
3
3
  import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
4
4
  function asMcpError(error) {
5
5
  const cause = error?.cause ?? String(error);
@@ -12,30 +12,19 @@ export const parameters = z.object({
12
12
  name: z.string().describe("The specification's name."),
13
13
  type: z.enum(['OPENAPI:3.0', 'ASYNCAPI:2.0']).describe("The specification's type."),
14
14
  files: z
15
- .array(z.any().superRefine((x, ctx) => {
16
- const schemas = [
17
- z.object({
18
- path: z.string().describe("The file's path. Accepts JSON or YAML files."),
19
- content: z.string().describe("The file's stringified contents."),
20
- type: z
21
- .enum(['DEFAULT', 'ROOT'])
22
- .describe('The type of file. This property is required when creating multi-file specifications:\n- `ROOT` — The file containing the full OpenAPI structure. This serves as the entry point for the API spec and references other (`DEFAULT`) spec files. Multi-file specs can only have one root file.\n- `DEFAULT` — A file referenced by the `ROOT` file.\n'),
23
- }),
24
- z.object({
25
- path: z.string().describe("The file's path. Accepts JSON or YAML files."),
26
- content: z.string().describe("The file's stringified contents."),
27
- }),
28
- ];
29
- const errors = schemas.reduce((errors, schema) => ((result) => (result.error ? [...errors, result.error] : errors))(schema.safeParse(x)), []);
30
- if (schemas.length - errors.length !== 1) {
31
- ctx.addIssue({
32
- path: ctx.path,
33
- code: 'invalid_union',
34
- unionErrors: errors,
35
- message: 'Invalid input: Should pass single schema',
36
- });
37
- }
38
- }))
15
+ .array(z.union([
16
+ z.object({
17
+ path: z.string().describe("The file's path. Accepts JSON or YAML files."),
18
+ content: z.string().describe("The file's stringified contents."),
19
+ type: z
20
+ .enum(['DEFAULT', 'ROOT'])
21
+ .describe('The type of file. This property is required when creating multi-file specifications:\n- `ROOT` — The file containing the full OpenAPI structure. This serves as the entry point for the API spec and references other (`DEFAULT`) spec files. Multi-file specs can only have one root file.\n- `DEFAULT` — A file referenced by the `ROOT` file.\n'),
22
+ }),
23
+ z.object({
24
+ path: z.string().describe("The file's path. Accepts JSON or YAML files."),
25
+ content: z.string().describe("The file's stringified contents."),
26
+ }),
27
+ ]))
39
28
  .describe("A list of the specification's files and their contents."),
40
29
  });
41
30
  export const annotations = {
@@ -58,13 +47,12 @@ export async function handler(params, extra) {
58
47
  bodyPayload.type = params.type;
59
48
  if (params.files !== undefined)
60
49
  bodyPayload.files = params.files;
61
- const result = await fetchPostmanAPI(url, {
62
- method: 'POST',
50
+ const options = {
63
51
  body: JSON.stringify(bodyPayload),
64
52
  contentType: ContentType.Json,
65
- apiKey: extra.apiKey,
66
53
  headers: extra.headers,
67
- });
54
+ };
55
+ const result = await extra.client.post(url, options);
68
56
  return {
69
57
  content: [
70
58
  {