Skip to main content
Glama
datastax

Astra DB MCP Server

Official

GetRecord

Retrieve a specific record from a specified collection in Astra DB using its unique ID. Simplify data access and management directly within the MCP Server.

Instructions

Get a specific record from a collection by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionNameYesName of the collection to get the record from
recordIdYesID of the record to retrieve

Implementation Reference

  • The core handler function that retrieves a specific record from the given collection by its ID using the database client, sanitizes the data to prevent prompt injection, and returns it or null if not found.
    export async function GetRecord(params: {
      collectionName: string;
      recordId: string;
    }) {
      const { collectionName, recordId } = params;
    
      const collection = db.collection(collectionName);
      const record = await collection.findOne({ _id: recordId });
    
      if (!record) {
        return null;
      }
    
      // Return sanitized record to prevent prompt injection attacks
      return sanitizeRecordData(record);
    }
  • Defines the tool metadata including name, description, and input schema (JSON Schema) for validating parameters: collectionName and recordId.
    {
      name: "GetRecord",
      description: "Get a specific record from a collection by ID",
      inputSchema: {
        type: "object",
        properties: {
          collectionName: {
            type: "string",
            description: "Name of the collection to get the record from",
          },
          recordId: {
            type: "string",
            description: "ID of the record to retrieve",
          },
        },
        required: ["collectionName", "recordId"],
      },
    },
  • index.ts:156-170 (registration)
    Registers the tool handler in the MCP server's CallToolRequestSchema dispatcher by importing and invoking the GetRecord function in the switch case, adding extra sanitization and formatting the response as MCP content.
    case "GetRecord":
      const record = await GetRecord({
        collectionName: args.collectionName as string,
        recordId: args.recordId as string,
      });
      // Sanitize record to prevent prompt injection
      const sanitizedRecord = sanitizeRecordData(record);
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(sanitizedRecord, null, 2),
          },
        ],
      };
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic operation without behavioral details. It doesn't disclose whether this is a read-only operation, error handling (e.g., for invalid IDs), authentication needs, rate limits, or return format, leaving significant gaps for a tool that retrieves data.

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, clear sentence with zero waste—it directly states the tool's function without unnecessary words. It's appropriately sized and front-loaded, making it efficient for quick understanding.

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 a retrieval tool with no annotations and no output schema, the description is incomplete. It lacks details on behavioral traits, error cases, and output format, which are crucial for proper usage. The schema covers parameters, but overall context is insufficient for safe and effective tool invocation.

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?

Schema description coverage is 100%, so the schema already documents both parameters ('collectionName' and 'recordId') adequately. The description adds no additional meaning beyond implying ID-based retrieval, aligning with the baseline score when schema does the heavy lifting.

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 action ('Get') and resource ('specific record from a collection by ID'), making the purpose immediately understandable. However, it doesn't distinguish this tool from sibling 'FindRecord' or 'ListRecords', which likely serve similar retrieval functions, missing explicit differentiation.

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?

No guidance is provided on when to use this tool versus alternatives like 'FindRecord' or 'ListRecords'. The description implies usage for retrieving a single record by ID, but it doesn't specify prerequisites, exclusions, or comparative contexts with sibling tools.

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