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;
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 offers minimal behavioral context. It doesn't disclose whether this is a read-only operation, what permissions are required, how results are returned (pagination, format), error conditions, or performance characteristics. The mention of 'optional filters' hints at filtering capability but lacks detail.

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 that communicates the core functionality without unnecessary words. It's front-loaded with the main action and resource, making it immediately understandable.

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?

For a database query tool with 6 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain what the tool returns, error handling, authentication requirements, or how it differs from similar operations. The context signals indicate significant complexity that isn't addressed.

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 all 6 parameters thoroughly. The description adds marginal value by mentioning 'key conditions' (mapping to keyConditionExpression) and 'optional filters' (mapping to filterExpression), but doesn't provide additional semantic context beyond what's in the schema descriptions.

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 ('Queries') and resource ('a table'), specifying it uses 'key conditions and optional filters'. This distinguishes it from siblings like 'scan_table' (full table scan) and 'get_item' (single item retrieval), though it doesn't explicitly name these alternatives.

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 like 'scan_table' or 'get_item'. It mentions 'key conditions' which implies it's for indexed queries, but doesn't state this explicitly or provide any exclusion criteria or prerequisites.

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

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