get_collection
Retrieve details about a specific repository collection using its unique ID, enabling access to structured data for GitHub repository analysis and insights.
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 getCollection function implements the core logic for the 'get_collection' tool. It fetches collection data from the OSSInsight API endpoint `/collections/{collectionId}` and falls back to scraping the web page 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: a required 'collection_id' string.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 ListToolsRequest handler, defining the name, description, and inputSchema for client discovery.{ name: "get_collection", description: "Get information about a specific collection of repositories", inputSchema: zodToJsonSchema(GetCollectionParamsSchema) },
- index.ts:336-339 (helper)Dispatch logic in the CallToolRequest handler that validates input with the schema, calls the handler function, and formats the response.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) }] };