list_collections
Retrieve all repository collections with pagination support. Use this tool to explore and analyze GitHub data for open source ecosystems through the OSSInsight MCP Server.
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)The core handler function that fetches the list of collections from the OSSInsight API endpoint '/collections' with pagination support, includes error handling with fallback 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 pagination parameters (page, per_page) for the list_collections tool input.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 ListToolsRequest handler, specifying name, description, and input schema.{ name: "list_collections", description: "List all available repository collections", inputSchema: zodToJsonSchema(ListCollectionsParamsSchema) },
- index.ts:342-346 (handler)Dispatcher case in the CallToolRequestSchema handler that parses arguments, calls the listCollections function, and formats the 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) }] }; }