MCP Code Search
Researchmcp-code-searchMCP Code Search is an Agent Skill for research published in the abhinand5/pi-setup repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Use the MCP grep server (`grep_searchGitHub`) for code search and GitHub code lookups instead of `web_search` or `code_search`. The `code_search` tool triggers an SSH passphrase prompt which blocks the workflow. The MCP grep tool searches literal code patterns across millions of public GitHub repos. Use whenever the user asks to find code examples, search GitHub repos, look up API usage patterns, or understand how libraries are used in real projects.
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Inspect the Agent Skill at https://github.com/abhinand5/pi-setup/blob/HEAD/skills/mcp-code-search/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/mcp-code-search, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
MCP Code Search
IMPORTANT: Tool Preference
When the user asks you to search for code, find GitHub examples, look up API usage patterns, or research how libraries are used in the wild:
- Always prefer the
mcptool withgrep_searchGitHuboverweb_searchorcode_search - Only fall back to
web_searchif the MCP grep server returns a 500 error or is unavailable - Never use the built-in
code_searchtool — it triggers an SSH passphrase prompt and blocks the workflow
How to Use the MCP Grep Tool
The grep_searchGitHub tool searches for literal code patterns (like grep), not keywords. Search for actual code that would appear in files.
Basic Usage
mcp({
tool: "grep_searchGitHub",
args: {
query: "literal code pattern to search",
language: ["TypeScript"],
}
})
Search Examples
| Goal | Query | Notes |
|---|---|---|
| Find React imports | "import React from" | Literal string |
| Find async functions | "async function" | Literal string |
| Find useState patterns | "useState(" | Literal string |
| Find multi-line patterns | "(?s)try {.*await" | Use useRegexp: true |
| Find specific repo patterns | "createAgentSession" | Use repo: "earendil-works/pi" |
Filter Parameters
query(string, required) — The literal code pattern to search forrepo(string) — Filter by repository, e.g."facebook/react","vercel/","microsoft/"path(string) — Filter by file path, e.g."src/components/Button.tsx","/route.ts"language(array) — Filter by language, e.g.["TypeScript", "TSX"],["Python"],["Rust"]matchCase(boolean) — Case-sensitive search (default: false)matchWholeWords(boolean) — Whole word matching (default: false)useRegexp(boolean) — Interpret query as regex (default: false). Prefix with(?s)for multi-line matching
Good vs Bad Queries
✅ Good (literal code that appears in files):
"useState(""import React from""async function""export default function""(?s)try {.*await"(withuseRegexp: true)
❌ Bad (keywords, not code):
"react tutorial""best practices""how to use""authentication in Next.js"
Fallback
If grep_searchGitHub returns an error (500, timeout, etc.), use web_search as a fallback to find what the user needs. Never use code_search.