@postman/postman-mcp-server 2.7.0 → 2.8.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.
- package/README.md +32 -0
- package/dist/package.json +15 -13
- package/dist/src/clients/postman.js +2 -0
- package/dist/src/enabledResources.js +14 -9
- package/dist/src/index.js +29 -1
- package/dist/src/tools/addWorkspaceToPrivateNetwork.js +47 -0
- package/dist/src/tools/createCollectionRequest.js +255 -94
- package/dist/src/tools/createCollectionResponse.js +125 -3
- package/dist/src/tools/createSpec.js +16 -4
- package/dist/src/tools/createWorkspace.js +6 -2
- package/dist/src/tools/deleteWorkspace.js +1 -1
- package/dist/src/tools/generateCollection.js +2 -2
- package/dist/src/tools/getAnalyticsData.js +107 -0
- package/dist/src/tools/getAnalyticsMetadata.js +55 -0
- package/dist/src/tools/getCodeGenerationInstructions.js +12 -6
- package/dist/src/tools/getCollection/getCollectionMap.js +2 -2
- package/dist/src/tools/getWorkspace.js +1 -1
- package/dist/src/tools/{getAllPanAddElementRequests.js → listPrivateNetworkAddRequests.js} +9 -16
- package/dist/src/tools/{getAllElementsAndFolders.js → listPrivateNetworkWorkspaces.js} +27 -34
- package/dist/src/tools/publishDocumentation.js +1 -1
- package/dist/src/tools/pullCollectionChanges.js +3 -1
- package/dist/src/tools/putCollection.js +11 -1
- package/dist/src/tools/removeWorkspaceFromPrivateNetwork.js +36 -0
- package/dist/src/tools/resolveCommentThread.js +1 -1
- package/dist/src/tools/respondPrivateNetworkAddRequest.js +56 -0
- package/dist/src/tools/searchPostmanElementsInPrivateNetwork.js +127 -0
- package/dist/src/tools/{searchPostmanElements.js → searchPostmanElementsInPublicNetwork.js} +1 -1
- package/dist/src/tools/updateCollectionRequest.js +254 -97
- package/dist/src/tools/updateCollectionResponse.js +113 -0
- package/dist/src/tools/updateWorkspace.js +1 -1
- package/dist/src/tools/utils/errorTemplateRenderer.js +23 -0
- package/dist/src/views/errors/getCollectionFolder.404.njk +5 -0
- package/dist/src/views/errors/getCollectionRequest.404.njk +5 -0
- package/dist/src/views/errors/getCollectionResponse.404.njk +5 -0
- package/dist/src/views/errors/getEnvironment.404.njk +5 -0
- package/dist/src/views/errors/getMock.404.njk +5 -0
- package/dist/src/views/errors/getMonitor.404.njk +5 -0
- package/dist/src/views/errors/getSpec.404.njk +5 -0
- package/dist/src/views/errors/getWorkspace.404.njk +5 -0
- package/dist/src/views/getWorkspaces.njk +3 -3
- package/package.json +24 -24
- package/dist/src/tools/deletePanElementOrFolder.js +0 -41
- package/dist/src/tools/postPanElementOrFolder.js +0 -84
- package/dist/src/tools/updatePanElementOrFolder.js +0 -100
|
@@ -7,6 +7,75 @@ export const parameters = z.object({
|
|
|
7
7
|
responseId: z.string().describe("The response's ID."),
|
|
8
8
|
collectionId: z.string().describe("The collection's ID."),
|
|
9
9
|
name: z.string().describe("The response's name.").optional(),
|
|
10
|
+
description: z.string().nullable().describe("The response's description.").optional(),
|
|
11
|
+
url: z.string().nullable().describe("The associated request's URL.").optional(),
|
|
12
|
+
method: z
|
|
13
|
+
.enum([
|
|
14
|
+
'GET',
|
|
15
|
+
'PUT',
|
|
16
|
+
'POST',
|
|
17
|
+
'PATCH',
|
|
18
|
+
'DELETE',
|
|
19
|
+
'COPY',
|
|
20
|
+
'HEAD',
|
|
21
|
+
'OPTIONS',
|
|
22
|
+
'LINK',
|
|
23
|
+
'UNLINK',
|
|
24
|
+
'PURGE',
|
|
25
|
+
'LOCK',
|
|
26
|
+
'UNLOCK',
|
|
27
|
+
'PROPFIND',
|
|
28
|
+
'VIEW',
|
|
29
|
+
])
|
|
30
|
+
.describe("The request's HTTP method.")
|
|
31
|
+
.optional(),
|
|
32
|
+
headers: z
|
|
33
|
+
.array(z
|
|
34
|
+
.object({
|
|
35
|
+
key: z
|
|
36
|
+
.string()
|
|
37
|
+
.describe("The header's key, such as `Content-Type` or `X-Custom-Header`."),
|
|
38
|
+
value: z.string().describe("The header key's value."),
|
|
39
|
+
description: z.string().nullable().describe("The header's description.").optional(),
|
|
40
|
+
})
|
|
41
|
+
.describe('Information about the header.'))
|
|
42
|
+
.describe('A list of headers.')
|
|
43
|
+
.optional(),
|
|
44
|
+
dataMode: z
|
|
45
|
+
.enum(['raw', 'urlencoded', 'formdata', 'binary', 'graphql'])
|
|
46
|
+
.describe("The associated request body's data mode.")
|
|
47
|
+
.optional(),
|
|
48
|
+
rawModeData: z
|
|
49
|
+
.string()
|
|
50
|
+
.nullable()
|
|
51
|
+
.describe("The associated request body's raw mode data.")
|
|
52
|
+
.optional(),
|
|
53
|
+
dataOptions: z
|
|
54
|
+
.object({
|
|
55
|
+
raw: z
|
|
56
|
+
.object({ language: z.string().describe("The raw mode data's language type.").optional() })
|
|
57
|
+
.describe('Options for the `raw` data mode.')
|
|
58
|
+
.optional(),
|
|
59
|
+
urlencoded: z
|
|
60
|
+
.record(z.string(), z.unknown())
|
|
61
|
+
.describe('Options for the `urlencoded` data mode.')
|
|
62
|
+
.optional(),
|
|
63
|
+
params: z
|
|
64
|
+
.record(z.string(), z.unknown())
|
|
65
|
+
.describe('Options for the `params` data mode.')
|
|
66
|
+
.optional(),
|
|
67
|
+
binary: z
|
|
68
|
+
.record(z.string(), z.unknown())
|
|
69
|
+
.describe('Options for the `binary` data mode.')
|
|
70
|
+
.optional(),
|
|
71
|
+
graphql: z
|
|
72
|
+
.record(z.string(), z.unknown())
|
|
73
|
+
.describe('Options for the `graphql` data mode.')
|
|
74
|
+
.optional(),
|
|
75
|
+
})
|
|
76
|
+
.nullable()
|
|
77
|
+
.describe("Additional configurations and options set for the request body's various data modes.")
|
|
78
|
+
.optional(),
|
|
10
79
|
responseCode: z
|
|
11
80
|
.object({
|
|
12
81
|
code: z.number().describe("The response's HTTP response status code.").optional(),
|
|
@@ -14,6 +83,20 @@ export const parameters = z.object({
|
|
|
14
83
|
})
|
|
15
84
|
.describe("The response's HTTP response code information.")
|
|
16
85
|
.optional(),
|
|
86
|
+
status: z.string().nullable().describe("The response's HTTP status text.").optional(),
|
|
87
|
+
time: z
|
|
88
|
+
.string()
|
|
89
|
+
.describe('The time taken by the request to complete, in milliseconds.')
|
|
90
|
+
.optional(),
|
|
91
|
+
cookies: z.string().nullable().describe("The response's cookie data.").optional(),
|
|
92
|
+
mime: z.string().nullable().describe("The response's MIME type.").optional(),
|
|
93
|
+
text: z.string().describe('The raw text of the response body.').optional(),
|
|
94
|
+
language: z.string().describe("The response body's language type.").optional(),
|
|
95
|
+
rawDataType: z.string().nullable().describe("The response's raw data type.").optional(),
|
|
96
|
+
requestObject: z
|
|
97
|
+
.string()
|
|
98
|
+
.describe('A JSON-stringified representation of the associated request.')
|
|
99
|
+
.optional(),
|
|
17
100
|
});
|
|
18
101
|
export const annotations = {
|
|
19
102
|
title: 'Updates a response in a collection. For a complete list of properties, see the [Postman Collection Format documentation](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html).',
|
|
@@ -29,8 +112,38 @@ export async function handler(args, extra) {
|
|
|
29
112
|
const bodyPayload = {};
|
|
30
113
|
if (args.name !== undefined)
|
|
31
114
|
bodyPayload.name = args.name;
|
|
115
|
+
if (args.description !== undefined)
|
|
116
|
+
bodyPayload.description = args.description;
|
|
117
|
+
if (args.url !== undefined)
|
|
118
|
+
bodyPayload.url = args.url;
|
|
119
|
+
if (args.method !== undefined)
|
|
120
|
+
bodyPayload.method = args.method;
|
|
121
|
+
if (args.headers !== undefined)
|
|
122
|
+
bodyPayload.headers = args.headers;
|
|
123
|
+
if (args.dataMode !== undefined)
|
|
124
|
+
bodyPayload.dataMode = args.dataMode;
|
|
125
|
+
if (args.rawModeData !== undefined)
|
|
126
|
+
bodyPayload.rawModeData = args.rawModeData;
|
|
127
|
+
if (args.dataOptions !== undefined)
|
|
128
|
+
bodyPayload.dataOptions = args.dataOptions;
|
|
32
129
|
if (args.responseCode !== undefined)
|
|
33
130
|
bodyPayload.responseCode = args.responseCode;
|
|
131
|
+
if (args.status !== undefined)
|
|
132
|
+
bodyPayload.status = args.status;
|
|
133
|
+
if (args.time !== undefined)
|
|
134
|
+
bodyPayload.time = args.time;
|
|
135
|
+
if (args.cookies !== undefined)
|
|
136
|
+
bodyPayload.cookies = args.cookies;
|
|
137
|
+
if (args.mime !== undefined)
|
|
138
|
+
bodyPayload.mime = args.mime;
|
|
139
|
+
if (args.text !== undefined)
|
|
140
|
+
bodyPayload.text = args.text;
|
|
141
|
+
if (args.language !== undefined)
|
|
142
|
+
bodyPayload.language = args.language;
|
|
143
|
+
if (args.rawDataType !== undefined)
|
|
144
|
+
bodyPayload.rawDataType = args.rawDataType;
|
|
145
|
+
if (args.requestObject !== undefined)
|
|
146
|
+
bodyPayload.requestObject = args.requestObject;
|
|
34
147
|
const options = {
|
|
35
148
|
body: JSON.stringify(bodyPayload),
|
|
36
149
|
contentType: ContentType.Json,
|
|
@@ -2,7 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
import { ContentType } from '../clients/postman.js';
|
|
3
3
|
import { asMcpError, McpError } from './utils/toolHelpers.js';
|
|
4
4
|
export const method = 'updateWorkspace';
|
|
5
|
-
export const description = 'Updates a workspace.\n\n**Note:**\n\n-
|
|
5
|
+
export const description = 'Updates a workspace.\n\n**Note:**\n\n- This endpoint does not support the following visibility changes:\n - \\`private\\` to \\`public\\`, \\`public\\` to \\`private\\`, and \\`private\\` to \\`personal\\` for **Free** and **Solo** [plans](https://www.postman.com/pricing/).\n - \\`public\\` to \\`personal\\` for team users only.\n- There are rate limits when publishing public workspaces.\n- Public team workspace names must be unique.\n';
|
|
6
6
|
export const parameters = z.object({
|
|
7
7
|
workspaceId: z.string().describe("The workspace's ID."),
|
|
8
8
|
workspace: z
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import nunjucks from 'nunjucks';
|
|
4
|
+
export function createErrorTemplateRenderer(errorsDir) {
|
|
5
|
+
const env = nunjucks.configure(errorsDir, {
|
|
6
|
+
autoescape: false,
|
|
7
|
+
noCache: false,
|
|
8
|
+
throwOnUndefined: false,
|
|
9
|
+
});
|
|
10
|
+
env.addFilter('default', (val, defaultVal = '') => val === undefined || val === null ? defaultVal : val);
|
|
11
|
+
return (toolName, statusCode, context) => {
|
|
12
|
+
const templateFile = `${toolName}.${statusCode}.njk`;
|
|
13
|
+
const templatePath = join(errorsDir, templateFile);
|
|
14
|
+
if (!existsSync(templatePath))
|
|
15
|
+
return null;
|
|
16
|
+
try {
|
|
17
|
+
return env.render(templateFile, context);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Workspaces
|
|
2
2
|
|
|
3
|
-
| id | name | type | visibility | createdBy | scim |
|
|
4
|
-
|
|
5
|
-
{% for item in workspaces %}| {{ item.id }} | {{ item.name }} | {{ item.type }} | {{ item.visibility }} | {{ item.createdBy }} | {{ item.scim | dump }} |
|
|
3
|
+
| id | name | type | visibility | createdBy | about | createdAt | updatedAt | scim |
|
|
4
|
+
|---|---|---|---|---|---|---|---|---|
|
|
5
|
+
{% for item in workspaces %}| {{ item.id }} | {{ item.name }} | {{ item.type }} | {{ item.visibility }} | {{ item.createdBy }} | {{ item.about }} | {{ item.createdAt }} | {{ item.updatedAt }} | {{ item.scim | dump }} |
|
|
6
6
|
{% endfor %}
|
package/package.json
CHANGED
|
@@ -1,22 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@postman/postman-mcp-server",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "A simple MCP server to operate on the Postman API",
|
|
5
5
|
"mcpName": "com.postman/postman-mcp-server",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
7
7
|
"type": "module",
|
|
8
|
-
"scripts": {
|
|
9
|
-
"start:stdio": "node dist/src/index.js",
|
|
10
|
-
"build": "eslint --fix ./src && prettier --write \"src/**/*.ts\" && tsc",
|
|
11
|
-
"prepack": "npm run build",
|
|
12
|
-
"test": "vitest",
|
|
13
|
-
"lint": "eslint",
|
|
14
|
-
"lint:fix": "eslint --fix",
|
|
15
|
-
"preversion": "npm run build",
|
|
16
|
-
"version": "git add dist/",
|
|
17
|
-
"release": "npm version",
|
|
18
|
-
"release-custom": "node scripts/release.js"
|
|
19
|
-
},
|
|
20
8
|
"bin": "dist/src/index.js",
|
|
21
9
|
"files": [
|
|
22
10
|
"dist",
|
|
@@ -27,23 +15,23 @@
|
|
|
27
15
|
"access": "public"
|
|
28
16
|
},
|
|
29
17
|
"dependencies": {
|
|
30
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
31
|
-
"dotenv": "^17.
|
|
32
|
-
"newman": "^6.2.
|
|
18
|
+
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
19
|
+
"dotenv": "^17.3.1",
|
|
20
|
+
"newman": "^6.2.2",
|
|
33
21
|
"nunjucks": "^3.2.4",
|
|
34
22
|
"uuid": "^13.0.0",
|
|
35
23
|
"zod": "^3.25.76"
|
|
36
24
|
},
|
|
37
25
|
"devDependencies": {
|
|
38
|
-
"@eslint/js": "^
|
|
26
|
+
"@eslint/js": "^10.0.1",
|
|
39
27
|
"@types/node": "^24",
|
|
40
|
-
"eslint": "^
|
|
28
|
+
"eslint": "^10.0.2",
|
|
41
29
|
"eslint-config-prettier": "^10.1.8",
|
|
42
|
-
"eslint-plugin-unused-imports": "^4.
|
|
43
|
-
"prettier": "^3.
|
|
30
|
+
"eslint-plugin-unused-imports": "^4.4.1",
|
|
31
|
+
"prettier": "^3.8.1",
|
|
44
32
|
"typescript": "^5.9.3",
|
|
45
|
-
"typescript-eslint": "^8.
|
|
46
|
-
"vitest": "^4.0.
|
|
33
|
+
"typescript-eslint": "^8.56.1",
|
|
34
|
+
"vitest": "^4.0.18"
|
|
47
35
|
},
|
|
48
36
|
"engines": {
|
|
49
37
|
"node": ">=20.0.0"
|
|
@@ -57,5 +45,17 @@
|
|
|
57
45
|
"bugs": {
|
|
58
46
|
"url": "https://github.com/postmanlabs/postman-mcp-server/issues"
|
|
59
47
|
},
|
|
60
|
-
"homepage": "https://github.com/postmanlabs/postman-mcp-server#readme"
|
|
61
|
-
|
|
48
|
+
"homepage": "https://github.com/postmanlabs/postman-mcp-server#readme",
|
|
49
|
+
"scripts": {
|
|
50
|
+
"preinstall": "npx only-allow pnpm",
|
|
51
|
+
"start:stdio": "node dist/src/index.js",
|
|
52
|
+
"build": "eslint --fix ./src && prettier --write \"src/**/*.ts\" && tsc",
|
|
53
|
+
"test": "vitest",
|
|
54
|
+
"lint": "eslint",
|
|
55
|
+
"lint:fix": "eslint --fix",
|
|
56
|
+
"preversion": "pnpm run build",
|
|
57
|
+
"version": "git add dist/",
|
|
58
|
+
"release": "pnpm version",
|
|
59
|
+
"release-custom": "node scripts/release.js"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { asMcpError, McpError } from './utils/toolHelpers.js';
|
|
3
|
-
export const method = 'deletePanElementOrFolder';
|
|
4
|
-
export const description = "Removes an element or delete a folder from your team's [Private API Network](https://learning.postman.com/docs/collaborating-in-postman/adding-private-network/).\n\n**Note:**\n\nRemoving an API, collection, or workspace element does not delete it. It only removes it from the Private API Network folder.\n";
|
|
5
|
-
export const parameters = z.object({
|
|
6
|
-
elementId: z
|
|
7
|
-
.string()
|
|
8
|
-
.describe("The element's ID or UUID. For Postman Collections you must pass the collection's UID (`userId`-`collectionId`) value."),
|
|
9
|
-
elementType: z.enum(['api', 'folder', 'collection', 'workspace']).describe('The element type.'),
|
|
10
|
-
});
|
|
11
|
-
export const annotations = {
|
|
12
|
-
title: "Removes an element or delete a folder from your team's [Private API Network](https://learning.postman.com/docs/collaborating-in-postman/adding-private-network/).",
|
|
13
|
-
readOnlyHint: false,
|
|
14
|
-
destructiveHint: true,
|
|
15
|
-
idempotentHint: true,
|
|
16
|
-
};
|
|
17
|
-
export async function handler(args, extra) {
|
|
18
|
-
try {
|
|
19
|
-
const endpoint = `/network/private/${args.elementType}/${args.elementId}`;
|
|
20
|
-
const query = new URLSearchParams();
|
|
21
|
-
const url = query.toString() ? `${endpoint}?${query.toString()}` : endpoint;
|
|
22
|
-
const options = {
|
|
23
|
-
headers: extra.headers,
|
|
24
|
-
};
|
|
25
|
-
const result = await extra.client.delete(url, options);
|
|
26
|
-
return {
|
|
27
|
-
content: [
|
|
28
|
-
{
|
|
29
|
-
type: 'text',
|
|
30
|
-
text: `${typeof result === 'string' ? result : JSON.stringify(result, null, 2)}`,
|
|
31
|
-
},
|
|
32
|
-
],
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
catch (e) {
|
|
36
|
-
if (e instanceof McpError) {
|
|
37
|
-
throw e;
|
|
38
|
-
}
|
|
39
|
-
throw asMcpError(e);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { ContentType } from '../clients/postman.js';
|
|
3
|
-
import { asMcpError, McpError } from './utils/toolHelpers.js';
|
|
4
|
-
export const method = 'postPanElementOrFolder';
|
|
5
|
-
export const description = "Publishes a element or creates a folder in your team's [Private API Network](https://learning.postman.com/docs/collaborating-in-postman/adding-private-network/). An element is a Postman API, collection, or workspace.\n\n**Note:**\n\nYou can only pass one element object type per call. For example, you cannot pass both \\`api\\` and \\`collection\\` in a single request.\n";
|
|
6
|
-
export const parameters = z.object({
|
|
7
|
-
body: z.union([
|
|
8
|
-
z.object({
|
|
9
|
-
api: z
|
|
10
|
-
.object({
|
|
11
|
-
id: z.string().describe("The API's ID."),
|
|
12
|
-
parentFolderId: z.number().int().describe("The API's parent folder ID."),
|
|
13
|
-
})
|
|
14
|
-
.optional(),
|
|
15
|
-
}),
|
|
16
|
-
z.object({
|
|
17
|
-
collection: z
|
|
18
|
-
.object({
|
|
19
|
-
id: z.string().describe("The collection's ID."),
|
|
20
|
-
parentFolderId: z.number().int().describe("The collection's parent folder ID."),
|
|
21
|
-
environments: z
|
|
22
|
-
.array(z.string().describe("An environment's UID."))
|
|
23
|
-
.describe('A list of environment UIDs (`userId`-`environmentId`) to add to the collection.')
|
|
24
|
-
.optional(),
|
|
25
|
-
})
|
|
26
|
-
.optional(),
|
|
27
|
-
}),
|
|
28
|
-
z.object({
|
|
29
|
-
workspace: z
|
|
30
|
-
.object({
|
|
31
|
-
id: z.string().describe("The workspace's ID."),
|
|
32
|
-
parentFolderId: z.number().int().describe("The workspace's parent folder ID."),
|
|
33
|
-
})
|
|
34
|
-
.optional(),
|
|
35
|
-
}),
|
|
36
|
-
z.object({
|
|
37
|
-
folder: z
|
|
38
|
-
.object({
|
|
39
|
-
name: z.string().describe("The folder's name."),
|
|
40
|
-
description: z.string().describe("The folder's description.").optional(),
|
|
41
|
-
parentFolderId: z
|
|
42
|
-
.number()
|
|
43
|
-
.int()
|
|
44
|
-
.describe("The folder's parent folder ID. This value defaults to `0`. To create a folder at the root level, omit this property.")
|
|
45
|
-
.default(0),
|
|
46
|
-
})
|
|
47
|
-
.optional(),
|
|
48
|
-
}),
|
|
49
|
-
]),
|
|
50
|
-
});
|
|
51
|
-
export const annotations = {
|
|
52
|
-
title: "Publishes a element or creates a folder in your team's [Private API Network](https://learning.postman.com/docs/collaborating-in-postman/adding-private-network/). An element is a Postman API, collection, or workspace.",
|
|
53
|
-
readOnlyHint: false,
|
|
54
|
-
destructiveHint: false,
|
|
55
|
-
idempotentHint: false,
|
|
56
|
-
};
|
|
57
|
-
export async function handler(args, extra) {
|
|
58
|
-
try {
|
|
59
|
-
const endpoint = `/network/private`;
|
|
60
|
-
const query = new URLSearchParams();
|
|
61
|
-
const url = query.toString() ? `${endpoint}?${query.toString()}` : endpoint;
|
|
62
|
-
const bodyPayload = args.body;
|
|
63
|
-
const options = {
|
|
64
|
-
body: JSON.stringify(bodyPayload),
|
|
65
|
-
contentType: ContentType.Json,
|
|
66
|
-
headers: extra.headers,
|
|
67
|
-
};
|
|
68
|
-
const result = await extra.client.post(url, options);
|
|
69
|
-
return {
|
|
70
|
-
content: [
|
|
71
|
-
{
|
|
72
|
-
type: 'text',
|
|
73
|
-
text: `${typeof result === 'string' ? result : JSON.stringify(result, null, 2)}`,
|
|
74
|
-
},
|
|
75
|
-
],
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
catch (e) {
|
|
79
|
-
if (e instanceof McpError) {
|
|
80
|
-
throw e;
|
|
81
|
-
}
|
|
82
|
-
throw asMcpError(e);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { ContentType } from '../clients/postman.js';
|
|
3
|
-
import { asMcpError, McpError } from './utils/toolHelpers.js';
|
|
4
|
-
export const method = 'updatePanElementOrFolder';
|
|
5
|
-
export const description = "Updates an element or folder in your team's [Private API Network](https://learning.postman.com/docs/collaborating-in-postman/adding-private-network/).\n\n**Note:**\n\nYou can only pass one element object type per call. For example, you cannot pass both \\`api\\` and \\`collection\\` in a single request.\n";
|
|
6
|
-
export const parameters = z.object({
|
|
7
|
-
elementId: z
|
|
8
|
-
.string()
|
|
9
|
-
.describe("The element's ID or UUID. For Postman Collections you must pass the collection's UID (`userId`-`collectionId`) value."),
|
|
10
|
-
elementType: z.enum(['api', 'folder', 'collection', 'workspace']).describe('The element type.'),
|
|
11
|
-
body: z.union([
|
|
12
|
-
z.object({
|
|
13
|
-
api: z
|
|
14
|
-
.object({
|
|
15
|
-
parentFolderId: z.number().int().describe("The API's new parent folder ID.").optional(),
|
|
16
|
-
})
|
|
17
|
-
.optional(),
|
|
18
|
-
}),
|
|
19
|
-
z.object({
|
|
20
|
-
collection: z
|
|
21
|
-
.object({
|
|
22
|
-
parentFolderId: z
|
|
23
|
-
.number()
|
|
24
|
-
.int()
|
|
25
|
-
.describe("The collection's new parent folder ID.")
|
|
26
|
-
.optional(),
|
|
27
|
-
environments: z
|
|
28
|
-
.object({
|
|
29
|
-
$add: z
|
|
30
|
-
.array(z.string().describe('The ID of environment to add to the collection.'))
|
|
31
|
-
.optional(),
|
|
32
|
-
$remove: z
|
|
33
|
-
.array(z.string().describe('The ID of environment to remove from the collection.'))
|
|
34
|
-
.optional(),
|
|
35
|
-
})
|
|
36
|
-
.describe("The collection's updated environments.")
|
|
37
|
-
.optional(),
|
|
38
|
-
})
|
|
39
|
-
.optional(),
|
|
40
|
-
}),
|
|
41
|
-
z.object({
|
|
42
|
-
workspace: z
|
|
43
|
-
.object({
|
|
44
|
-
parentFolderId: z
|
|
45
|
-
.number()
|
|
46
|
-
.int()
|
|
47
|
-
.describe("The workspace's new parent folder ID.")
|
|
48
|
-
.optional(),
|
|
49
|
-
})
|
|
50
|
-
.optional(),
|
|
51
|
-
}),
|
|
52
|
-
z.object({
|
|
53
|
-
folder: z
|
|
54
|
-
.object({
|
|
55
|
-
name: z.string().describe("The folder's new name.").optional(),
|
|
56
|
-
description: z.string().describe("The folder's updated description.").optional(),
|
|
57
|
-
parentFolderId: z
|
|
58
|
-
.number()
|
|
59
|
-
.int()
|
|
60
|
-
.describe("The folder's new parent folder ID.")
|
|
61
|
-
.optional(),
|
|
62
|
-
})
|
|
63
|
-
.optional(),
|
|
64
|
-
}),
|
|
65
|
-
]),
|
|
66
|
-
});
|
|
67
|
-
export const annotations = {
|
|
68
|
-
title: "Updates an element or folder in your team's [Private API Network](https://learning.postman.com/docs/collaborating-in-postman/adding-private-network/).",
|
|
69
|
-
readOnlyHint: false,
|
|
70
|
-
destructiveHint: false,
|
|
71
|
-
idempotentHint: true,
|
|
72
|
-
};
|
|
73
|
-
export async function handler(args, extra) {
|
|
74
|
-
try {
|
|
75
|
-
const endpoint = `/network/private/${args.elementType}/${args.elementId}`;
|
|
76
|
-
const query = new URLSearchParams();
|
|
77
|
-
const url = query.toString() ? `${endpoint}?${query.toString()}` : endpoint;
|
|
78
|
-
const bodyPayload = args.body;
|
|
79
|
-
const options = {
|
|
80
|
-
body: JSON.stringify(bodyPayload),
|
|
81
|
-
contentType: ContentType.Json,
|
|
82
|
-
headers: extra.headers,
|
|
83
|
-
};
|
|
84
|
-
const result = await extra.client.put(url, options);
|
|
85
|
-
return {
|
|
86
|
-
content: [
|
|
87
|
-
{
|
|
88
|
-
type: 'text',
|
|
89
|
-
text: `${typeof result === 'string' ? result : JSON.stringify(result, null, 2)}`,
|
|
90
|
-
},
|
|
91
|
-
],
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
catch (e) {
|
|
95
|
-
if (e instanceof McpError) {
|
|
96
|
-
throw e;
|
|
97
|
-
}
|
|
98
|
-
throw asMcpError(e);
|
|
99
|
-
}
|
|
100
|
-
}
|