Sponsored by Deepsite.site

MCP server for Azure Cosmos DB using the Go SDK

Created By
abhirockzz9 months ago
Sample implementation of a MCP server for Cosmos DB built using the Go SDK
Content

MCP server for Azure Cosmos DB using the Go SDK

This is an implementation of a MCP server for Azure Cosmos DB built using its Go SDK. It exposes the following tools for interacting with Azure Cosmos DB:

  • List Databases: Retrieve a list of all databases in a Cosmos DB account.
  • List Containers: Retrieve a list of all containers in a specific database.
  • Read Container Metadata: Fetch metadata or configuration details of a specific container.
  • Create Container: Create a new container in a specified database with a defined partition key.
  • Add Item to Container: Add a new item to a specified container in a database.
  • Read Item: Read a specific item from a container using its ID and partition key.
  • Execute Query: Execute a SQL query on a Cosmos DB container with optional partition key scoping.

The project uses mcp-go as the MCP implementation.

Here is a demo (recommend watching at 2x speed 😉) using VS Code in Agent Mode:

Demo: MCP server for Azure Cosmos DB using the Go SDK

How to run

Word(s) of caution: As much as I want folks to benefit from this, I have to call out that Large Language Models (LLMs) are non-deterministic by nature and can make mistakes. I would recommend you to always validate the results and queries before making any decisions based on them.

git clone https://github.com/abhirockzz/mcp_cosmosdb_go
cd mcp_cosmosdb_go

go build -o mcp_azure_cosmosdb main.go

Configure the MCP server

This will differ based on the MCP client/tool you use. For VS Code you can follow these instructions on how to configure this server using a mcp.json file.

Here is an example of the mcp.json file:

{
  "servers": {
    "Azure Cosmos DB MCP (Golang)": {
      "type": "stdio",
      "command": "enter path to binary e.g. /Users/demo/Desktop/mcp_azure_cosmosdb"
    }
  }
}

Here is an example of Claude Desktop configuration:

{
  "mcpServers": {
    "Azure Cosmos DB MCP (Golang)": {
      "command": "enter path to binary e.g. /Users/demo/Desktop/mcp_azure_cosmosdb",
      "args": []
    }
    //other MCP servers...
  }
}

Azure Cosmos DB RBAC permissions and authentication

  • The user principal you will be using should have permissions (control and data plane) to execute CRUD operations on database, container, and items.

  • Authentication

    • Local credentials - Just login locally using Azure CLI (az login) and the MCP server will use the DefaultAzureCredential implementation automatically.
    • Or, you can set the COSMOSDB_ACCOUNT_KEY environment variable in the MCP server configuration:
    {
      "servers": {
        "CosmosDB Golang MCP": {
          "type": "stdio",
          "command": "/Users/demo/mcp_azure_cosmosdb",
          "env": {
            "COSMOSDB_ACCOUNT_KEY": "enter the key"
          }
        }
      }
    }
    

You are good to go! Now spin up VS Code in Agent Mode, or any other MCP tool (like Claude Desktop) and try this out!

Local dev/testing

Start with MCP inspector - npx @modelcontextprotocol/inspector ./mcp_azure_cosmosdb

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Serper MCP ServerA Serper MCP Server
Playwright McpPlaywright MCP server
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
ChatWiseThe second fastest AI chatbot™
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Amap Maps高德地图官方 MCP Server
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
WindsurfThe new purpose-built IDE to harness magic
DeepChatYour AI Partner on Desktop
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Tavily Mcp
CursorThe AI Code Editor