Skip to main content
Glama
robinong79

Azure Cosmos DB MCP Server

by robinong79

query_container

Executes SQL-like queries on an Azure Cosmos DB container to retrieve, filter, or manipulate data, enabling efficient interaction with database systems through structured inputs.

Instructions

Queries a Azure Cosmos DB container using SQL-like syntax

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
containerNameYesName of the container
parametersNoQuery parameters
queryYesSQL query string

Implementation Reference

  • The handler function that performs the actual query on the Cosmos DB container using the provided SQL query and parameters.
    async function queryContainer(params: any) { try { const { query, parameters } = params; const { resources } = await container.items.query({ query, parameters }).fetchAll(); return { success: true, message: `Query executed successfully`, items: resources, }; } catch (error) { console.error("Error querying container:", error); return { success: false, message: `Failed to query container: ${error}`, }; } }
  • The Tool object defining the input schema and metadata for the query_container tool.
    const QUERY_CONTAINER_TOOL: Tool = { name: "query_container", description: "Queries a Azure Cosmos DB container using SQL-like syntax", inputSchema: { type: "object", properties: { containerName: { type: "string", description: "Name of the container" }, query: { type: "string", description: "SQL query string" }, parameters: { type: "array", description: "Query parameters" }, }, required: ["containerName", "query"], }, };
  • src/index.ts:177-179 (registration)
    Registration of the query_container tool (QUERY_CONTAINER_TOOL) in the list of tools provided by ListToolsRequestHandler.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [PUT_ITEM_TOOL, GET_ITEM_TOOL, QUERY_CONTAINER_TOOL, UPDATE_ITEM_TOOL], }));
  • src/index.ts:193-195 (registration)
    The switch case in CallToolRequestHandler that routes calls to the query_container tool to its handler function.
    case "query_container": result = await queryContainer(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