Skip to main content
Glama

search_repositories

Search GitHub repositories using a custom query. Returns a concise list of repositories with essential information.

Instructions

Search for GitHub repositories. Returns a concise list with essential information. Use 'get_repository' for detailed information about a specific repository.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query. Examples: 'language:typescript stars:>1000', 'org:facebook react', 'machine learning in:description', 'user:octocat', 'created:>2023-01-01', 'license:mit', 'topic:javascript', 'is:public archived:false'
per_pageNoResults per page (default 10, max 100)
pageNoPage number (default 1)

Implementation Reference

  • The 'search_repositories' MCP tool is defined here (line 54) via server.tool(). The handler (lines 73-120) calls octokit.rest.search.repos with the query, per_page, and page parameters, maps results to a concise format (full_name, description truncated to 150 chars, stars, language, recent updated date), and returns formatted text content.
    server.tool(
    	"search_repositories",
    	"Search for GitHub repositories. Returns a concise list with essential information. Use 'get_repository' for detailed information about a specific repository.",
    	{
    		query: z
    			.string()
    			.describe(
    				"Search query. Examples: 'language:typescript stars:>1000', 'org:facebook react', 'machine learning in:description', 'user:octocat', 'created:>2023-01-01', 'license:mit', 'topic:javascript', 'is:public archived:false'",
    			),
    		per_page: z
    			.number()
    			.optional()
    			.default(10)
    			.describe("Results per page (default 10, max 100)"),
    		page: z
    			.number()
    			.optional()
    			.default(1)
    			.describe("Page number (default 1)"),
    	},
    	async ({ query, per_page, page }) => {
    		try {
    			const response = await octokit.rest.search.repos({
    				q: query,
    				per_page,
    				page,
    			})
    
    			// Extract only essential information
    			const repositories = response.data.items.map(repo => ({
    				full_name: repo.full_name,
    				description:
    					repo.description?.slice(0, 150) +
    					(repo.description && repo.description.length > 150 ? "..." : ""),
    				stars: repo.stargazers_count,
    				language: repo.language,
    				// Only include updated_at if it's recent (within last year)
    				...(new Date(repo.updated_at).getTime() >
    				Date.now() - 365 * 24 * 60 * 60 * 1000
    					? { updated: new Date(repo.updated_at).toISOString().split("T")[0] }
    					: {}),
    			}))
    
    			// Format as simple text
    			const text = repositories
    				.map(
    					(repo, i) =>
    						`${i + 1}. **${repo.full_name}**${repo.stars ? ` - ${repo.stars.toLocaleString()} stars` : ""}${repo.language ? ` - \`${repo.language}\`` : ""}
      ${repo.description || "_No description_"}${repo.updated ? `\n   _Updated: ${repo.updated}_` : ""}`,
    				)
    				.join("\n\n")
    
    			return {
    				content: [
    					{
    						type: "text",
    						text: text
    							? `### Found ${repositories.length} repositories:\n\n${text}`
    							: "No repositories found",
    					},
    				],
    			}
    		} catch (e: any) {
    			return {
    				content: [{ type: "text", text: `Error: ${e.message}` }],
    			}
    		}
    	},
    )
  • Input schema for 'search_repositories': query (string, required), per_page (number, optional, default 10), page (number, optional, default 1) — defined using Zod schemas.
    {
    	query: z
    		.string()
    		.describe(
    			"Search query. Examples: 'language:typescript stars:>1000', 'org:facebook react', 'machine learning in:description', 'user:octocat', 'created:>2023-01-01', 'license:mit', 'topic:javascript', 'is:public archived:false'",
    		),
    	per_page: z
    		.number()
    		.optional()
    		.default(10)
    		.describe("Results per page (default 10, max 100)"),
    	page: z
    		.number()
    		.optional()
    		.default(1)
    		.describe("Page number (default 1)"),
    },
  • src/index.ts:14-38 (registration)
    Registration of the tool: registerSearchTools(server, octokit) called inside registerAllToolsAndResources which is invoked by both CLI and HTTP entry points.
    export function registerAllToolsAndResources(server: McpServer, octokit: Octokit): void {
    	registerSearchTools(server, octokit)
    	registerIssueTools(server, octokit)
    	registerRepositoryTools(server, octokit)
    	registerPullRequestTools(server, octokit)
    	registerRepositoryResource(server, octokit)
    
    	// Hello tool — verifies MCP server connectivity
    	server.tool(
    		"hello",
    		"A simple test tool to verify that the MCP server is working correctly",
    		{},
    		async () => ({
    			content: [
    				{
    					type: "text",
    					text: JSON.stringify({
    						message: "Hello from GitHub MCP Server!",
    						timestamp: new Date().toISOString(),
    					}, null, 2),
    				},
    			],
    		}),
    	)
    }
  • src/index.ts:15-17 (registration)
    The registerSearchTools function is imported from './tools/search.js' and called during server initialization.
    registerSearchTools(server, octokit)
    registerIssueTools(server, octokit)
    registerRepositoryTools(server, octokit)
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description only discloses that it returns a 'concise list with essential information.' It does not mention rate limits, authentication, or side effects, which is acceptable for a search tool but adds little beyond the schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, front-loaded with the main purpose, and the second sentence provides a useful alternative. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description is adequate for a simple search tool with well-documented schema, but lacks details about what 'essential information' is returned (no output schema), leaving some ambiguity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% and provides detailed examples. The description adds no additional meaning to the query, per_page, or page parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states 'Search for GitHub repositories' with a specific verb and resource. Differentiates from sibling 'get_repository' by directing users to that tool for detailed info.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly provides an alternative tool ('get_repository') for detailed repo info, but does not further clarify when not to use this tool (e.g., for exact name lookup).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/hithereiamaliff/mcp-github'

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