PythonAnywhere Model Context Protocol Server
A Model Context Protocol (MCP)server acts as a bridge between AI-powered tools and yourPythonAnywhere account, enabling secure,programmatic management of files, websites, webapps, and scheduled tasks. Byexposing a standardized interface, it allows language models and automationclients to perform operations—such as editing files, deploying web apps, orscheduling jobs -- on your behalf, all while maintaining fine-grained controland auditability.
Features
- File management: Read, upload, delete files and list directory trees.(also enables debugging with direct access to log files, which are justfiles on PythonAnywhere)
- ASGI Web app management: Create, delete, reload, and list.(as described in the PythonAnywhere ASGIdocumentation)
- WSGI Web app management: Reload only (at the moment).
- Scheduled task management: List, create, update, and delete.(Note that this enables LLMs to execute arbitrary commands if a task isscheduled too soon after creation and deleted after execution. For that wewould suggest running it with mcp-server-timeas models easily get confused about time.)
Installation
The MCP protocol is well-defined and supported by various clients, butinstallation is different depending on the client you are using. We willcover cases that we tried and tested.
In all cases, you need to have uv
installed and available in your PATH
.
Have your PythonAnywhere API token and username ready. You can find (orgenerate) your API token in the API section of your PythonAnywhereaccount.
Desktop Extension - works with Claude Desktop
Probably the most straightforward way to install the MCP server is to usethe desktop extension for Claude Desktop.
- Open Claude Desktop.
- Download the latest .dxt file.
- Double-click on the downloaded .dxt file or drag the file into the window.
- Configure your PythonAnywhere API token and username.
- Restart Claude Desktop.
Claude Code
Run:
claude mcp add pythonanywhere-mcp-server \
-e API_TOKEN=yourpythonanywhereapitoken \
-e LOGNAME=yourpythonanywhereusername \
-- uvx pythonanywhere-mcp-server
GitHub Copilot in PyCharm:
Add it to your mcp.json
.
{
"servers": {
"pythonanywhere-mcp-server": {
"type": "stdio",
"command": "uvx",
"args": ["pythonanywhere-mcp-server"],
"env": {
"API_TOKEN": "yourpythonanywhereapitoken",
"LOGNAME": "yourpythonanywhereusername"
}
}
}
}
Claude Desktop (manual setup) and Cursor:
Add it to claude_desktop_config.json
(for Claude Desktop) or (mcp.json
for Cursor).
{
"mcpServers": {
"pythonanywhere-mcp-server": {
"type": "stdio",
"command": "uvx",
"args": ["pythonanywhere-mcp-server"],
"env": {
"API_TOKEN": "yourpythonanywhereapitoken",
"LOGNAME": "yourpythonanywhereusername"
}
}
}
}
Caveats
Direct integration of an LLM with your PythonAnywhere account offerssignificant capabilities, but also introduces risks. We strongly advisemaintaining human oversight, especially for sensitive actions such asmodifying or deleting files.
If you are running multiple MCP servers simultaneously, becautious -- particularly if any server can access external resources you do notcontrol, such as GitHub issues. These can become attack vectors. For moredetails, see this story.
Implementation
The server uses the python mcp sdkin connection with the pythonanywhere-corepackage (docs), which wraps a subset of the PythonAnywhereAPI and may be expanded inthe future as needed.