get_collection
Retrieve a collection's details by providing its name.
Instructions
Get a specific collection by name
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Collection name |
Implementation Reference
- src/index.ts:48-55 (registration)Registration of the 'get_collection' tool using server.registerTool() — binds the tool name, schema, and handler together.
server.registerTool( "get_collection", { description: "Get a specific collection by name", inputSchema: { name: z.string().describe("Collection name") }, }, async ({ name }) => ok(await nocoFetch(`/api/collections/${name}`)) ); - src/index.ts:54-54 (handler)Handler function for get_collection — fetches a specific collection by name via GET /api/collections/{name}.
async ({ name }) => ok(await nocoFetch(`/api/collections/${name}`)) - src/index.ts:52-53 (schema)Input schema for get_collection — uses Zod to define a required 'name' string parameter.
inputSchema: { name: z.string().describe("Collection name") }, }, - src/index.ts:18-27 (helper)Helper utility 'nocoFetch' used by the handler to make authenticated HTTP requests to the NocoBase API.
async function nocoFetch(path: string, options: RequestInit = {}): Promise<unknown> { const url = `${NOCOBASE_URL}${path}`; const res = await fetch(url, { ...options, headers: { ...reqHeaders, ...(options.headers as Record<string, string> | undefined) }, }); const text = await res.text(); if (!res.ok) throw new Error(`HTTP ${res.status} ${res.statusText}: ${text}`); try { return JSON.parse(text); } catch { return text; } } - src/index.ts:29-31 (helper)Helper function 'ok' used by the handler to format successful responses as text content.
const ok = (data: unknown) => ({ content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }], });