Skip to content

Commit 26df31e

Browse files
chore: sync tools from postman-mcp-server (#25)
Co-authored-by: postman-distribution-bot[bot] <124679000+postman-distribution-bot[bot]@users.noreply.github.com>
1 parent cb18205 commit 26df31e

24 files changed

+494
-68
lines changed

dist/src/tools/create_collection.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { z } from 'zod';
22
import { fetchPostmanAPI, ContentType } from '../clients/postman.js';
33
export const method = 'create-collection';
4-
export const description = 'Creates a collection using the [Postman Collection v2.1.0 schema format](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html).\n\n**Note:**\n\n- If you do not include the \\`workspace\\` query parameter, the system creates the collection in your "My Workspace" workspace.\n- For a complete list of available property values for this endpoint, use the following references available in the [Postman Collection Format documentation](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html):\n - \\`info\\` object — Refer to the **Information** entry.\n - \\`item\\` object — Refer to the **Items** entry.\n- For all other possible values, refer to the [Postman Collection Format documentation](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html).\n';
4+
export const description = 'Creates a collection using the [Postman Collection v2.1.0 schema format](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html).\n\n**Note:**\n\n- If you do not include the \\`workspace\\` query parameter, the system creates the collection in the oldest personal Internal workspace you own.\n- For a complete list of available property values for this endpoint, use the following references available in the [Postman Collection Format documentation](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html):\n - \\`info\\` object — Refer to the **Information** entry.\n - \\`item\\` object — Refer to the **Items** entry.\n- For all other possible values, refer to the [Postman Collection Format documentation](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html).\n';
55
export const parameters = z.object({
6-
workspace: z.string().describe("The workspace's ID.").optional(),
6+
workspace: z.string().describe("The workspace's ID."),
77
collection: z
88
.object({
99
info: z
@@ -32,7 +32,10 @@ export const parameters = z.object({
3232
.string()
3333
.describe("The variable's description. Doesn't apply to collection-level variables.")
3434
.optional(),
35-
disabled: z.boolean().default(false),
35+
disabled: z
36+
.boolean()
37+
.describe('If true, the variable is not enabled.')
38+
.default(false),
3639
})
3740
.describe('Information about the variable.'))
3841
.describe("A list of the collection's [variables](https://learning.postman.com/docs/sending-requests/variables/variables/). Make certain not to include sensitive information in variables.")
@@ -515,7 +518,10 @@ export const parameters = z.object({
515518
.string()
516519
.describe("The variable's description. Doesn't apply to collection-level variables.")
517520
.optional(),
518-
disabled: z.boolean().default(false),
521+
disabled: z
522+
.boolean()
523+
.describe('If true, the variable is not enabled.')
524+
.default(false),
519525
})
520526
.describe('Information about the variable.'))
521527
.describe("A list of the collection's [variables](https://learning.postman.com/docs/sending-requests/variables/variables/). Make certain not to include sensitive information in variables.")
@@ -771,7 +777,7 @@ export const parameters = z.object({
771777
.optional(),
772778
});
773779
export const annotations = {
774-
title: 'Creates a collection using the [Postman Collection v2.1.0 schema format](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html).\n\n**Note:**\n\n- If you do not include the \\`workspace\\` query parameter, the system creates the collection in your "My Workspace" workspace.\n- For a complete list of available property values for this endpoint, use the following references available in the [Postman Collection Format documentation](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html):\n - \\`info\\` object — Refer to the **Information** entry.\n - \\`item\\` object — Refer to the **Items** entry.\n- For all other possible values, refer to the [Postman Collection Format documentation](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html).\n',
780+
title: 'Creates a collection using the [Postman Collection v2.1.0 schema format](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html).\n\n**Note:**\n\n- If you do not include the \\`workspace\\` query parameter, the system creates the collection in the oldest personal Internal workspace you own.\n- For a complete list of available property values for this endpoint, use the following references available in the [Postman Collection Format documentation](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html):\n - \\`info\\` object — Refer to the **Information** entry.\n - \\`item\\` object — Refer to the **Items** entry.\n- For all other possible values, refer to the [Postman Collection Format documentation](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html).\n',
775781
readOnlyHint: false,
776782
destructiveHint: false,
777783
idempotentHint: false,

dist/src/tools/create_environment.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { z } from 'zod';
22
import { fetchPostmanAPI, ContentType } from '../clients/postman.js';
33
export const method = 'create-environment';
4-
export const description = 'Creates an environment.\n\n**Note:**\n\n- The request body size cannot exceed the maximum allowed size of 30MB.\n- If you receive an HTTP \\`411 Length Required\\` error response, manually pass the \\`Content-Length\\` header and its value in the request header.\n- If you do not include the \\`workspace\\` query parameter, the system creates the collection in your "My Workspace" workspace.\n';
4+
export const description = 'Creates an environment.\n\n**Note:**\n\n- The request body size cannot exceed the maximum allowed size of 30MB.\n- If you receive an HTTP \\`411 Length Required\\` error response, manually pass the \\`Content-Length\\` header and its value in the request header.\n- If you do not include the \\`workspace\\` query parameter, the system creates the environment in the oldest personal Internal workspace you own.\n';
55
export const parameters = z.object({
6-
workspace: z.string().describe("The workspace's ID.").optional(),
6+
workspace: z.string().describe("The workspace's ID."),
77
environment: z
88
.object({
99
name: z.string().describe("The environment's name."),
@@ -17,10 +17,11 @@ export const parameters = z.object({
1717
.describe("Information about the environment's variables.")
1818
.optional(),
1919
})
20+
.describe('Information about the environment.')
2021
.optional(),
2122
});
2223
export const annotations = {
23-
title: 'Creates an environment.\n\n**Note:**\n\n- The request body size cannot exceed the maximum allowed size of 30MB.\n- If you receive an HTTP \\`411 Length Required\\` error response, manually pass the \\`Content-Length\\` header and its value in the request header.\n- If you do not include the \\`workspace\\` query parameter, the system creates the collection in your "My Workspace" workspace.\n',
24+
title: 'Creates an environment.\n\n**Note:**\n\n- The request body size cannot exceed the maximum allowed size of 30MB.\n- If you receive an HTTP \\`411 Length Required\\` error response, manually pass the \\`Content-Length\\` header and its value in the request header.\n- If you do not include the \\`workspace\\` query parameter, the system creates the environment in the oldest personal Internal workspace you own.\n',
2425
readOnlyHint: false,
2526
destructiveHint: false,
2627
idempotentHint: false,

dist/src/tools/create_mock.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { z } from 'zod';
22
import { fetchPostmanAPI, ContentType } from '../clients/postman.js';
33
export const method = 'create-mock';
4-
export const description = 'Creates a mock server in a collection.\n\n**Note:**\n\n- If you do not include the \\`workspaceId\\` query parameter, the system creates the mock server in your [Personal\nworkspace](https://learning.postman.com/docs/collaborating-in-postman/using-workspaces/creating-workspaces/).\n- You cannot create mocks for collections added to an API definition.\n';
4+
export const description = 'Creates a mock server in a collection.\n\n**Note:**\n\n- You cannot create mocks for collections added to an API definition.\n- If you do not include the \\`workspaceId\\` query parameter, the system creates the mock server in the oldest personal Internal workspace you own.\n';
55
export const parameters = z.object({
6-
workspaceId: z.string().describe("The workspace's ID.").optional(),
6+
workspace: z.string().describe("The workspace's ID."),
77
mock: z
88
.object({
99
collection: z.string().describe("The unique ID of the mock's associated collection."),
@@ -20,7 +20,7 @@ export const parameters = z.object({
2020
.optional(),
2121
});
2222
export const annotations = {
23-
title: 'Creates a mock server in a collection.\n\n**Note:**\n\n- If you do not include the \\`workspaceId\\` query parameter, the system creates the mock server in your [Personal\nworkspace](https://learning.postman.com/docs/collaborating-in-postman/using-workspaces/creating-workspaces/).\n- You cannot create mocks for collections added to an API definition.\n',
23+
title: 'Creates a mock server in a collection.\n\n**Note:**\n\n- You cannot create mocks for collections added to an API definition.\n- If you do not include the \\`workspaceId\\` query parameter, the system creates the mock server in the oldest personal Internal workspace you own.\n',
2424
readOnlyHint: false,
2525
destructiveHint: false,
2626
idempotentHint: false,
@@ -29,8 +29,8 @@ export async function handler(params, extra) {
2929
try {
3030
const endpoint = `/mocks`;
3131
const query = new URLSearchParams();
32-
if (params.workspaceId !== undefined)
33-
query.set('workspaceId', String(params.workspaceId));
32+
if (params.workspace !== undefined)
33+
query.set('workspace', String(params.workspace));
3434
const url = query.toString() ? `${endpoint}?${query.toString()}` : endpoint;
3535
const bodyPayload = {};
3636
if (params.mock !== undefined)

dist/src/tools/create_monitor.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { z } from 'zod';
22
import { fetchPostmanAPI, ContentType } from '../clients/postman.js';
33
export const method = 'create-monitor';
4-
export const description = 'Creates a monitor.\n\n**Note:**\n\n- You cannot create monitors for collections added to an API definition.\n- If you do not pass the \\`workspace\\` parameter, the monitor is created in your personal workspace.\n';
4+
export const description = 'Creates a monitor.\n\n**Note:**\n\n- You cannot create monitors for collections added to an API definition.\n- If you do not pass the \\`workspace\\` query parameter, the system creates the monitor in the oldest personal Internal workspace you own.\n';
55
export const parameters = z.object({
6-
workspace: z.string().describe("The workspace's ID.").optional(),
6+
workspace: z.string().describe("The workspace's ID."),
77
monitor: z
88
.object({
99
name: z.string().describe("The monitor's name."),
@@ -106,10 +106,11 @@ export const parameters = z.object({
106106
.describe("Information about the monitor's notification settings.")
107107
.optional(),
108108
})
109+
.describe('Information about the monitor.')
109110
.optional(),
110111
});
111112
export const annotations = {
112-
title: 'Creates a monitor.\n\n**Note:**\n\n- You cannot create monitors for collections added to an API definition.\n- If you do not pass the \\`workspace\\` parameter, the monitor is created in your personal workspace.\n',
113+
title: 'Creates a monitor.\n\n**Note:**\n\n- You cannot create monitors for collections added to an API definition.\n- If you do not pass the \\`workspace\\` query parameter, the system creates the monitor in the oldest personal Internal workspace you own.\n',
113114
readOnlyHint: false,
114115
destructiveHint: false,
115116
idempotentHint: false,

dist/src/tools/create_spec.js

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,40 @@
11
import { z } from 'zod';
22
import { fetchPostmanAPI, ContentType } from '../clients/postman.js';
33
export const method = 'create-spec';
4-
export const description = "Creates an API specification in Postman's [Spec Hub](https://learning.postman.com/docs/design-apis/specifications/overview/).\n\n**Note:**\n- Postman supports OpenAPI 3.0 and AsyncAPI 2.0 specifications.\n- This endpoint does not yet support multiple files.\n";
4+
export const description = "Creates an API specification in Postman's [Spec Hub](https://learning.postman.com/docs/design-apis/specifications/overview/). Specifications can be single or multi-file.\n\n**Note:**\n- Postman supports OpenAPI 3.0 and AsyncAPI 2.0 specifications.\n- If the file path contains a \\`/\\` (forward slash) character, then a folder is created. For example, if the path is the \\`components/schemas.json\\` value, then a \\`components\\` folder is created with the \\`schemas.json\\` file inside.\n- Multi-file specifications can only have one root file.\n- Files cannot exceed a maximum of 10 MB in size.\n";
55
export const parameters = z.object({
66
workspaceId: z.string().describe("The workspace's ID."),
77
name: z.string().describe("The specification's name."),
88
type: z.enum(['OPENAPI:3.0', 'ASYNCAPI:2.0']).describe("The specification's type."),
99
files: z
10-
.array(z.object({
11-
path: z
12-
.string()
13-
.describe("The file's path. Accepts the `index.json` or `index.yaml` value."),
14-
content: z.string().describe("The file's stringified contents."),
10+
.array(z.any().superRefine((x, ctx) => {
11+
const schemas = [
12+
z.object({
13+
path: z.string().describe("The file's path. Accepts JSON or YAML files."),
14+
content: z.string().describe("The file's stringified contents."),
15+
type: z
16+
.enum(['DEFAULT', 'ROOT'])
17+
.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'),
18+
}),
19+
z.object({
20+
path: z.string().describe("The file's path. Accepts JSON or YAML files."),
21+
content: z.string().describe("The file's stringified contents."),
22+
}),
23+
];
24+
const errors = schemas.reduce((errors, schema) => ((result) => (result.error ? [...errors, result.error] : errors))(schema.safeParse(x)), []);
25+
if (schemas.length - errors.length !== 1) {
26+
ctx.addIssue({
27+
path: ctx.path,
28+
code: 'invalid_union',
29+
unionErrors: errors,
30+
message: 'Invalid input: Should pass single schema',
31+
});
32+
}
1533
}))
1634
.describe("A list of the specification's files and their contents."),
1735
});
1836
export const annotations = {
19-
title: "Creates an API specification in Postman's [Spec Hub](https://learning.postman.com/docs/design-apis/specifications/overview/).\n\n**Note:**\n- Postman supports OpenAPI 3.0 and AsyncAPI 2.0 specifications.\n- This endpoint does not yet support multiple files.\n",
37+
title: "Creates an API specification in Postman's [Spec Hub](https://learning.postman.com/docs/design-apis/specifications/overview/). Specifications can be single or multi-file.\n\n**Note:**\n- Postman supports OpenAPI 3.0 and AsyncAPI 2.0 specifications.\n- If the file path contains a \\`/\\` (forward slash) character, then a folder is created. For example, if the path is the \\`components/schemas.json\\` value, then a \\`components\\` folder is created with the \\`schemas.json\\` file inside.\n- Multi-file specifications can only have one root file.\n- Files cannot exceed a maximum of 10 MB in size.\n",
2038
readOnlyHint: false,
2139
destructiveHint: false,
2240
idempotentHint: false,

dist/src/tools/create_spec_file.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { z } from 'zod';
2+
import { fetchPostmanAPI, ContentType } from '../clients/postman.js';
3+
export const method = 'create-spec-file';
4+
export const description = 'Creates an API specification file.\n\n**Note:**\n\n- If the file path contains a \\`/\\` (forward slash) character, then a folder is created. For example, if the path is the \\`components/schemas.json\\` value, then a \\`components\\` folder is created with the \\`schemas.json\\` file inside.\n- Creating a spec file assigns it the \\`DEFAULT\\` file type.\n- Multi-file specifications can only have one root file.\n- Files cannot exceed a maximum of 10 MB in size.\n';
5+
export const parameters = z.object({
6+
specId: z.string().describe("The spec's ID."),
7+
path: z.string().describe("The file's path. Accepts JSON or YAML files."),
8+
content: z.string().describe("The file's stringified contents."),
9+
});
10+
export const annotations = {
11+
title: 'Creates an API specification file.\n\n**Note:**\n\n- If the file path contains a \\`/\\` (forward slash) character, then a folder is created. For example, if the path is the \\`components/schemas.json\\` value, then a \\`components\\` folder is created with the \\`schemas.json\\` file inside.\n- Creating a spec file assigns it the \\`DEFAULT\\` file type.\n- Multi-file specifications can only have one root file.\n- Files cannot exceed a maximum of 10 MB in size.\n',
12+
readOnlyHint: false,
13+
destructiveHint: false,
14+
idempotentHint: false,
15+
};
16+
export async function handler(params, extra) {
17+
try {
18+
const endpoint = `/specs/${params.specId}/files`;
19+
const query = new URLSearchParams();
20+
const url = query.toString() ? `${endpoint}?${query.toString()}` : endpoint;
21+
const bodyPayload = {};
22+
if (params.path !== undefined)
23+
bodyPayload.path = params.path;
24+
if (params.content !== undefined)
25+
bodyPayload.content = params.content;
26+
const result = await fetchPostmanAPI(url, {
27+
method: 'POST',
28+
body: JSON.stringify(bodyPayload),
29+
contentType: ContentType.Json,
30+
apiKey: extra.apiKey,
31+
headers: extra.headers,
32+
});
33+
return {
34+
content: [
35+
{
36+
type: 'text',
37+
text: `${typeof result === 'string' ? result : JSON.stringify(result, null, 2)}`,
38+
},
39+
],
40+
};
41+
}
42+
catch (e) {
43+
return {
44+
content: [{ type: 'text', text: `Failed: ${e.message}` }],
45+
};
46+
}
47+
}

dist/src/tools/delete_spec_file.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { z } from 'zod';
2+
import { fetchPostmanAPI } from '../clients/postman.js';
3+
export const method = 'delete-spec-file';
4+
export const description = 'Deletes a file in an API specification. On success, this returns an HTTP \\`204 No Content\\` response.';
5+
export const parameters = z.object({
6+
specId: z.string().describe("The spec's ID."),
7+
filePath: z.string().describe('The path to the file.'),
8+
});
9+
export const annotations = {
10+
title: 'Deletes a file in an API specification. On success, this returns an HTTP \\`204 No Content\\` response.',
11+
readOnlyHint: false,
12+
destructiveHint: true,
13+
idempotentHint: true,
14+
};
15+
export async function handler(params, extra) {
16+
try {
17+
const endpoint = `/specs/${params.specId}/files/${params.filePath}`;
18+
const query = new URLSearchParams();
19+
const url = query.toString() ? `${endpoint}?${query.toString()}` : endpoint;
20+
const result = await fetchPostmanAPI(url, {
21+
method: 'DELETE',
22+
apiKey: extra.apiKey,
23+
headers: extra.headers,
24+
});
25+
return {
26+
content: [
27+
{
28+
type: 'text',
29+
text: `${typeof result === 'string' ? result : JSON.stringify(result, null, 2)}`,
30+
},
31+
],
32+
};
33+
}
34+
catch (e) {
35+
return {
36+
content: [{ type: 'text', text: `Failed: ${e.message}` }],
37+
};
38+
}
39+
}

0 commit comments

Comments
 (0)