list_collections
Retrieve available repository collections to analyze GitHub data for open source insights. Supports pagination with page and per-page parameters.
Instructions
List all available repository collections
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page | No | Page number, starting from 1 | |
| per_page | No | Number of results per page, default is 20 |
Implementation Reference
- index.ts:245-269 (handler)Core handler function that fetches the list of collections from OSSInsight API, with fallback to web URL.async function listCollections(page: number = 1, perPage: number = 20): Promise<any> { try { // Get collections from API if available const collectionsData = await apiRequest('/collections', { page, per_page: perPage }); // Get web page URL for reference const webUrl = `${OSSINSIGHT_WEB_URL}/collections`; return { collections: collectionsData, web_url: webUrl }; } catch (error) { // If API fails, provide just the collections web URL console.error(`API request failed: ${error}`); return { message: "API request failed. Please visit the web URL to browse collections.", web_url: `${OSSINSIGHT_WEB_URL}/collections` }; } }
- schemas.ts:18-21 (schema)Zod schema defining optional input parameters page and per_page for pagination.export const ListCollectionsParamsSchema = z.object({ page: z.number().optional().describe("Page number, starting from 1"), per_page: z.number().optional().describe("Number of results per page, default is 20") });
- index.ts:302-306 (registration)Tool registration in the listTools response, specifying name, description, and input schema.{ name: "list_collections", description: "List all available repository collections", inputSchema: zodToJsonSchema(ListCollectionsParamsSchema) },
- index.ts:342-346 (handler)Dispatcher handler case within CallToolRequest that parses args, calls listCollections, and formats response.case "list_collections": { const args = ListCollectionsParamsSchema.parse(request.params.arguments); const collections = await listCollections(args.page, args.per_page); return { content: [{ type: "text", text: JSON.stringify(collections, null, 2) }] }; }