Skip to main content
Glama
jjikky

DynamoDB Read-Only MCP

by jjikky

get-item

Retrieve a specific item from a DynamoDB table using a defined key in JSON format. Simplify querying and access data directly from AWS DynamoDB databases.

Instructions

Get an item from a DynamoDB table based on a specific key

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesItem key (JSON format)
tableNameYesTable name

Implementation Reference

  • Core implementation of the get-item tool logic using AWS SDK's GetItemCommand to retrieve a single item from DynamoDB.
    export async function getItem(tableName: string, key: Record<string, any>) {
      console.error('# Starting getItem function:', { tableName, key });
      try {
        const command = new GetItemCommand({
          TableName: tableName,
          Key: key,
        });
        console.error('# GetItem command created successfully');
        const response = await dynamodb.send(command);
        console.error('# GetItem response received:', response);
        return response.Item;
      } catch (error) {
        console.error('# Error in getItem function:', error);
        throw error;
      }
    }
  • Zod input schema defining parameters for the get-item tool: tableName and key.
    {
      tableName: z.string().describe('Table name'),
      key: z.record(z.any()).describe('Item key (JSON format)'),
    },
  • src/index.ts:252-292 (registration)
    MCP server tool registration for 'get-item', including description, schema, and handler wrapper that calls the core getItem function.
    server.tool(
      'get-item',
      'Get an item from a DynamoDB table based on a specific key',
      {
        tableName: z.string().describe('Table name'),
        key: z.record(z.any()).describe('Item key (JSON format)'),
      },
      async ({ tableName, key }) => {
        try {
          const item = await getItem(tableName, key);
          if (!item) {
            return {
              content: [
                {
                  type: 'text',
                  text: 'Could not find the corresponding item.',
                },
              ],
            };
          }
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(item, null, 2),
              },
            ],
          };
        } catch (error: any) {
          return {
            isError: true,
            content: [
              {
                type: 'text',
                text: `Error occurred: ${error.message}`,
              },
            ],
          };
        }
      }
    );
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