> ## Documentation Index
> Fetch the complete documentation index at: https://docs.morphllm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# GitHub Search

> Search public GitHub repositories without cloning

Search public GitHub repositories without cloning them locally. WarpGrep clones and searches the repo on Morph's servers — no local clone or ripgrep needed.

### Why?

Use GitHub search when your primary agent needs to find code snippets from a public repository that isn't cloned locally — exploring how an open-source library works, finding usage patterns, or pulling reference implementations.

See the [GitHub search example](https://github.com/morphllm/examples/tree/main/warpgrep/github-search).

## Direct Usage

```typescript theme={null}
import { MorphClient } from '@morphllm/morphsdk';

const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });

const result = await morph.warpGrep.searchGitHub({
  searchTerm: 'Find authentication middleware',
  github: 'vercel/next.js',       // or full URL: 'https://github.com/vercel/next.js'
  branch: 'canary',               // optional, defaults to repo's default branch
});

if (result.success) {
  for (const ctx of result.contexts) {
    console.log(`${ctx.file}: ${ctx.content}`);
  }
}
```

## As an Agent Tool

Each SDK adapter provides `createGitHubSearchTool()`:

```typescript theme={null}
const githubTool = morph.anthropic.createGitHubSearchTool();
// Or: morph.openai.createGitHubSearchTool()
// Or: morph.vercel.createGitHubSearchTool()
```

Pass `githubTool` in your `tools` array the same way as `createWarpGrepTool`. GitHub search returns the same `WarpGrepResult` format as codebase search.

## Options

`createGitHubSearchTool()` accepts:

| Option          | Default                    | Description              |
| --------------- | -------------------------- | ------------------------ |
| `morphApiKey`   | `MORPH_API_KEY` env var    | API key for Morph        |
| `morphApiUrl`   | `https://api.morphllm.com` | Override API base URL    |
| `codeSearchUrl` | `https://morphllm.com`     | Code storage service URL |
| `timeout`       | `30000`                    | Timeout in ms            |
