Skip to main content
Glama
robinong79

Azure Cosmos DB MCP Server

by robinong79

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
NameRequiredDescriptionDefault
containerNameYesName of the container
idYesID of the item to retrieve

Implementation Reference

  • 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}`, }; } }
  • 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;

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/robinong79/mcp-cosmos'

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