Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.githits.com/llms.txt

Use this file to discover all available pages before exploring further.

The get_example MCP tool and its CLI counterpart npx githits@latest example let you search the latest GitHub data using plain natural language. GitHits returns a distilled, source-cited code example based on real repositories, issues, discussions, and pull requests.
Code Examples are not version-aware. They use the latest available GitHub data. 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:
npx githits@latest example "how to use Redis pub/sub in Python"

Parameters

query
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".
language
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).
license_mode
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 a working implementation alongside citations showing where the pattern comes from in the open-source ecosystem.
npx githits@latest example "broadcast messages to specific rooms using python-socketio with Redis pub/sub"
The result includes:
  • A canonical code example distilled from multiple real-world implementations
  • 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
import socketio
import asyncio
import redis.asyncio as redis

# Initialize Redis client
r = redis.Redis(host='localhost', port=6379, decode_responses=True)

# Create AsyncRedisManager for horizontal scaling via Redis pub/sub
mgr = socketio.AsyncRedisManager(r)

# Create SocketIO server with the Redis manager
sio = socketio.AsyncServer(client_manager=mgr)

@sio.event
async def broadcast_to_room(sid, data):
    room = data.get('room')
    message = data.get('message')
    if room and message:
        await sio.emit('room_message', {'message': message, 'from': sid}, room=room)

app = socketio.ASGIApp(sio)
Results reflect the latest available GitHub data, including recent repository changes and discussions. They 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:
npx githits@latest languages typescript
npx githits@latest languages elixir
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

ToolCLI commandPurpose
get_examplenpx githits@latest exampleNatural-language search returning a canonical code example
search_languagenpx githits@latest languagesList or filter supported language names