Nextcloud MCP Server
README.md
# Nextcloud MCP Server
A Model Context Protocol (MCP) server that provides Nextcloud file access to Claude Desktop via WebDAV.
> **Disclaimer**: This project was created with assistance from Claude AI (Anthropic). While functional, use at your own discretion and review the code before deployment.
## Features
- Full WebDAV access to Nextcloud files
- Integrates natively with Claude Desktop
- Supports file listing, upload, download, and deletion
- Smart directory detection for uploads
- No external dependencies beyond Python and `webdav4`
## Available Tools
Once configured, Claude Desktop will have access to these tools:
- `nextcloud_list` - List files and directories
- `nextcloud_download` - Download files from Nextcloud
- `nextcloud_upload` - Upload files to Nextcloud (with smart directory handling)
- `nextcloud_cat` - Display text file contents
- `nextcloud_mkdir` - Create directories
- `nextcloud_delete` - Delete files or directories
## Prerequisites
- Python 3.8 or higher
- Claude Desktop installed
- A Nextcloud instance with WebDAV access enabled
- [uv](https://github.com/astral-sh/uv) (recommended) or pip for Python package management
## Installation
### 1. Clone or Download
```bash
# Clone this repository or download the files to a local directory
git clone https://github.com/runter-vom-mattenwagen/nextcloud-mcp-server.git
cd nextcloud-mcp-server
```
### 2. Configure Credentials
Edit `nextcloud_client.py` and update the following variables at the top of the file:
```python
WEBDAV_URL = "https://your-nextcloud-instance.com/remote.php/dav/files/username/"
USERNAME = "your-username"
PASSWORD = "your-password"
```
**Important**: The `WEBDAV_URL` should end with your username followed by a trailing slash.
Example: `https://cloud.example.com/remote.php/dav/files/john/`
### 3. Configure Claude Desktop
Add the MCP server to your Claude Desktop configuration file.
**Configuration file location by OS:**
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
- **Linux**: `~/.config/Claude/claude_desktop_config.json`
**Configuration**:
#### Option A: Using uv (Recommended)
```json
{
"mcpServers": {
"nextcloud": {
"command": "uv",
"args": [
"run",
"--with",
"webdav4",
"/absolute/path/to/nextcloud_mcp_server.py"
]
}
}
}
```
#### Option B: Using system Python
```json
{
"mcpServers": {
"nextcloud": {
"command": "python3",
"args": [
"/absolute/path/to/nextcloud_mcp_server.py"
]
}
}
}
```
**Note**: If using system Python, you must install dependencies first:
```bash
pip3 install webdav4
```
### 4. Restart Claude Desktop
After configuration, restart Claude Desktop for the changes to take effect.
## Usage Examples
Once configured, you can interact with your Nextcloud instance through Claude:
```
User: "List the files in my Nextcloud"
Claude: [uses nextcloud_list tool]
User: "Upload this document to my Nextcloud Documents folder"
Claude: [uses nextcloud_upload with remote_path="Documents/"]
User: "Show me the contents of notes.txt"
Claude: [uses nextcloud_cat]
```
## Standalone Usage
The `nextcloud_client.py` script can also be used standalone from the command line:
```bash
# List files
python3 nextcloud_client.py list /
# Upload a file
python3 nextcloud_client.py upload local_file.txt remote_folder/
# Download a file
python3 nextcloud_client.py download remote_file.txt
# Create directory
python3 nextcloud_client.py mkdir new_folder
# Delete file
python3 nextcloud_client.py delete old_file.txt
# Show file contents
python3 nextcloud_client.py cat notes.txt
```
## Troubleshooting
### Connection Issues
1. Verify your WebDAV URL is correct (should include `/remote.php/dav/files/username/`)
2. Check username and password are correct
3. Ensure WebDAV is enabled in your Nextcloud instance
4. Test connection manually:
```bash
curl -u "username:password" "https://your-nextcloud-instance.com/remote.php/dav/files/username/"
```
### MCP Server Not Starting
1. Check the Claude Desktop logs for errors
2. Verify Python path in configuration is correct
3. Ensure `webdav4` is installed (if using system Python)
4. Test the MCP server directly:
```bash
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}' | python3 nextcloud_mcp_server.py
```
### Permission Denied
Ensure the scripts are executable:
```bash
chmod +x nextcloud_client.py nextcloud_mcp_server.py
```
## Security Considerations
- **Credentials in Code**: This implementation stores credentials directly in the Python file. For production use, consider using environment variables or a separate config file.
- **HTTPS Only**: Always use HTTPS URLs to protect credentials in transit.
- **File Permissions**: Ensure the Python files are not world-readable if they contain credentials.
## Architecture
- `nextcloud_client.py` - WebDAV client handling all Nextcloud operations
- `nextcloud_mcp_server.py` - MCP protocol server that wraps the client for Claude Desktop
The MCP server communicates with Claude Desktop via JSON-RPC over stdin/stdout, executing the WebDAV client as needed.
## Dependencies
- Python 3.8+
- [webdav4](https://github.com/skshetry/webdav4) - WebDAV client library
## License
MIT License - See LICENSE file for details.
## Contributing
Contributions are welcome! Please feel free to submit issues or pull requests.
## Acknowledgments
- Created with assistance from Claude AI (Anthropic)
- Uses the [webdav4](https://github.com/skshetry/webdav4) library for WebDAV operations
- Built for the [Model Context Protocol](https://modelcontextprotocol.io/)
This server cannot be deployed
Maintenance
ActivityInactive
ResponsivenessNo recent community issues