Skip to main content
Glama
collection.ts1.31 kB
import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js"; import { FirestoreClient } from "../firestore/client.js"; import { PermissionManager } from "../permissions/manager.js"; export function registerCollectionResources( server: McpServer, firestoreClient: FirestoreClient, permissionManager: PermissionManager ) { // Register collection resource template server.resource( "collection", new ResourceTemplate("firestore://collection/{collectionId}", { list: undefined }), async (uri, { collectionId }) => { // Check permissions if (!permissionManager.hasPermission(collectionId as string, 'read')) { throw new Error(`Access denied to collection: ${collectionId}`); } try { const documents = await firestoreClient.getCollection(collectionId as string); return { contents: [{ uri: uri.href, text: JSON.stringify(documents, null, 2), mimeType: "application/json" }] }; } catch (error) { console.error(`Error reading collection ${collectionId}:`, error); throw new Error(`Failed to read collection ${collectionId}: ${error instanceof Error ? error.message : String(error)}`); } } ); }

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/devlimelabs/firestore-mcp'

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