create_index
Add fields to a query index for faster database queries by specifying the collection and index fields.
Instructions
Add field(s) to a query index
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| collection | Yes | Collection name | |
| index | Yes | Field(s) to add to query index |
Implementation Reference
- src/index.ts:98-101 (schema)Zod schema for the create_index tool inputs: defines 'collection' (string) and 'index' (string) as required parameters.
const createIndexSchema = z.object({ collection: z.string().describe("Collection name"), index: z.string().describe("Field(s) to add to query index"), }); - src/index.ts:302-314 (registration)Tool registration entry in the tools array: name 'create_index', description 'Add field(s) to a query index', with inputSchema listing collection and index properties.
{ name: "create_index", description: "Add field(s) to a query index", schema: createIndexSchema, inputSchema: { type: "object", properties: { collection: { type: "string", description: "Collection name" }, index: { type: "string", description: "Field(s) to add to query index" } }, required: ["collection", "index"] } }, - src/index.ts:937-956 (handler)The handler for create_index tool execution: extracts collection and index args, builds a 'createindex' CLI command with project/space flags, executes via executeCohoCommand, and returns the result.
case "create_index": { const { collection, index } = args as CreateIndexArgs; const indexArgs = [ 'createindex', '--project', config.projectId, '--space', config.space, collection, index ]; const result = await executeCohoCommand(indexArgs); return { content: [ { type: "text", text: result } ], isError: false }; }