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:
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.goThis 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...
  }
}- 
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_KEYenvironment 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!
Start with MCP inspector - npx @modelcontextprotocol/inspector ./mcp_azure_cosmosdb

