Skip to main content
Glama

CreateCollection

Build a new database collection in Astra DB MCP Server, specifying collection name and optional vector properties for efficient data organization and retrieval.

Instructions

Create a new collection in the database

Input Schema

NameRequiredDescriptionDefault
collectionNameYesName of the collection to create
dimensionNoThe dimensions of the vector collection, if vector is true
vectorNoWhether to create a vector collection

Input Schema (JSON Schema)

{ "properties": { "collectionName": { "description": "Name of the collection to create", "type": "string" }, "dimension": { "default": 1536, "description": "The dimensions of the vector collection, if vector is true", "type": "number" }, "vector": { "default": true, "description": "Whether to create a vector collection", "type": "boolean" } }, "required": [ "collectionName" ], "type": "object" }

Implementation Reference

  • The core handler function that implements the CreateCollection tool logic. It creates a collection in Astra DB, optionally configuring it as a vector collection with specified dimensions and metric.
    export async function CreateCollection(params: { collectionName: string; vector?: boolean; dimension?: number; metric?: VectorMetric; }) { const { collectionName, vector = true, dimension = 1536, metric = "cosine" as VectorMetric } = params; if (vector) { await db.createCollection(collectionName, { vector: { dimension: dimension, metric: metric }, }); } else { await db.createCollection(collectionName); } return { success: true, message: `Collection '${collectionName}' created successfully`, }; }
  • The JSON schema definition for the CreateCollection tool input, including parameters like collectionName (required), vector, dimension, and metric with defaults.
    { name: "CreateCollection", description: "Create a new collection in the database", inputSchema: { type: "object", properties: { collectionName: { type: "string", description: "Name of the collection to create", }, vector: { type: "boolean", description: "Whether to create a vector collection", default: true, }, dimension: { type: "number", description: "The dimensions of the vector collection, if vector is true", default: 1536, }, metric: { type: "string", description: "The similarity metric to use for vector search (cosine, euclidean, or dot_product)", default: "cosine", enum: ["cosine", "euclidean", "dot_product"] } }, required: ["collectionName"], }, },
  • index.ts:84-98 (registration)
    The registration and dispatch logic in the MCP server's CallToolRequest handler. It extracts arguments and calls the CreateCollection handler function, returning the result as MCP content.
    case "CreateCollection": const createResult = await CreateCollection({ collectionName: args.collectionName as string, vector: args.vector as boolean | undefined, dimension: args.dimension as number | undefined, metric: args.metric as "cosine" | "euclidean" | "dot_product" | undefined, }); return { content: [ { type: "text", text: createResult.message, }, ], };

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/datastax/astra-db-mcp'

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