mcpcosmosdb

v2.0.0
mcpcosmosdb Checked 2 hours ago Published 10 months ago

MCP CosmosDB - Azure CosmosDB MCP Server for database analysis and operations

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

mcp_list_connections

List all available CosmosDB connections configured in this MCP server. Use this to discover which connection_id values you can use. Each connection points to a different CosmosDB account/database.

mcp_list_databases

List all databases in the CosmosDB account. Use this to discover available databases before querying containers. Returns database IDs, timestamps, and ETags.

ParameterTypeDescription
connection_idstringID of the connection to use. Use mcp_list_connections to see available connections. If not specified, uses the default connection.

mcp_list_containers

List all containers in the connected CosmosDB database. Use this to discover available containers and their partition key configurations before querying data. Returns container IDs, partition key paths, and indexing policies.

ParameterTypeDescription
connection_idstringID of the connection to use. Use mcp_list_connections to see available connections. If not specified, uses the default connection.

mcp_get_container_definition

Get detailed configuration of a specific container including partition key, indexing policy, and throughput settings. Use this to understand the container structure before writing queries. Example: mcp_get_container_definition({container_id: 'users', connection_id: 'athlete'})

ParameterTypeDescription
container_id *stringThe ID/name of the container (e.g., 'users', 'orders', 'products')
connection_idstringID of the connection to use. Use mcp_list_connections to see available connections. If not specified, uses the default connection.

mcp_get_container_stats

Get statistical information about a container including document count, estimated size, and partition key distribution. Use this for capacity planning and performance analysis. Example: mcp_get_container_stats({container_id: 'orders', sample_size: 500})

ParameterTypeDescription
container_id *stringThe ID/name of the container to analyze
connection_idstringID of the connection to use. Use mcp_list_connections to see available connections. If not specified, uses the default connection.
sample_sizenumberNumber of documents to sample for statistics (default: 1000, higher = more accurate but slower)

mcp_cosmos_query

Execute a CosmosDB SQL query against a container. Use this for complex queries with JOINs, aggregations, or custom SQL syntax. ⚠️ IMPORTANT - AVOID SELECT *: - NEVER use SELECT * in large containers - it causes timeouts and high RU consumption - ALWAYS use TOP N to limit results: SELECT TOP 10 c.id, c.name FROM c - ALWAYS specify only the fields you need: SELECT c.id, c.name, c.email FROM c COSMOSDB SQL SYNTAX EXAMPLES: - Basic: SELECT TOP 10 c.id, c.name FROM c WHERE c.status = @status - With projection: SELECT c.id, c.name, c.email FROM c - Aggregation: SELECT VALUE COUNT(1) FROM c - A…

ParameterTypeDescription
container_id *stringThe ID/name of the container to query
query *stringCosmosDB SQL query. Use 'c' as the alias for the container. ALWAYS use TOP N and specify fields - NEVER use SELECT *. Example: 'SELECT TOP 10 c.id, c.name FROM c WHERE c.active = true'
connection_idstringID of the connection to use. Use mcp_list_connections to see available connections. If not specified, uses the default connection.
enable_cross_partitionbooleanEnable cross-partition queries. Set to true unless querying within a single partition key value.
max_itemsnumberMaximum number of items to return (default: 100, max recommended: 1000)
parametersobjectQuery parameters as key-value pairs (without @ prefix). Example: {status: 'active', limit: 10}

mcp_get_documents

Get documents from a container with simple filters and ordering. Use this for basic queries without complex SQL syntax. FOR COMPLEX QUERIES: Use mcp_cosmos_query instead. THIS TOOL IS BEST FOR: - Getting all documents (with limit) - Simple equality filters on fields - Filtering by partition key for performance - Getting the most recent or oldest documents using order_by Example: mcp_get_documents({container_id: 'users', limit: 10, order_by: '_ts', order_direction: 'DESC', connection_id: 'athlete'}) Example: mcp_get_documents({container_id: 'users', limit: 50, filter_conditions: {status: 'act…

ParameterTypeDescription
container_id *stringThe ID/name of the container to query
connection_idstringID of the connection to use. Use mcp_list_connections to see available connections. If not specified, uses the default connection.
filter_conditionsobjectSimple equality filters as key-value pairs. Example: {status: 'active', type: 'premium'}
limitnumberMaximum number of documents to return (default: 100)
order_bystringField name to order results by. Use '_ts' for timestamp ordering (most recent/oldest). Example: '_ts', 'creationDate', 'name'
order_directionstringSort direction: 'ASC' for ascending (oldest first), 'DESC' for descending (newest first). Default: 'ASC'
partition_keystring | number | booleanOptional partition key value to filter by. Improves performance significantly.

mcp_get_document_by_id

Get a single document by its ID and partition key. This is the most efficient way to retrieve a specific document. IMPORTANT: Both document_id and partition_key are required for a point read in CosmosDB. The partition_key type must match your container's partition key type. Example: mcp_get_document_by_id({container_id: 'users', document_id: 'user-123', partition_key: 'user-123', connection_id: 'athlete'})

ParameterTypeDescription
container_id *stringThe ID/name of the container
document_id *stringThe unique ID of the document (the 'id' field value)
partition_key *string | number | booleanThe partition key value for the document. Must match the container's partition key path value.
connection_idstringID of the connection to use. Use mcp_list_connections to see available connections. If not specified, uses the default connection.

mcp_analyze_schema

Analyze the schema/structure of documents in a container. Samples documents to discover field names, data types, and frequency. Use this to understand the data model before writing queries.

ParameterTypeDescription
container_id *stringThe ID/name of the container to analyze
connection_idstringID of the connection to use. Use mcp_list_connections to see available connections. If not specified, uses the default connection.
sample_sizenumberNumber of documents to sample for analysis (default: 100)

mcp_create_document

Create a new document in a CosmosDB container. REQUIREMENTS: - The document MUST have an 'id' field (string) - The document MUST have the partition key field with a value - The 'id' must be unique within the partition Example: mcp_create_document({ container_id: 'users', document: {id: 'user-456', email: 'test@example.com', status: 'active'}, partition_key: 'user-456', connection_id: 'athlete' })

ParameterTypeDescription
container_id *stringThe ID/name of the container
document *objectThe document to create. Must include 'id' field and the partition key field.
partition_key *string | number | booleanThe partition key value for the document
connection_idstringID of the connection to use. Use mcp_list_connections to see available connections. If not specified, uses the default connection.

mcp_update_document

Update (replace) an existing document in a CosmosDB container. NOTE: This performs a full document replacement. Include ALL fields you want to keep. For partial updates, first get the document with mcp_get_document_by_id, modify it, then update. Example: mcp_update_document({ container_id: 'users', document_id: 'user-456', document: {id: 'user-456', email: 'new@example.com', status: 'inactive'}, partition_key: 'user-456', connection_id: 'athlete' })

ParameterTypeDescription
container_id *stringThe ID/name of the container
document *objectThe complete document with updated values. Must include 'id' field.
document_id *stringThe ID of the document to update
partition_key *string | number | booleanThe partition key value for the document
connection_idstringID of the connection to use. Use mcp_list_connections to see available connections. If not specified, uses the default connection.

mcp_delete_document

Delete a document from a CosmosDB container. WARNING: This operation is irreversible. The document will be permanently deleted. Example: mcp_delete_document({ container_id: 'users', document_id: 'user-456', partition_key: 'user-456', connection_id: 'athlete' })

ParameterTypeDescription
container_id *stringThe ID/name of the container
document_id *stringThe ID of the document to delete
partition_key *string | number | booleanThe partition key value for the document
connection_idstringID of the connection to use. Use mcp_list_connections to see available connections. If not specified, uses the default connection.

mcp_upsert_document

Create or update a document in a CosmosDB container (upsert operation). If a document with the same id and partition key exists, it will be replaced. If it doesn't exist, a new document will be created. Example: mcp_upsert_document({ container_id: 'users', document: {id: 'user-456', email: 'test@example.com', lastUpdated: '2024-01-15'}, partition_key: 'user-456', connection_id: 'athlete' })

ParameterTypeDescription
container_id *stringThe ID/name of the container
document *objectThe document to create or update. Must include 'id' field and the partition key field.
partition_key *string | number | booleanThe partition key value for the document
connection_idstringID of the connection to use. Use mcp_list_connections to see available connections. If not specified, uses the default connection.