Skip to main content
Glama

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
NameRequiredDescriptionDefault
collection_idYesCollection ID, e.g., 'open-source-database'

Implementation Reference

  • 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 }; } }
  • 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) },
  • 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) }] };

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/damonxue/mcp-ossinsight'

If you have feedback or need assistance with the MCP directory API, please join our Discord server