The Searchfox MCP Server provides AI assistants with comprehensive access to Mozilla's code search and analysis service for exploring Mozilla codebases.
Core Capabilities:
Advanced Code Search - Search using exact literal strings or regular expressions with advanced query syntax (symbol:, id:, path:, re: operators). Filter by repository, case sensitivity, language (C++, JavaScript, Rust, etc.), and exclude/include test files, generated files, or third-party code. Path filtering uses glob patterns with substring matching (supports ^ and $ anchoring).
Symbol Analysis - Search for symbols/identifiers and extract complete function/class definitions with intelligent brace-matching for C++, C, Rust, JavaScript, and WebIDL.
Call Graph Analysis - Analyze function call relationships with three modes: calls-from (what a function calls), calls-to (what calls a function), and calls-between (call paths between functions). Supports C++, Java, Kotlin, and Python with configurable traversal depth.
Memory Layout Analysis - View C++ class/struct memory layout including field offsets, sizes, alignment, base classes with offsets, and inheritance hierarchy.
Git Blame - Retrieve commit history (hash, author, date, message) for specific lines or entire files.
File Operations - Retrieve file contents with support for specific line ranges and additional context lines. Search for files matching path patterns.
Multi-Repository Support - Access mozilla-central (default), autoland, comm-central (Thunderbird), mozilla-beta, mozilla-release, and ESR branches.
Important Limitation: Search uses exact literal string matching by default—multiple words are treated as a single string, not OR logic. No built-in phrase matching with quotes. Use separate queries or enable regexp mode for broader searches.
Retrieves file contents from Mozilla repositories via GitHub's raw content API.
Provides access to Mozilla's Searchfox code search service, enabling code search across Mozilla repositories (mozilla-central, autoland, beta, release, ESR branches, and comm-central) and retrieval of file contents from these repositories.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Searchfox MCP Serversearch for 'console.log' in mozilla-central with case sensitivity"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Searchfox MCP Server
A comprehensive Model Context Protocol (MCP) server that provides full access to Mozilla's Searchfox code search and analysis service. This server enables AI assistants to search through Mozilla codebases, analyze code structure, retrieve file contents, and understand call relationships.
Prefer usingsearchfox-cli for agentic workflows (like Claude Code) instead of this MCP.
Features
Advanced Code Search: Unified search with advanced query syntax (symbol:, id:, path:, etc.)
Symbol Analysis: Search for symbols and extract complete definitions
Call Graph Analysis: Analyze function call relationships with three query modes
Memory Layout: View C++ class/struct memory layout with field offsets
Git Blame: Get commit history for specific lines or files
File Operations: Retrieve file contents with line range support
Path Search: Find files matching specific patterns
Multiple Repositories: Support for mozilla-central, autoland, mozilla-beta, ESR branches, and more
Available Tools (8 Total)
1. search
Unified code search with advanced query syntax and filtering capabilities.
Parameters:
query(string): Search query with optional advanced syntaxsymbol:Name- Symbol search (definitions/declarations)id:Name- Exact identifier matchingpath:dir/file- Path filterpathre:regex- Path regex filtertext:exact- Exact text searchre:pattern- Regular expression pattern
repo(string, optional): Repository to search in (default: "mozilla-central")case_sensitive(boolean, optional): Enable case sensitive searchlimit(number, optional): Maximum number of results (default: 50)context_lines(number, optional): Number of context lines before/after matchesfilters(object, optional): Additional filterslanguage: Filter by language (cpp, c, js, webidl, rust)exclude_tests: Exclude test filesexclude_generated: Exclude generated filesexclude_thirdparty: Exclude third-party filesonly_tests: Include only test files
Example:
2. get_file
Retrieve file contents with optional line range support.
Parameters:
path(string): File path within the repositoryrepo(string, optional): Repository name (default: "mozilla-central")lines(object, optional): Line range to retrievestart(number): Starting line number (1-based)end(number): Ending line number (inclusive)context(number): Additional context lines before/after range
Example:
3. search_paths
Find files by path pattern.
Parameters:
pattern(string): File path pattern to search forrepo(string, optional): Repository to search in (default: "mozilla-central")limit(number, optional): Maximum number of results (default: 100)
Example:
4. search_symbols
Dedicated symbol/identifier search with language and path filtering.
Parameters:
symbol(string): Symbol or identifier name to search fortype(string, optional): Search type - "symbol" (default) or "identifier"repo(string, optional): Repository to search in (default: "mozilla-central")path_filter(string, optional): Path filter to narrow resultslimit(number, optional): Maximum number of results (default: 50)language(string, optional): Filter by language (cpp, c, js, webidl, rust)
Example:
5. get_definition
Extract complete function/class definitions using intelligent brace-matching.
Parameters:
symbol(string): Symbol name to get definition forrepo(string, optional): Repository to search in (default: "mozilla-central")path_filter(string, optional): Path filter to find the right definitionlanguage(string, optional): Language hint - cpp, c, js, webidl, rust, or "auto" (default: "auto")max_lines(number, optional): Maximum number of lines to extract (default: 500)
Features:
Intelligent brace-matching state machine
Handles nested braces, strings, comments, escape sequences
Supports C++, C, Rust, JavaScript, and WebIDL
Scans backward to find function/class start
Includes initializer lists in C++
Example:
6. get_call_graph
Analyze function call relationships with three query modes.
Parameters:
mode(string): Query modecalls-from- What does this function call?calls-to- What calls this function?calls-between- Find call paths between two functions
source_symbol(string): Source symbol/function nametarget_symbol(string, optional): Target symbol (required for calls-between mode)repo(string, optional): Repository to search in (default: "mozilla-central")depth(number, optional): Maximum traversal depth 1-3 (default: 1)
Features:
Results grouped by class/namespace
Overloaded functions collapsed together
Formatted markdown output
Depth control for breadth-first traversal
Language Support:
✅ C++ (full support)
✅ Java, Kotlin, Python (via SCIP indexing)
❌ JavaScript/TypeScript (not supported)
Example:
7. get_field_layout
Get C++ class/struct memory layout information.
Parameters:
class_name(string): C++ class or struct namerepo(string, optional): Repository to search in (default: "mozilla-central")
Features:
Shows size and alignment in bytes
Lists base classes with offsets
Shows field offsets, sizes, and types
Handles template class variants
C++ only
Example:
8. get_blame
Get git blame information for files.
Parameters:
path(string): File path within the repositoryrepo(string, optional): Repository to search in (default: "mozilla-central")start_line(number, optional): Starting line number (default: 1)end_line(number, optional): Ending line number (inclusive)
Features:
Shows commit hash, author, date, and message
Supports line range filtering
Batches commit info requests for efficiency
Formatted markdown output
Example:
Supported Repositories
mozilla-central(default) - Main development branchautoland- Integration branchmozilla-beta- Beta release branchmozilla-release- Release branchmozilla-esr115,mozilla-esr128,mozilla-esr140- ESR branchescomm-central- Thunderbird codebase
Installation
Usage
Claude Desktop Configuration
Add to your claude_desktop_config.json:
Configuration file locations:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.json
Other MCP Clients
This server uses stdio transport and follows the MCP protocol specification. Configure your MCP client to run:
Query Syntax Examples
Basic Searches
Advanced Filtering
Workflow Examples
Understanding a New API:
Search for symbol:
{"query": "symbol:AudioContext"}Get definition:
{"symbol": "AudioContext", "language": "cpp"}See what it calls:
{"mode": "calls-from", "source_symbol": "mozilla::dom::AudioContext::Create"}Find usage:
{"mode": "calls-to", "source_symbol": "mozilla::dom::AudioContext::Create"}
Debugging a Crash:
Get implementation:
{"symbol": "MediaStream::AddTrack"}See what it calls:
{"mode": "calls-from", "source_symbol": "mozilla::dom::MediaStream::AddTrack"}Check blame:
{"path": "dom/media/MediaStream.cpp", "start_line": 100, "end_line": 150}
Memory Layout Analysis:
Get layout:
{"class_name": "mozilla::dom::AudioContext"}Check field sizes and offsets for padding analysis
Understand inheritance hierarchy
Development
Architecture
This MCP server is built with a modular architecture:
Related Projects
searchfox-cli - Command-line tool for Searchfox (Rust)
Searchfox - Mozilla's code search website
License
Licensed under either of
Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.