Skip to main content
Code Examples are one GitHits context tool. Use them when your agent needs prior art or implementation patterns from open-source repositories, issues, discussions, and pull requests, and does not need to inspect a specific package version or repository ref. The get_example MCP tool and its CLI counterpart npx githits@latest example accept a plain-language query and return an implementation example with source citations.
Code Examples are not version-aware. Use Code Navigation when your agent needs to inspect a specific package version or repository ref.

How agents use it

Your agent calls get_example automatically when it is stuck on an unfamiliar API, needs to validate a pattern, or encounters an error it cannot resolve from training data. You do not need to prompt it manually — once GitHits is connected via MCP, the agent decides when to reach for the tool. You can also trigger it explicitly from the CLI for manual research or to give your agent a head start with fresh context:
When using the CLI, pass --lang to force a language and --license to choose the license filter. The MCP parameters are named language and license_mode.

Parameters

string
required
Natural-language description of the code pattern or API usage you need. Write it the way you would describe the problem to a colleague — for example, "broadcast messages to specific rooms using python-socketio with Redis as the message queue backend".
string
Programming language to target. Omit this parameter and GitHits infers the language from your query automatically. Only supply it when you need to force a specific language and want to be exact. If you are unsure of the canonical name, use npx githits@latest languages first (see below).
string
default:"strict"
Controls license filtering for Code Examples only. Use strict by default, yolo for unfiltered research, or custom for your configured blocklist at githits.com.

Example output

The following query asks for a Python Redis pub/sub pattern. GitHits returns an implementation example alongside citations showing where that prior art appears in the open-source ecosystem.
The result includes:
  • An implementation example based on real-world usage
  • Source repository citations (e.g., socketio/socket.io-redis-adapter, miguelgrinberg/python-socketio)
  • A solution_id on the final line of the output, used when submitting feedback
Results are useful for current ecosystem patterns, not for version-pinned dependency inspection.

Language support

get_example supports over 800 programming languages. In most cases, GitHits infers the correct language from your query without any additional input. When you need to force a specific language and are unsure of the exact name GitHits expects, use the search_language tool or npx githits@latest languages command to look it up:
The command returns up to five matching languages by name, display name, or alias.
You only need npx githits@latest languages when you want to pass an explicit language parameter and need the canonical name. For most queries, skip it — GitHits infers the language automatically.

Submitting feedback

After reviewing an example, submit feedback with the solution_id from the output. See Feedback for the full tool reference.

MCP tool reference