Skip to main content
Glama
jjikky

DynamoDB Read-Only MCP

by jjikky

query-table

Retrieve items from a DynamoDB table using specified key conditions, filters, and optional parameters to refine query results.

Instructions

Query items from a DynamoDB table based on conditions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expressionAttributeValuesYesFilter expression attribute values (JSON format)
filterExpressionNoFilter expression (optional)
indexNameNoName of the index to use (optional)
keyConditionExpressionYesKey condition expression (e.g: 'PK = :pk')
limitNoMaximum number of items to return
projectionExpressionNoProjection expression (optional)
tableNameYesName of the table to query

Implementation Reference

  • The handler function for the 'query-table' tool. It constructs a QueryCommandInput object from the input parameters and calls the queryTable helper to execute the DynamoDB query, then formats the response.
    async ({
      tableName,
      keyConditionExpression,
      expressionAttributeValues,
      indexName,
      filterExpression,
      limit,
      projectionExpression,
    }) => {
      console.error('# query-table tool has been called');
      try {
        const queryParams: QueryCommandInput = {
          TableName: tableName,
          KeyConditionExpression: keyConditionExpression,
          ExpressionAttributeValues: expressionAttributeValues,
          ProjectionExpression: projectionExpression,
        };
    
        if (indexName) {
          queryParams.IndexName = indexName;
        }
    
        if (filterExpression) {
          queryParams.FilterExpression = filterExpression;
        }
    
        if (limit) {
          queryParams.Limit = limit;
        }
    
        if (projectionExpression) {
          queryParams.ProjectionExpression = projectionExpression;
        }
    
        const items = await queryTable(queryParams);
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(items, null, 2),
            },
          ],
        };
      } catch (error: any) {
        console.error('# Error executing query:', error);
        return {
          isError: true,
          content: [
            {
              type: 'text',
              text: `Error occurred: ${error.message}`,
            },
          ],
        };
      }
    }
  • Zod schema defining the input parameters for the 'query-table' tool, including table name, key condition, attribute values, and optional filters.
    {
      tableName: z.string().describe('Name of the table to query'),
      keyConditionExpression: z.string().describe("Key condition expression (e.g: 'PK = :pk')"),
      expressionAttributeValues: z
        .record(z.any())
        .describe('Filter expression attribute values (JSON format)'),
      indexName: z.string().optional().describe('Name of the index to use (optional)'),
      filterExpression: z.string().optional().describe('Filter expression (optional)'),
      limit: z.number().optional().describe('Maximum number of items to return'),
      projectionExpression: z.string().optional().describe('Projection expression (optional)'),
    },
  • src/index.ts:128-198 (registration)
    Registration of the 'query-table' MCP tool using server.tool(), specifying name, description, input schema, and handler function.
    server.tool(
      'query-table',
      'Query items from a DynamoDB table based on conditions',
      {
        tableName: z.string().describe('Name of the table to query'),
        keyConditionExpression: z.string().describe("Key condition expression (e.g: 'PK = :pk')"),
        expressionAttributeValues: z
          .record(z.any())
          .describe('Filter expression attribute values (JSON format)'),
        indexName: z.string().optional().describe('Name of the index to use (optional)'),
        filterExpression: z.string().optional().describe('Filter expression (optional)'),
        limit: z.number().optional().describe('Maximum number of items to return'),
        projectionExpression: z.string().optional().describe('Projection expression (optional)'),
      },
      async ({
        tableName,
        keyConditionExpression,
        expressionAttributeValues,
        indexName,
        filterExpression,
        limit,
        projectionExpression,
      }) => {
        console.error('# query-table tool has been called');
        try {
          const queryParams: QueryCommandInput = {
            TableName: tableName,
            KeyConditionExpression: keyConditionExpression,
            ExpressionAttributeValues: expressionAttributeValues,
            ProjectionExpression: projectionExpression,
          };
    
          if (indexName) {
            queryParams.IndexName = indexName;
          }
    
          if (filterExpression) {
            queryParams.FilterExpression = filterExpression;
          }
    
          if (limit) {
            queryParams.Limit = limit;
          }
    
          if (projectionExpression) {
            queryParams.ProjectionExpression = projectionExpression;
          }
    
          const items = await queryTable(queryParams);
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(items, null, 2),
              },
            ],
          };
        } catch (error: any) {
          console.error('# Error executing query:', error);
          return {
            isError: true,
            content: [
              {
                type: 'text',
                text: `Error occurred: ${error.message}`,
              },
            ],
          };
        }
      }
    );
  • Helper function queryTable that executes the actual DynamoDB QueryCommand using the AWS SDK and returns the items.
    export async function queryTable(params: QueryCommandInput) {
      console.error('# Starting queryTable function');
      console.error('# Query parameters:', params);
    
      try {
        const command = new QueryCommand(params);
        console.error('# Query command created successfully');
    
        const response = await dynamodb.send(command);
        console.error('# Query response received:', response);
    
        if (!response) {
          console.error('# Response is undefined');
          return [];
        }
    
        if (!response.Items) {
          console.error('# Response has no Items');
          return [];
        }
    
        console.error(`# Found ${response.Items.length} items`);
        return response.Items;
      } catch (error) {
        console.error('# Error in queryTable function:', error);
        throw error;
      }
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool queries items but doesn't mention whether it's read-only, if it has side effects, rate limits, authentication needs, or what the return format looks like. For a database query tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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 directly states the tool's purpose without unnecessary words. It's front-loaded with the core action and resource, making it easy to parse quickly.

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 DynamoDB query tool with 7 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain return values, error conditions, or behavioral constraints, leaving the agent with insufficient context to use the tool effectively beyond basic parameter passing.

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%, so the schema already documents all 7 parameters thoroughly. The description adds no additional parameter semantics beyond implying 'conditions' relate to the filter and key condition expressions. This meets the baseline of 3 since the schema does the heavy lifting, but the description doesn't compensate with extra context.

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 ('Query items') and resource ('from a DynamoDB table') with the purpose ('based on conditions'), making it easy to understand what the tool does. It distinguishes from siblings like 'scan-table' by specifying querying rather than scanning, though it doesn't explicitly differentiate from 'paginate-query-table' which might be a related operation.

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 'paginate-query-table'. It mentions conditions but doesn't specify that this is for key-based queries in DynamoDB, leaving the agent to infer usage from the tool name and parameters alone.

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/jjikky/dynamo-readonly-mcp'

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