getSpecCollections
Retrieve paginated collections generated from a specific API specification using its spec ID.
Instructions
Gets all of an API specification's generated collections.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| specId | Yes | The spec's ID. | |
| elementType | Yes | The `collection` element type. | |
| limit | No | The maximum number of rows to return in the response. | |
| cursor | No | The pointer to the first record of the set of paginated results. To view the next response, use the `nextCursor` value for this parameter. |
Implementation Reference
- src/tools/getSpecCollections.ts:30-58 (handler)The handler function that executes the getSpecCollections tool logic. It calls the Postman API endpoint /specs/{specId}/generations/{elementType} with optional limit/cursor query params for pagination.
export async function handler( args: z.infer<typeof parameters>, extra: { client: PostmanAPIClient; headers?: IsomorphicHeaders; serverContext?: ServerContext } ): Promise<CallToolResult> { try { const endpoint = `/specs/${args.specId}/generations/${args.elementType}`; const query = new URLSearchParams(); if (args.limit !== undefined) query.set('limit', String(args.limit)); if (args.cursor !== undefined) query.set('cursor', String(args.cursor)); const url = query.toString() ? `${endpoint}?${query.toString()}` : endpoint; const options: any = { headers: extra.headers, }; const result = await extra.client.get(url, options); return { content: [ { type: 'text', text: `${typeof result === 'string' ? result : JSON.stringify(result, null, 2)}`, }, ], }; } catch (e: unknown) { if (e instanceof McpError) { throw e; } throw asMcpError(e); } } - src/tools/getSpecCollections.ts:6-28 (schema)The method name, description, Zod schema (parameters with specId, elementType, limit, cursor), and annotations for the getSpecCollections tool.
export const method = 'getSpecCollections'; export const description = "Gets all of an API specification's generated collections."; export const parameters = z.object({ specId: z.string().describe("The spec's ID."), elementType: z.literal('collection').describe('The `collection` element type.'), limit: z .number() .int() .describe('The maximum number of rows to return in the response.') .default(10), cursor: z .string() .describe( 'The pointer to the first record of the set of paginated results. To view the next response, use the `nextCursor` value for this parameter.' ) .optional(), }); export const annotations = { title: "Gets all of an API specification's generated collections.", readOnlyHint: true, destructiveHint: false, idempotentHint: true, }; - src/enabledResources.ts:1-161 (registration)Registration of 'getSpecCollections' in the 'full' list of enabled resources (line 17) and the 'minimal' list (line 182), making it available as a tool.
const full = [ // Collections 'createCollection', 'deleteCollection', 'generateCollection', 'getCollection', 'getCollections', 'patchCollection', 'putCollection', 'getCollectionTags', 'updateCollectionTags', 'getCollectionUpdatesTasks', 'syncCollectionWithSpec', 'syncSpecWithCollection', 'generateSpecFromCollection', 'getGeneratedCollectionSpecs', 'getSpecCollections', // Collection Forks 'getCollectionForks', 'getSourceCollectionStatus', 'getCollectionsForkedByUser', 'pullCollectionChanges', 'createCollectionFork', 'mergeCollectionFork', // Collection Folders 'createCollectionFolder', 'deleteCollectionFolder', 'getCollectionFolder', 'updateCollectionFolder', 'transferCollectionFolders', // Collection Requests 'createCollectionRequest', 'deleteCollectionRequest', 'getCollectionRequest', 'updateCollectionRequest', 'transferCollectionRequests', // Collection Responses 'createCollectionResponse', 'deleteCollectionResponse', 'getCollectionResponse', 'updateCollectionResponse', 'transferCollectionResponses', // Collection Runner 'runCollection', // Comments 'createCollectionComment', 'deleteCollectionComment', 'getCollectionComments', 'updateCollectionComment', 'updateApiCollectionComment', 'createFolderComment', 'deleteFolderComment', 'getFolderComments', 'updateFolderComment', 'createRequestComment', 'deleteRequestComment', 'getRequestComments', 'updateRequestComment', 'createResponseComment', 'deleteResponseComment', 'getResponseComments', 'updateResponseComment', 'resolveCommentThread', // Environments 'createEnvironment', 'deleteEnvironment', 'getEnvironment', 'getEnvironments', 'patchEnvironment', 'putEnvironment', // Mocks 'createMock', 'deleteMock', 'getMock', 'getMocks', 'updateMock', 'publishMock', 'unpublishMock', // Monitors 'createMonitor', 'deleteMonitor', 'getMonitor', 'getMonitors', 'updateMonitor', 'runMonitor', // Specs 'createSpec', 'deleteSpec', 'getSpec', 'getAllSpecs', 'getSpecDefinition', 'updateSpecProperties', 'createSpecFile', 'getSpecFile', 'getSpecFiles', 'updateSpecFile', // Workspaces 'createWorkspace', 'deleteWorkspace', 'getWorkspace', 'getWorkspaces', 'updateWorkspace', 'getWorkspaceGlobalVariables', 'updateWorkspaceGlobalVariables', 'getWorkspaceTags', 'updateWorkspaceTags', // PAN (Private API Network) 'listPrivateNetworkWorkspaces', 'listPrivateNetworkAddRequests', 'removeWorkspaceFromPrivateNetwork', 'addWorkspaceToPrivateNetwork', 'respondPrivateNetworkAddRequest', // // Documentation 'publishDocumentation', 'unpublishDocumentation', // Tasks and Status 'getAsyncSpecTaskStatus', 'getStatusOfAnAsyncApiTask', // User and Tags 'getAuthenticatedUser', 'getTaggedEntities', // Code Generation 'getCodeGenerationInstructions', // Transfer 'transferCollectionFolders', 'transferCollectionResponses', 'transferCollectionResponses', // 'asyncMergePullCollectionFork' skipped // 'asyncMergePullCollectionTaskStatus' skipped // Duplicate Collection 'duplicateCollection', 'getDuplicateCollectionTaskStatus', 'deleteApiCollectionComment', 'deleteSpecFile', 'getEnabledTools', 'searchPostmanElementsInPublicNetwork', 'searchPostmanElementsInPrivateNetwork', // Analytics 'getAnalyticsData', 'getAnalyticsMetadata', ] as const;