Usage
Once GitHits MCP is connected, your AI agent can search for code examples. Most agents will do this automatically when relevant, but you can be explicit.
To make the coding agents use GitHits automatically when the get stuck, ensure that you have instructed the agents to use GitHits MCP as a search tool in their AGENTS.md or equivalent configuration.
For example, you could add the following instruction to the agent's configuration:
"Use GitHits MCP to search for real-world code examples when you encounter issues or need implementation patterns."
Available MCP Tools
GitHits MCP exposes the following tools to your AI agent:
search
Searches for code examples across GitHub repositories. Accepts a natural language query and programming language. Returns a distilled code example along with source references.
The search tool also accepts an optional license_mode parameter to control license filtering (see License Filtering below). If not specified, it defaults to your user preference.
Search results include license SPDX IDs in references, so you can see which license applies to each source.
feedback
Submit feedback on a search result. After receiving a search result, your agent can indicate whether the example was helpful (accepted: true) or not (accepted: false), along with optional text feedback. This helps improve GitHits search quality over time.
search_language
Look up supported programming languages by name. Use this to find the correct language identifier before calling search.
License Filtering
GitHits filters search results based on software licenses to help you avoid copyleft-licensed code when needed. There are three license modes:
You can set your default license mode in your GitHits account settings under Preferences. Your agent can also override the mode per search by passing the license_mode parameter.
Each search result's references now include the SPDX license ID, so you always know the license of the source code.
Manual Prompting Patterns
Tell your agent to search GitHits when you see that the agent is struggling or hallucinating. Here are some simple example prompts:
- "Search GitHits for React authentication with Supabase and create a login component"
- "Find examples of rate limiting in Express on GitHits and implement similar middleware"
- "Look up file upload handling with S3 presigned URLs on GitHits and add that to our API"
Being Specific
Vague requests don't work well:
- ❌ "Create an auth system"
- ✅ "Search GitHits for JWT auth in Express with TypeScript and implement the middleware"
Include the technologies you're using:
- ❌ "Add form validation"
- ✅ "Find React Hook Form with Zod validation on GitHits and apply it to our signup"
Reference actual problems:
- ❌ "Fix the API errors"
- ✅ "Search GitHits for CORS error solutions in Next.js and fix our /api/users route"