get_collection
Retrieve the complete schema of a collection, including its fields, types, and relations, to understand data structure.
Instructions
Récupère le schéma complet d'une collection (champs, types, relations)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| collection | Yes | Nom de la collection |
Implementation Reference
- src/tools.ts:18-31 (schema)Schema definition for the get_collection tool: takes a required 'collection' (string) parameter, returns the collection's full schema (fields, types, relations).
{ name: "get_collection", description: "Récupère le schéma complet d'une collection (champs, types, relations)", inputSchema: { type: "object", properties: { collection: { type: "string", description: "Nom de la collection", }, }, required: ["collection"], }, }, - src/index.ts:48-52 (handler)Handler that extracts the 'collection' argument from the request and calls skema.getCollection() to fetch the collection schema.
case "get_collection": { const { collection } = args as { collection: string }; result = await skema.getCollection(collection); break; } - src/skema-client.ts:73-77 (helper)Helper function getCollection() that makes a JSON-RPC call with tool name 'get_collection' and the collection argument to the remote Skema API.
/** * Recupere le schema d'une collection */ export const getCollection = (collection: string) => mcpCall("get_collection", { collection }); - src/skema-client.ts:25-66 (helper)Generic mcpCall function used by getCollection to communicate with the Skema CMS MCP API via HTTP JSON-RPC.
export const mcpCall = async <T = unknown>( toolName: string, args: Record<string, unknown> = {} ): Promise<T> => { requestId++; const response = await fetch(`${BASE_URL}/mcp`, { method: "POST", headers: { "X-API-Key": API_KEY, "Content-Type": "application/json", }, body: JSON.stringify({ jsonrpc: "2.0", id: requestId, method: "tools/call", params: { name: toolName, arguments: args, }, }), }); if (!response.ok) { const error = await response .json() .catch(() => ({ message: "Erreur inconnue" })); throw new Error(error.message || `Erreur HTTP ${response.status}`); } const jsonRpc: JsonRpcResponse<T> = await response.json(); if (jsonRpc.error) { throw new Error(jsonRpc.error.message); } if (!jsonRpc.result?.content?.[0]?.text) { throw new Error("Reponse MCP invalide"); } return JSON.parse(jsonRpc.result.content[0].text); };