get_item
Retrieve a specific item from an Azure Cosmos DB container using its unique ID. Ideal for fetching targeted data entries directly through the MCP server interface.
Instructions
Retrieves an item from a Azure Cosmos DB container by its ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| containerName | Yes | Name of the container | |
| id | Yes | ID of the item to retrieve |
Implementation Reference
- src/index.ts:125-142 (handler)The core handler function for the get_item tool that retrieves an item from the hardcoded Cosmos DB container by ID using container.item(id).read(). Note: ignores containerName parameter.async function getItem(params: any) { try { const { id } = params; const { resource } = await container.item(id).read(); return { success: true, message: `Item retrieved successfully`, item: resource, }; } catch (error) { console.error("Error getting item:", error); return { success: false, message: `Failed to get item: ${error}`, }; } }
- src/index.ts:52-63 (schema)The tool schema definition for get_item, specifying input parameters containerName and id.const GET_ITEM_TOOL: Tool = { name: "get_item", description: "Retrieves an item from a Azure Cosmos DB container by its ID", inputSchema: { type: "object", properties: { containerName: { type: "string", description: "Name of the container" }, id: { type: "string", description: "ID of the item to retrieve" }, }, required: ["containerName", "id"], }, };
- src/index.ts:177-179 (registration)Registration of the get_item tool (via GET_ITEM_TOOL) in the ListToolsRequestHandler, making it discoverable.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [PUT_ITEM_TOOL, GET_ITEM_TOOL, QUERY_CONTAINER_TOOL, UPDATE_ITEM_TOOL], }));
- src/index.ts:190-192 (registration)Dispatch/registration of the get_item tool call in the switch statement of CallToolRequestHandler.case "get_item": result = await getItem(args); break;