Skip to main content
Glama
datastax

Astra DB MCP Server

Official

ListRecords

Retrieve records from a specified collection in Astra DB, with options to limit the number of results returned for efficient data management.

Instructions

List records from a collection in the database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionNameYesName of the collection to list records from
limitNoMaximum number of records to return

Implementation Reference

  • Core handler function that executes the ListRecords tool: fetches records from the specified collection using db.collection().find(), applies limit, sanitizes output, handles errors.
    export async function ListRecords(params: {
      collectionName: string;
      limit?: number;
    }) {
      const { collectionName, limit = 10 } = params;
    
      const collection = db.collection(collectionName);
      
      try {
        // Try to use the limit method if available
        const cursor = collection.find({});
        
        // Handle the case when toArray is not available
        if (!cursor || typeof cursor.toArray !== 'function') {
          console.warn(`cursor.toArray is not available for collection '${collectionName}'`);
          return sanitizeRecordData([]);
        }
        
        if (typeof cursor.limit === 'function') {
          const records = await cursor.limit(limit).toArray();
          return sanitizeRecordData(records);
        } else {
          // Fallback if limit is not available
          const allRecords = await cursor.toArray();
          const limitedRecords = allRecords.slice(0, limit);
          return sanitizeRecordData(limitedRecords);
        }
      } catch (error) {
        console.error(`Error listing records from collection '${collectionName}':`, error);
        return sanitizeRecordData([]);
      }
    }
  • Input schema definition for the ListRecords tool, specifying parameters collectionName (required) and optional limit.
    {
      name: "ListRecords",
      description: "List records from a collection in the database",
      inputSchema: {
        type: "object",
        properties: {
          collectionName: {
            type: "string",
            description: "Name of the collection to list records from",
          },
          limit: {
            type: "number",
            description: "Maximum number of records to return",
            default: 10,
          },
        },
        required: ["collectionName"],
      },
    },
  • index.ts:140-154 (registration)
    Registration and dispatch logic in the MCP server's CallToolRequestSchema handler: imports ListRecords, calls it with arguments, sanitizes, and returns JSON response.
    case "ListRecords":
      const records = await ListRecords({
        collectionName: args.collectionName as string,
        limit: args.limit as number | undefined,
      });
      // Sanitize records to prevent prompt injection
      const sanitizedRecords = sanitizeRecordData(records);
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(sanitizedRecords, null, 2),
          },
        ],
      };
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action but doesn't cover critical behaviors like whether this is a read-only operation, if it requires authentication, how it handles pagination beyond the 'limit' parameter, or what the output format looks like. This is inadequate for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It's appropriately sized and front-loaded, clearly stating the tool's purpose without unnecessary elaboration, earning a perfect score for conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of listing database records, the lack of annotations, and no output schema, the description is incomplete. It doesn't explain return values, error handling, or behavioral constraints, making it insufficient for an agent to fully understand the tool's operation in context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with clear descriptions for both parameters ('collectionName' and 'limit'), so the schema does the heavy lifting. The description adds no additional parameter semantics beyond what's in the schema, resulting in a baseline score of 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('List') and resource ('records from a collection in the database'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'GetCollections' (which lists collections, not records) or 'FindRecord' (which searches for specific records), missing full sibling distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to choose 'ListRecords' over 'FindRecord' for searching, 'GetRecord' for single records, or 'GetCollections' for listing collections, leaving usage context unclear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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