python-mcp-server
Detects Django projects and provides analysis of modules, classes, functions, and API endpoints (list_api_endpoints).
Detects FastAPI projects and provides analysis of modules, classes, functions, and API endpoints (list_api_endpoints).
Detects Flask projects and provides analysis of modules, classes, functions, and API endpoints (list_api_endpoints).
Detects PDM as the build system in Python projects via detect_build_system.
Detects Poetry as the build system in Python projects via detect_build_system.
Extracts environment variable reads from Pydantic Field(env=...) in Python projects via extract_environment_dependencies.
Detects SQLAlchemy usage in Python projects as part of framework detection.
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., "@python-mcp-serverlist all classes in the current project"
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.
python-mcp-server
MCP (Model Context Protocol) server for deterministic static analysis of Python code, built with LibCST + Jedi.
Motivation
This project is inspired by the deterministic analysis approach of cobol-mcp-server. Just as that project demonstrates that COBOL can be analyzed deterministically via AST (without AI), python-mcp-server applies the same principle to the Python ecosystem:
LibCST — parses source code into a concrete AST, guaranteeing 100% deterministic analysis (no guesswork).
Jedi — optional type resolution for finding definitions and references (on-demand, no classpath required).
No code execution — only static syntax analysis.
The result is an MCP server that exposes Python code analysis tools to any MCP client (OpenCode, Claude Desktop, etc.).
Related MCP server: neatcode-mcp
Tools
Tool | Description |
| Loads a project from local path, Git URL, or archive (.zip/.tar.gz) |
| Removes a loaded project from memory |
| Lists all projects currently in memory |
| Shows project metadata (build, modules, classes, functions) |
| Detects the build system (pip, poetry, pdm, hatch, uv, conda, etc.) |
| Detects frameworks/libs in use (Flask, Django, FastAPI, SQLAlchemy, etc.) |
| Lists all Python modules in the project |
| Lists all classes in the project |
| Lists all functions and methods in the project |
| Deep-dives into a class: bases, methods, decorators, docstring |
| Deep-dives into a function: signature, parameters, body, decorators |
| Lists all imports in the project |
| Lists all decorators used with their frequencies |
| Finds classes/functions decorated with a specific decorator |
| Shows inheritance hierarchy (bases and direct subclasses) |
| Searches text in the project source code |
| Searches text across all loaded projects simultaneously |
| Finds the definition of a symbol (requires |
| Finds references to a symbol (requires |
| Reads the raw source content of any file in the project |
| Returns specific source lines with line numbers from a file |
| Checks if a class, function, or variable exists (EXISTS/NOT_FOUND) |
| Resolves a type name to its definition, tracing imports across the project |
| Deep-dives into a module: docstring, variables, functions, classes, imports |
| Static call graph: shows which functions are called and which call a given function |
| Cross-references a variable: shows declarations, writes, and reads across the project |
| Lists all enum classes with their members and values |
| Builds a dependency map showing which modules import which |
| Finds all functions/methods that return a specific type annotation |
| Finds where the program starts: if name, console_scripts, web apps, CLI apps, async runners |
| Lists all API route/endpoint definitions (FastAPI, Flask, Starlette, Django) with paths and handlers |
| Extracts environment variable reads, config file loads, and Pydantic Field(env=...) |
| Classifies functions by side effects: FILE_IO, NETWORK, DB, LOG, MUTATION, or PURE |
| Analyzes error handling: custom exceptions, raises, try/except patterns, bare excepts |
| Shows the public API surface: all, init.py re-exports, top-level public definitions |
| Maps production code to tests by analyzing test file imports |
| Extracts domain-specific vocabulary — key entities, module docstrings, domain terms |
Building the .pyz (fat-pyz)
Important:
shivmust be installed in the Python interpreter that you use to build the wheel. The resulting.pyzwill then be runnable on any Python 3.8+ system interpreter, but the build itself must be done with a Python version you want to ship wheels for.
The package layout is src/pymcp/ (declared in pyproject.toml via setuptools.packages.find), so shiv discovers it automatically when run from the project root.
Build inside a venv (recommended)
# 1. Create / activate a venv (use any Python 3.8+ interpreter)
python -m venv .venv
source .venv/bin/activate
# 2. Install build tooling
pip install shiv
# 3. Build the fat .pyz from the project root
shiv -o python-mcp-server.pyz -e pymcp.main:main -p "/usr/bin/env python3" .For reproducible builds, create the venv with a pinned interpreter, e.g.
python3.11 -m venv .venv. This guarantees the bundled wheels match the target Python's ABI.
Why this matters
shivresolves dependencies viapip, which downloads wheels built for the active interpreter's ABI (e.g.cp311for Python 3.11).If you build with Python 3.14 and try to run the
.pyzwith the system's Python 3.11, you'll getzipimport.ZipImportErrorbecause the bundledcp314wheels are not compatible.The
pyproject.tomlpinsrequires-python = ">=3.8". Make sure the Python used to build the.pyzis the same major.minor you intend to run it with.
Smoke test
./python-mcp-server.pyz # starts the MCP server on stdio and logs to /tmp/python_mcp_server.logThe resulting .pyz is standalone — it includes all dependencies (mcp, libcst, jedi, GitPython) and works with any Python 3.8+ interpreter.
You can also run the installed entrypoint directly:
python-mcp-serverOpenCode Configuration
Add the following to your opencode.json or opencode.yml:
{
"mcpServers": {
"python-mcp-server": {
"command": "python",
"args": ["python-mcp-server.pyz"],
"transport": "stdio"
}
}
}Or if installed as a package:
{
"mcpServers": {
"python-mcp-server": {
"command": "python-mcp-server",
"transport": "stdio"
}
}
}Environment Variables
Variable | Default | Description |
|
| Log file path |
|
| Log level (DEBUG, INFO, WARNING, ERROR) |
Dependencies
mcp >= 1.0.0libcst >= 1.0.0jedi >= 0.19.0GitPython >= 3.1.0
License
MIT — see LICENSE.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/aferreiraguido/python-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server