Skip to main content
Glama
getCollection.ts2.49 kB
import { z } from 'zod'; import { PostmanAPIClient } from '../../clients/postman.js'; import { IsomorphicHeaders, CallToolResult } from '@modelcontextprotocol/sdk/types.js'; import { ServerContext, asMcpError, McpError } from '../utils/toolHelpers.js'; export const method = 'getCollection'; export const description = "Gets information about a collection. For a complete list of this endpoint's possible values, refer to the [Postman Collection Format documentation](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html)."; export const parameters = z.object({ collectionId: z .string() .describe( 'The collection ID must be in the form <OWNER_ID>-<UUID> (e.g. 12345-33823532ab9e41c9b6fd12d0fd459b8b).' ), access_key: z .string() .describe( "A collection's read-only access key. Using this query parameter does not require an API key to call the endpoint." ) .optional(), model: z .literal('minimal') .describe( "Return a list of only the collection's root-level request (`rootLevelRequests`) and folder (`rootLevelFolders`) IDs instead of the full collection element data." ) .optional(), }); export const annotations = { title: "Gets information about a collection. For a complete list of this endpoint's possible values, refer to the [Postman Collection Format documentation](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html).", readOnlyHint: true, destructiveHint: false, idempotentHint: true, }; export async function handler( args: z.infer<typeof parameters>, extra: { client: PostmanAPIClient; headers?: IsomorphicHeaders; serverContext?: ServerContext } ): Promise<CallToolResult> { try { const endpoint = `/collections/${args.collectionId}`; const query = new URLSearchParams(); if (args.access_key !== undefined) query.set('access_key', String(args.access_key)); if (args.model !== undefined) query.set('model', String(args.model)); 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); } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/postmanlabs/postman-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server