scan_table
Scan entire DynamoDB tables with optional filters, attribute mappings, and result limits using the DynamoDB MCP Server. Retrieve table data efficiently with customizable query parameters.
Instructions
Scans an entire table with optional filters
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| expressionAttributeNames | No | Attribute name mappings | |
| expressionAttributeValues | No | Values for the filter expression | |
| filterExpression | No | Filter expression | |
| limit | No | Maximum number of items to return | |
| tableName | Yes | Name of the table |
Implementation Reference
- src/index.ts:536-561 (handler)The handler function that executes the DynamoDB ScanCommand on the specified table, with optional filter expression, attribute values, names, and limit.async function scanTable(params: any) { try { const command = new ScanCommand({ TableName: params.tableName, FilterExpression: params.filterExpression, ExpressionAttributeValues: params.expressionAttributeValues ? marshall(params.expressionAttributeValues) : undefined, ExpressionAttributeNames: params.expressionAttributeNames, Limit: params.limit, }); const response = await dynamoClient.send(command); return { success: true, message: `Scan 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 scanning table:", error); return { success: false, message: `Failed to scan table: ${error}`, }; } }
- src/index.ts:205-219 (schema)Defines the Tool object for scan_table, including name, description, and inputSchema.const SCAN_TABLE_TOOL: Tool = { name: "scan_table", description: "Scans an entire table with optional filters", inputSchema: { type: "object", properties: { tableName: { type: "string", description: "Name of the table" }, filterExpression: { type: "string", description: "Filter expression", optional: true }, expressionAttributeValues: { type: "object", description: "Values for the filter expression", optional: true }, expressionAttributeNames: { type: "object", description: "Attribute name mappings", optional: true }, limit: { type: "number", description: "Maximum number of items to return", optional: true }, }, required: ["tableName"], }, };
- src/index.ts:638-640 (registration)Dispatcher switch case that registers and invokes the scanTable handler for the 'scan_table' tool name.case "scan_table": result = await scanTable(args); break;
- src/index.ts:598-600 (registration)Registers SCAN_TABLE_TOOL in the list of available tools returned by 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], }));