kb_get_collection
Retrieve collection metadata and articles from the knowledge base to access organized content using a collection ID.
Instructions
Get collection metadata and articles from the Pylon knowledge base
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Collection ID |
Implementation Reference
- src/tools/kbGetCollection.ts:20-45 (handler)The handler function that parses input arguments, fetches the collection using pylonClient.getCollection, and returns the JSON stringified result or an error message.export async function handleKbGetCollection(pylonClient: PylonAPI, args: unknown) { const params = GetCollectionParamsSchema.parse(args); try { const collection = await pylonClient.getCollection(params.id); return { content: [ { type: 'text', text: JSON.stringify(collection, null, 2) } ] }; } catch (error) { return { content: [ { type: 'text', text: `Error getting collection: ${error instanceof Error ? error.message : 'Unknown error'}` } ], isError: true }; } }
- src/tools/kbGetCollection.ts:5-18 (schema)MCP tool definition including input schema for the kb_get_collection tool.export const kbGetCollectionTool: Tool = { name: 'kb_get_collection', description: 'Get collection metadata and articles from the Pylon knowledge base', inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'Collection ID' } }, required: ['id'] } };
- src/schema.ts:14-16 (schema)Zod schema used for parsing and validating the input arguments in the handler.export const GetCollectionParamsSchema = z.object({ id: z.string().min(1, "Collection ID cannot be empty") });
- src/index.ts:39-43 (registration)Registration of the tool in the ListToolsRequest handler, making it discoverable.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [kbGetArticleTool, kbGetCollectionTool, kbGetArticlesTool], }; });
- src/index.ts:45-56 (registration)Dispatch registration in the CallToolRequest handler via switch case for 'kb_get_collection'.server.setRequestHandler(CallToolRequestSchema, async (request) => { switch (request.params.name) { case 'amplemarket_get_article': return await handleKbGetArticle(pylonClient, request.params.arguments); case 'kb_get_collection': return await handleKbGetCollection(pylonClient, request.params.arguments); case 'amplemarket_get_all_articles': return await handleKbGetArticles(pylonClient, request.params.arguments); default: throw new Error(`Unknown tool: ${request.params.name}`); } });