Skip to main content
Glama
imankamyabi

DynamoDB MCP Server

by imankamyabi

query_table

Retrieve data from a DynamoDB table using key conditions and optional filters, ensuring precise query results for efficient data management in the DynamoDB MCP Server.

Instructions

Queries a table using key conditions and optional filters

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expressionAttributeNamesNoAttribute name mappings
expressionAttributeValuesYesValues for the key condition expression
filterExpressionNoFilter expression for results
keyConditionExpressionYesKey condition expression
limitNoMaximum number of items to return
tableNameYesName of the table

Implementation Reference

  • The main handler function that performs a DynamoDB QueryCommand based on the provided parameters including table name, key condition expression, and optional filters.
    async function queryTable(params: any) { try { const command = new QueryCommand({ TableName: params.tableName, KeyConditionExpression: params.keyConditionExpression, ExpressionAttributeValues: marshall(params.expressionAttributeValues), ExpressionAttributeNames: params.expressionAttributeNames, FilterExpression: params.filterExpression, Limit: params.limit, }); const response = await dynamoClient.send(command); return { success: true, message: `Query executed successfully on table ${params.tableName}`, items: response.Items ? response.Items.map(item => unmarshall(item)) : [], count: response.Count, scannedCount: response.ScannedCount, }; } catch (error) { console.error("Error querying table:", error); return { success: false, message: `Failed to query table: ${error}`, }; } }
  • Defines the tool schema for 'query_table', including input parameters validation and descriptions.
    const QUERY_TABLE_TOOL: Tool = { name: "query_table", description: "Queries a table using key conditions and optional filters", inputSchema: { type: "object", properties: { tableName: { type: "string", description: "Name of the table" }, keyConditionExpression: { type: "string", description: "Key condition expression" }, expressionAttributeValues: { type: "object", description: "Values for the key condition expression" }, expressionAttributeNames: { type: "object", description: "Attribute name mappings", optional: true }, filterExpression: { type: "string", description: "Filter expression for results", optional: true }, limit: { type: "number", description: "Maximum number of items to return", optional: true }, }, required: ["tableName", "keyConditionExpression", "expressionAttributeValues"], }, };
  • src/index.ts:598-600 (registration)
    Registers the QUERY_TABLE_TOOL in the list of available tools returned by the ListToolsRequestHandler.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [CREATE_TABLE_TOOL, UPDATE_CAPACITY_TOOL, PUT_ITEM_TOOL, GET_ITEM_TOOL, QUERY_TABLE_TOOL, SCAN_TABLE_TOOL, DESCRIBE_TABLE_TOOL, LIST_TABLES_TOOL, CREATE_GSI_TOOL, UPDATE_GSI_TOOL, CREATE_LSI_TOOL, UPDATE_ITEM_TOOL], }));
  • src/index.ts:635-637 (registration)
    In the CallToolRequestHandler switch statement, routes calls to the 'query_table' tool to the queryTable handler function.
    case "query_table": result = await queryTable(args); break;

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/imankamyabi/dynamodb-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server