create_collection
Create a new prompt collection to organize prompts by app. Use this to establish a namespace before creating prompts; returns collection id and slug.
Instructions
Create a new prompt collection for organizing prompts by app. Use this when you need a new namespace before create_prompt; returns the collection id and slug, and does not move any prompts.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Collection name (e.g., 'hourlink', 'apizone', 'research-pilot') | |
| workspace_id | No | Workspace ID to create collection in |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | Whether the tool call succeeded and returned structured data | |
| data | No | Structured success payload when ok is true | |
| error | No | Structured error payload when ok is false |
Implementation Reference
- src/tools/collections.tools.ts:84-108 (handler)The MCP tool handler for 'create_collection'. Registered via server.tool('create_collection', ...), it accepts params matching COLLECTIONS_TOOL_SCHEMAS.createCollection (name and optional workspace_id), calls service.collections.createCollection(params), and returns the created collection's id and slug.
// Create collection tool server.tool( "create_collection", "Create a new prompt collection for organizing prompts by app. Use this when you need a new namespace before create_prompt; returns the collection id and slug, and does not move any prompts.", COLLECTIONS_TOOL_SCHEMAS.createCollection, async (params) => { const result = await service.collections.createCollection(params); return { content: [ { type: "text", text: JSON.stringify( { message: `Successfully created collection "${params.name}"`, id: result.id, slug: result.slug, }, null, 2, ), }, ], }; }, ); - src/tools/collections.tools.ts:21-31 (schema)Input schema for createCollection tool — validates 'name' (required string) and 'workspace_id' (optional string). Defined as part of COLLECTIONS_TOOL_SCHEMAS and passed to the tool registration.
createCollection: { name: z .string() .describe( "Collection name (e.g., 'hourlink', 'apizone', 'research-pilot')", ), workspace_id: z .string() .optional() .describe("Workspace ID to create collection in"), }, - Service layer method that performs the actual HTTP POST to '/collections' with the given CreateCollectionRequest. Returns a CreateCollectionResponse containing id, slug, and object type.
async createCollection( data: CreateCollectionRequest, ): Promise<CreateCollectionResponse> { return this.post<CreateCollectionResponse>("/collections", data); } - TypeScript interfaces for the create collection request (name, optional workspace_id) and response (id, slug, object type).
export interface CreateCollectionRequest { name: string; workspace_id?: string; } export interface CreateCollectionResponse { id: string; slug: string; object: "collection"; } - src/tools/collections.tools.ts:48-51 (registration)The registerCollectionsTools() function that is called during server setup to register all collection tools, including 'create_collection', on the MCP server.
export function registerCollectionsTools( server: McpServer, service: PortkeyService, ): void {