Skip to main content
Glama
cosmos.ts3.07 kB
import { AzureService, ServiceResult } from './base-service.js'; import { CacheKeys } from '../lib/cache.js'; interface CosmosAccount { name: string; resourceGroup: string; location: string; kind: string; documentEndpoint: string; } interface CosmosDatabase { id: string; _rid: string; } interface CosmosContainer { id: string; partitionKey: { paths: string[] }; } export class CosmosService extends AzureService { readonly serviceName = 'CosmosDB'; readonly cliPrefix = 'cosmosdb'; async list(resourceGroup?: string): Promise<ServiceResult<CosmosAccount[]>> { const cacheKey = CacheKeys.service('cosmos', 'accounts', resourceGroup ?? ''); return this.cachedExecute(cacheKey, async () => { const opts: Record<string, string> = {}; if (resourceGroup) opts['resource-group'] = resourceGroup; const result = await this.execute('list', opts); return this.toResult<CosmosAccount[]>(result); }); } async listDatabases(accountName: string, resourceGroup: string): Promise<ServiceResult<CosmosDatabase[]>> { const cacheKey = CacheKeys.service('cosmos', 'databases', accountName); return this.cachedExecute(cacheKey, async () => { const result = await this.execute('sql database list', { 'account-name': accountName, 'resource-group': resourceGroup }); return this.toResult<CosmosDatabase[]>(result); }); } async listContainers(accountName: string, resourceGroup: string, databaseName: string): Promise<ServiceResult<CosmosContainer[]>> { const cacheKey = CacheKeys.service('cosmos', 'containers', accountName, databaseName); return this.cachedExecute(cacheKey, async () => { const result = await this.execute('sql container list', { 'account-name': accountName, 'resource-group': resourceGroup, 'database-name': databaseName }); return this.toResult<CosmosContainer[]>(result); }); } async queryContainer( accountName: string, resourceGroup: string, databaseName: string, containerName: string, query: string ): Promise<ServiceResult> { const result = await this.execute('sql container query', { 'account-name': accountName, 'resource-group': resourceGroup, 'database-name': databaseName, 'name': containerName, 'query': query }); return this.toResult(result); } async getContainer(accountName: string, resourceGroup: string, databaseName: string, containerName: string): Promise<ServiceResult> { const result = await this.execute('sql container show', { 'account-name': accountName, 'resource-group': resourceGroup, 'database-name': databaseName, 'name': containerName }); return this.toResult(result); } }

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/vedantparmar12/Azure-_MCP'

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