Skip to main content
Glama
check-collection.ts622 B
import type { Schema } from '../types/schema.js'; import { formatErrorResponse } from './response.js'; /** * Check if a collection exists in the context schema. * @param collection - The collection to check. * @param contextSchema - The context schema. * @returns The collection if it exists, otherwise an error. */ export function checkCollection(collection: string, contextSchema: Schema) { if (collection && !contextSchema[collection]) { return formatErrorResponse( new Error( `Collection "${collection}" not found. Use read-collections tool first.`, ), ); } return contextSchema[collection]; }

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/JoshTheDerf/directus-extension-mcp'

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