What is MCP?
Model Context Protocol (MCP) is an open standard introduced by Anthropic that enables AI assistants to connect with external tools and data sources in a standardized way. Think of it like USB for AI - one protocol that works everywhere.
Learn more about MCP at the official MCP introduction guide.
Code Pathfinder implements an MCP server that exposes your codebase's structure, call graphs, and relationships to AI assistants through 6 powerful tools.
Prerequisites
Before setting up the MCP server, you need:
- Code Pathfinder installed on your system
- An MCP-compatible AI assistant (Claude Code, Open Code, Codex, etc.)
- A Python project to analyze (currently Python only, more languages coming soon)
Installation
Install Code Pathfinder
👉 Follow the Quickstart Guide for detailed installation instructions.
The quickstart guide covers all installation methods:
- Homebrew (macOS/Linux)
- pip (Python 3.8+)
- Docker
- From Source
Setting Up with AI Assistants
Code Pathfinder MCP server works seamlessly with Claude Code, Open Code, Codex, and other MCP-compatible AI assistants.
Step 1: Locate Your Configuration File
Your AI assistant stores its MCP server configuration in a JSON file. The location depends on your tool:
Claude Code (macOS/Linux):
~/.config/claude/mcp_config.jsonOpen Code / VS Code with MCP:
~/.vscode/mcp_servers.jsonCodex:
~/.config/openai/codex/config.tomlStep 2: Add MCP Server Configuration
Open the configuration file in your text editor and add the Code Pathfinder MCP server.
For Claude Code / Open Code / VS Code:
{
"mcpServers": {
"code-pathfinder": {
"command": "pathfinder",
"args": [
"serve",
"--project",
"/absolute/path/to/your/project"
]
}
}
}For Codex:
[mcp_servers.code-pathfinder]
command = "pathfinder"
args = ["serve", "--project", "/absolute/path/to/your/project"]Important:
- Use absolute paths for the
--projectargument - Replace
/absolute/path/to/your/projectwith your actual project directory - Do NOT use
~for home directory - expand it to the full path
Multiple Projects
You can configure multiple projects by adding more MCP servers.
For Claude Code / Open Code / VS Code:
{
"mcpServers": {
"project-backend": {
"command": "pathfinder",
"args": ["serve", "--project", "/Users/you/code/backend"]
},
"project-frontend": {
"command": "pathfinder",
"args": ["serve", "--project", "/Users/you/code/frontend"]
}
}
}For Codex:
[mcp_servers.project-backend]
command = "pathfinder"
args = ["serve", "--project", "/Users/you/code/backend"]
[mcp_servers.project-frontend]
command = "pathfinder"
args = ["serve", "--project", "/Users/you/code/frontend"]Custom Python Version
Override automatic Python version detection.
For Claude Code / Open Code / VS Code:
{
"mcpServers": {
"code-pathfinder": {
"command": "pathfinder",
"args": [
"serve",
"--project", "/path/to/project",
"--python-version", "3.11"
]
}
}
}For Codex:
[mcp_servers.code-pathfinder]
command = "pathfinder"
args = ["serve", "--project", "/path/to/project", "--python-version", "3.11"]Step 3: Test Your Setup
Try these example queries in your AI assistant:
Example Query:
Find all functions that call process_paymentExpected Response:
The process_payment function is called by:
- checkout_handler (line 45 in handlers/checkout.py)
- subscription_renewal (line 89 in services/billing.py)
- refund_processor (line 23 in handlers/refunds.py)Example Query:
Show me what functions validate_user callsExpected Response:
The validate_user function calls:
- check_email_format (line 12 in utils/validators.py)
- verify_password_strength (line 34 in utils/validators.py)
- query_user_database (line 67 in database/users.py)If your AI assistant responds with similar code intelligence from your project, everything is working!
HTTP Transport (Optional)
For remote access or custom integrations, you can run the MCP server in HTTP mode:
$ pathfinder serve --project /path/to/project --http --address :8080This starts an HTTP server on port 8080 that accepts MCP requests over HTTP instead of stdio.
Use cases for HTTP mode:
- Team collaboration (shared code analysis server)
- CI/CD integrations
- Custom web-based tools
- Remote development environments
Troubleshooting
Common issues and solutions when setting up the MCP server
Cause: Your AI assistant can't find the pathfinder command in your system PATH.
Solution: Ensure pathfinder is properly installed and available in your PATH:
$ which pathfinder
# Should print: /usr/local/bin/pathfinder (or similar)If not found, reinstall Code Pathfinder or add the installation directory to your PATH environment variable.
Cause: The --project path specified in your configuration doesn't exist or uses relative path notation.
Solution:
- Always use absolute paths (e.g.,
/Users/you/project, not~/project) - Verify the directory actually exists on your filesystem
- Check for typos in the path
ls /path/to/projectCause: The server may have failed to index your project, encountered parsing errors, or crashed during initialization.
Solution:
- Check your AI assistant's logs for MCP server error output
- Try starting the server manually in a terminal to see error messages
- Verify your project contains Python files to analyze
- Check for syntax errors in your Python files that may prevent parsing
$ pathfinder serve --project /path/to/project
# Watch for errors in terminal outputCause: The auto-detected Python version doesn't match your project's Python version, causing parsing or analysis errors.
Solution: Explicitly specify the Python version in your MCP configuration:
{
"mcpServers": {
"code-pathfinder": {
"command": "pathfinder",
"args": [
"serve",
"--project", "/path/to/your/project",
"--python-version", "3.11"
]
}
}
}Replace 3.11 with your project's actual Python version (3.8, 3.9, 3.10, 3.11, 3.12, etc.).