Skip to main content
Glama
imankamyabi

DynamoDB MCP Server

by imankamyabi

get_item

Retrieve specific items from DynamoDB tables using their primary key with this tool. Designed for secure and precise data access without delete functionality to prevent data loss.

Instructions

Retrieves an item from a table by its primary key

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesPrimary key of the item to retrieve
tableNameYesName of the table

Implementation Reference

  • The main handler function for the 'get_item' tool. It constructs a GetItemCommand with the provided tableName and key, sends it to the DynamoDB client, unmarshalls the response item if present, and returns a success/error object.
    async function getItem(params: any) { try { const command = new GetItemCommand({ TableName: params.tableName, Key: marshall(params.key), }); const response = await dynamoClient.send(command); return { success: true, message: `Item retrieved successfully from table ${params.tableName}`, item: response.Item ? unmarshall(response.Item) : null, }; } catch (error) { console.error("Error getting item:", error); return { success: false, message: `Failed to get item: ${error}`, }; }
  • The Tool object definition for 'get_item', including name, description, and inputSchema for validation (requires tableName and key).
    const GET_ITEM_TOOL: Tool = { name: "get_item", description: "Retrieves an item from a table by its primary key", inputSchema: { type: "object", properties: { tableName: { type: "string", description: "Name of the table" }, key: { type: "object", description: "Primary key of the item to retrieve" }, }, required: ["tableName", "key"], }, };
  • src/index.ts:598-600 (registration)
    Registration of the 'get_item' tool (as GET_ITEM_TOOL) in the ListToolsRequestHandler, where the server lists all available tools.
    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:632-634 (registration)
    Dispatch/registration in the CallToolRequestHandler switch statement, routing calls to 'get_item' to the getItem handler function.
    case "get_item": result = await getItem(args); break;
  • Import of the AWS SDK GetItemCommand class used in the handler.
    GetItemCommand,

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