Skip to main content
Glama
getCollectionFolder.ts2.08 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 = 'getCollectionFolder'; export const description = 'Gets information about a folder in a collection.'; export const parameters = z.object({ folderId: z.string().describe("The folder's ID."), collectionId: z.string().describe("The collection's ID."), ids: z .boolean() .describe('If true, returns only properties that contain ID values in the response.') .optional(), uid: z.boolean().describe('If true, returns all IDs in UID format (`userId`-`id`).').optional(), populate: z .boolean() .describe("If true, returns all of the collection item's contents.") .optional(), }); export const annotations = { title: 'Gets information about a folder in a collection.', 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}/folders/${args.folderId}`; const query = new URLSearchParams(); if (args.ids !== undefined) query.set('ids', String(args.ids)); if (args.uid !== undefined) query.set('uid', String(args.uid)); if (args.populate !== undefined) query.set('populate', String(args.populate)); 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