MCP Python Code Navigation Server

MCP Python Code Navigation Server

Provides tools for Python code navigation, analysis, and refactoring, including finding definitions, references, and symbol lists. It enables automated tasks such as renaming symbols and organizing imports to enhance AI-driven development.

Category
Visit Server

README

MCP Python Code Navigation Server

This project provides a powerful MCP (Model Context Protocol) server for Python that enhances AI-driven development by offering advanced code navigation, analysis, and refactoring capabilities.

Features

The server provides a suite of tools to understand and manipulate Python codebases:

  • Find Definition: Locate the definition of a symbol (variable, function, class, etc.).
  • Find References: Find all references to a symbol across the project.
  • Document Symbols: List all symbols (classes, functions, methods) in a given file.
  • Organize Imports: Automatically sort and format import statements.
  • Rename Symbol: Safely rename a symbol and all its references.
  • Import Graph: Visualize the import relationships between modules.
  • And more...: Check out the src/mcp_pytools/tools directory for a full list of available tools.

Getting Started

Prerequisites

  • Python 3.10+
  • uv (recommended for environment management)

Installation

  1. Clone the repository:

    git clone https://github.com/user/mcp_python.git # Replace with the actual URL
    cd mcp_python
    
  2. Create a virtual environment and install dependencies:

    uv venv
    source .venv/bin/activate
    uv pip install -e ".[dev]"
    

Running the Server

To run the MCP server, use the mcp-pytools-server command. You can optionally provide a path to the root of the Python project you want to analyze. If no path is given, it will default to the current directory.

mcp-pytools-server [PROJECT_ROOT_PATH]

Example:

To run the server for a project located at ~/code/my-python-project:

mcp-pytools-server ~/code/my-python-project

Configuring IDEs and Editors

To use this server with your favorite AI-powered editor, you need to configure it as an MCP server. Here are examples for some popular clients.

Note: You must use the absolute path to the mcp-pytools-server executable, which is located in your virtual environment's bin directory (e.g., /path/to/your/project/.venv/bin/mcp-pytools-server).

Gemini CLI / Claude Code / etc.

Create or edit your MCP configuration file (e.g., ~/.config/gemini/mcp.json or ~/.cursor/mcp.json) and add the following entry. This example sets up the server for a project located at ~/code/my-python-project.

{
  "mcpServers": {
    "python-code-tools": {
      "command": "/path/to/your/project/.venv/bin/mcp-pytools-server",
      "args": [
        "/path/to/your/project/src"
      ],
      "description": "MCP server for Python code navigation and refactoring."
    }
  }
}

Replace /path/to/your/project/.venv/bin/mcp-pytools-server with the actual absolute path to the server executable in your virtual environment and /path/to/your/project/src with the path to the code you want to analyze.

Usage Tips

Once the server is running and your editor is configured, you can start using its capabilities through natural language prompts. Here are some examples of what you can ask your AI assistant:

  • "Find the definition of the ServerContext class."
  • "Where is the create_tool_handler function used?"
  • "Rename the handler variable to tool_handler in server.py."
  • "List all the functions in src/mcp_pytools/tools/find_definition.py."
  • "Clean up the imports in src/mcp_pytools/server.py."

The server will process these requests and, with your confirmation, perform the corresponding actions on your codebase.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured