GetCollections
Retrieve all collections stored in the Astra DB database using the MCP Server, enabling efficient database management and interaction through natural language commands.
Instructions
Get all collections in the Astra DB database
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"properties": {},
"required": [],
"type": "object"
}
Implementation Reference
- tools/GetCollections.ts:17-20 (handler)The core handler function that executes the tool logic: lists all collections from the Astra DB using db.listCollections() and returns them.export async function GetCollections() { const collections = await db.listCollections(); return collections; }
- tools.ts:45-53 (schema)The schema definition for the GetCollections tool, specifying no input parameters.{ name: "GetCollections", description: "Get all collections in the Astra DB database", inputSchema: { type: "object", properties: {}, required: [], }, },
- index.ts:61-65 (registration)Registration of the ListTools handler which exposes the tools list (including GetCollections schema).server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools, }; });
- index.ts:73-82 (registration)The dispatch case in CallToolRequestSchema handler that calls the GetCollections handler and returns formatted response.case "GetCollections": const collections = await GetCollections(); return { content: [ { type: "text", text: collections.map((c) => c.name).join("\n"), }, ], };