Skip to main content
Glama

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

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

Input Schema (JSON Schema)

{ "properties": { "collectionName": { "description": "Name of the collection to get the record from", "type": "string" }, "recordId": { "description": "ID of the record to retrieve", "type": "string" } }, "required": [ "collectionName", "recordId" ], "type": "object" }

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), }, ], };

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