Integrations

MCP Server

Run xgrep as a Model Context Protocol server for AI agents — the full tool list, inputs, and how it differs from the CLI.

MCP Server

Run xgrep as an MCP server so an AI agent can scan for vulnerabilities and navigate a codebase through structured tool calls:

xgrep mcp                 # serve over stdio
xgrep mcp -f rules/       # preload a rule set for the scan tool (see below)

The server speaks MCP over stdio — point any MCP-capable client (Claude Code, editor agents, your own harness) at the xgrep mcp process. For how agents combine these tools in practice — scan, trace dataflow, triage a finding — see AI agents.

Tools

The server exposes 18 tools in three groups: one scanning tool, the code-graph tools, and the code-intelligence (inspect) tools. All are read-only.

Scanning

ToolInputsDescription
scanpath (required), rules, languageRun xgrep rules against a local file or directory and return findings as JSON.

scan inputs:

  • path — a local file or directory. A directory is scanned recursively. (Unlike the CLI, the scan tool does not accept remote-repo URLs or stdin — see Differences from the CLI.)
  • rules — path to a rule file or directory. Optional: when omitted (and the server wasn't started with -f/--rules), the scan tool falls back to the built-in corpus filtered to security + secrets — the same out-of-the-box default as the CLI (ADR-0172) — so an agent can scan without configuring rules first.
  • language — force a language (e.g. go, python, javascript) instead of detecting it from the file extension.

Code graph

Build and query the call graph. The graph is built on first use and cached in memory for the life of the server process.

ToolInputsDescription
graph_buildpathBuild or refresh the code graph for a directory.
graph_callersnameFind all callers of a function.
graph_calleesnameFind all functions called by a function.
graph_pathssource, targetFind call paths between two functions.
graph_contextname, depthN-hop call neighborhood with inlined source, for understanding code flow.
graph_reachablenameAll functions transitively reachable from a function via call edges.

name matches a function by partial name or a full ID like pkg/file.go::FuncName.

Code intelligence

The same capabilities as xgrep inspect, exposed as tools. The code graph and search index are built on first use and cached in .xgrep/.

ToolCLI equivalentDescription
codebase_overviewinspect overviewLanguages, packages, entry points, key types. Run this first in an unfamiliar codebase.
symbol_searchinspect symbolFind a symbol by name (exact, prefix, or substring) with its location.
text_searchinspect searchFast trigram-indexed text search (substring or regex, with language/file filters).
go_to_definitioninspect definitionFind the definition of the symbol at a file:line:col position.
hoverinspect hoverDocumentation, type info, and parameters for the symbol at a position.
get_rangesinspect rangesAll symbols in a line range of a file, with docs and type info.
find_referencesinspect referencesAll usages of a symbol: callers, callees, and reference edges.
find_implementationsinspect implementationsAll types implementing an interface.
file_symbolsinspect outlineOutline of a file — every symbol, sorted by line.
impact_analysisinspect impactBlast radius of changing a symbol: callers, affected files, risk score.
dependency_graphinspect depsUpstream/downstream call dependencies, transitively.

Differences from the CLI

The MCP scan tool is a deliberately narrow surface for agents — it is not a full mirror of the CLI scan:

CLI xgrep scanMCP scan tool
Local file / directoryYesYes
Multiple targetsYesOne path
Remote git repo (URL/shorthand)YesNo
stdin / stdin manifestYes (--stdin, --stdin-files)No
Built-in rule corpus by defaultYes (security,secrets)Yes (security,secrets)
--category / --subcategory / --severity filtersYesNo (built-in fallback is fixed to security,secrets)
--include / --exclude globsYesNo

For scans that need remote repositories, stdin, or category/severity filtering, drive the CLI directly. The graph and inspect tools, by contrast, are a complete mirror of their inspect and graph commands.

On this page