get_collection
Retrieve detailed information about a specific collection of GitHub repositories to analyze open source ecosystems and gain insights into related projects.
Instructions
Get information about a specific collection of repositories
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| collection_id | Yes | Collection ID, e.g., 'open-source-database' |
Implementation Reference
- index.ts:208-243 (handler)The core handler function implementing the 'get_collection' tool logic. It fetches collection data from the OSSInsight API and falls back to web scraping if the API fails.async function getCollection(collectionId: string): Promise<any> { try { // Get collection data from API if available const collectionData = await apiRequest(`/collections/${collectionId}`); // Get web page URL for reference const webUrl = `${OSSINSIGHT_WEB_URL}/collections/${collectionId}`; // Try to get additional data from the web page const webData = await scrapeOSSInsightPage(webUrl, { title: 'h1', description: '.collection-description', // Add more selectors as needed }); return { collection_data: collectionData, web_data: webData, web_url: webUrl }; } catch (error) { // If API fails, rely on web page data console.error(`API request failed, falling back to web scraping: ${error}`); const webUrl = `${OSSINSIGHT_WEB_URL}/collections/${collectionId}`; return { web_data: await scrapeOSSInsightPage(webUrl, { title: 'h1', description: '.collection-description', repos_count: '.repos-count', // Add more selectors as needed }), web_url: webUrl }; } }
- schemas.ts:14-16 (schema)Zod schema defining the input parameters for the 'get_collection' tool, specifically the collection_id.export const GetCollectionParamsSchema = z.object({ collection_id: z.string().describe("Collection ID, e.g., 'open-source-database'") });
- index.ts:297-301 (registration)Tool registration in the list of available tools returned by ListToolsRequestSchema handler.{ name: "get_collection", description: "Get information about a specific collection of repositories", inputSchema: zodToJsonSchema(GetCollectionParamsSchema) },
- index.ts:336-340 (registration)Dispatch case in the CallToolRequestSchema handler that invokes the getCollection function.case "get_collection": { const args = GetCollectionParamsSchema.parse(request.params.arguments); const collection = await getCollection(args.collection_id); return { content: [{ type: "text", text: JSON.stringify(collection, null, 2) }] }; }