Grep’s code search is now an MCP endpoint
Grep, the search engine for public GitHub repositories, now exposes its index through the Model Context Protocol (MCP). That means AI assistants and custom agents can query over a million repositories using the same standard interface they already use for other tools, over HTTP.
The new Grep MCP server provides a search endpoint that accepts plain-text queries or regular expressions, with optional filters for language, repository, and file path. It’s backed by the same infrastructure as grep.app, and results typically come back in under a second, ranked by relevance.
Connecting an AI client
MCP servers expose tools through machine-readable schemas, so clients can discover and invoke them without custom integration code. Adding Grep to your AI client is just a matter of configuration.
In Cursor:
{
"mcpServers": {
"grep": {
"url": "https://mcp.grep.app"
}
}
}
With Claude Code:
claude mcp add --transport http grep https://mcp.grep.app
Using Grep to answer technical questions
The usefulness of this setup shows up in practice when an agent needs to ground its answer in real code. Suppose you’re building an MCP server yourself and want to know the correct way to return an error to a client. You could ask your agent:
What's the right way for this MCP tool to return an error message to the client?
If Grep is configured, the agent can run code searches to find how other projects handle this. It might try several queries and land on one that looks for a server.tool function call with a catch block:
{
"query": "(?s)server\\.tool.*catch",
"language": [
"TypeScript",
"JavaScript"
],
"useRegexp": true
}
The search results come back as structured snippets:
Repository: microsoft/rushstack
Path: apps/rush-mcp-server/src/tools/base.tool.ts
URL: https://github.com/microsoft/rushstack/blob/main/apps/rush-mcp-server/src/tools/base.tool.ts
License: Unknown
Snippets:
--- Snippet 1 (Line 39) ---
public register(server: McpServer): void {
// TODO: remove ts-ignore
// @ts-ignore
server.tool(this._options.name, this._options.description, this._options.schema, async (...args) => {
try {
const result: CallToolResult = await this.executeAsync(...(args as Parameters<ToolCallback<Args>>));
return result;
} catch (error: unknown) {
return {
isError: true,
content: [
The pattern in those results suggests the answer: set isError: true when returning an error response from an MCP tool call. To verify, the agent can run another query:
{
"query": "isError: true",
"language": [
"TypeScript",
"JavaScript"
]
}
That query surfaces more examples of error handling in real MCP server implementations, giving the agent enough evidence to answer the question and offer to update your project accordingly.
Lightweight implementation
Grep’s MCP server was built in an afternoon using Vercel’s mcp-handler package. The adapter handles the MCP schema, request routing, and response formatting, so the only real work was mapping Grep’s existing search API to the MCP contract. The same approach works for exposing any existing tool or API to AI clients, with deployment handled on Vercel.



