search_spryker_packages
Search for Spryker packages in GitHub repositories using natural language queries. Filter results by specific organizations to quickly locate modules and documentation.
Instructions
To search the Spryker package repository in Github
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| organisations | No | Optional array of organisations to filter by [`spryker`, `spryker-eco`, `spryker-sdk`, `spryker-shop` | |
| query | Yes | The natural language query to search in Github |
Implementation Reference
- src/tools.js:14-56 (handler)The handler function that executes the tool logic: normalizes query, validates organizations, builds GitHub search query, performs repository search, formats results, and returns text content.export const searchSprykerPackages = async ({query, organisations}) => { logger.info(`Received searchSprykerPackages request`, { query, organisations }); try { const normalizedQuery = normalizeQuery(query); const validatedOrgs = validateOrganisations(organisations); logger.info(`Using organizations for searchSprykerPackages`, { organisations: validatedOrgs }); const githubQuery = buildGitHubQuery(normalizedQuery, validatedOrgs); logger.info(`Performing GitHub repository searchSprykerPackages`, { query: githubQuery }); const searchResults = await searchGitHubRepositories(githubQuery); logger.info(`GitHub searchSprykerPackages completed`, { resultCount: searchResults.items ? searchResults.items.length : 0, totalCount: searchResults.total_count }); const formattedText = formatResults(searchResults.items, validatedOrgs); logger.debug(`Search results formatted for display`); return { content: [{ type: `text`, text: formattedText }] }; } catch (error) { logger.error(`Error in search: ${error.message}`, { error, stack: error.stack }); return { content: [{ type: `text`, text: `Error performing search: ${error.message}` }] }; } }
- src/index.js:38-53 (registration)Registers the 'search_spryker_packages' tool with the MCP server, including input schema validation using Zod and linking to the searchSprykerPackages handler.server.tool( `search_spryker_packages`, `To search the Spryker package repository in Github`, { query: z .string() .max(120) .min(5) .describe(`The natural language query to search in Github`), organisations: z .array(z.string()) .optional() .describe(`Optional array of organisations to filter by [\`spryker\`, \`spryker-eco\`, \`spryker-sdk\`, \`spryker-shop\``) }, searchSprykerPackages );
- src/utils.js:10-12 (helper)Helper function to normalize the search query by trimming and normalizing whitespace.export const normalizeQuery = (query) => { return query.trim().replace(/\s+/g, ` `); };
- src/utils.js:20-32 (helper)Helper function to validate and default organizations list for filtering searches.export const validateOrganisations = (organisations = []) => { if (!organisations || organisations.length === 0) { return SPRYKER_ORGS; } const validatedOrgs = organisations.filter(org => SPRYKER_ORGS.includes(org)); if (validatedOrgs.length === 0) { return SPRYKER_ORGS; } return validatedOrgs; };
- src/utils.js:41-57 (helper)Helper function to format the GitHub search results into readable text.export const formatResults = (repositories, organisations) => { if (!repositories || repositories.length === 0) { return `No repositories found matching your searchSprykerPackages criteria.`; } let formattedText = `Found ${repositories.length} repositories:\n\n`; repositories.forEach((repo, index) => { formattedText += `${index + 1}. ${repo.name}\n`; formattedText += ` Description: ${repo.description || `No description available`}\n`; formattedText += ` URL: ${repo.html_url}\n\n`; }); formattedText += `Search performed across organizations: ${organisations.join(`, `)}`; return formattedText; };