Nextcloud MCP
This project provides a Model-Context-Protocol (MCP) for saving files to a Nextcloud instance and immediately receiving a publicly available share URL.
Features
- Save & Share: Upload files to a designated Nextcloud folder and automatically generate a public, read-only share link.
- File and Folder Management: Create and delete files and folders.
- Configurable: All Nextcloud connection details are configurable via environment variables.
- Robust: Built with modern Python libraries (
httpx,pydantic) and includes error handling. - Asynchronous: Uses
asynciofor non-blocking I/O operations.
Quickstart
1. Prerequisites
- Python 3.8+
- A Nextcloud account with WebDAV access enabled.
2. Installation
Clone the repository and install the required dependencies:
git clone https://github.com/your-username/nextcloud-mcp.git
cd nextcloud-mcp
pip install -e .
3. Configuration
This project uses environment variables for configuration. Create a .env file in the project root and add the following variables:
NEXTCLOUD_INSTANCE_URL="https://your-nextcloud-instance.com"
NEXTCLOUD_USERNAME="your_username"
NEXTCLOUD_PASSWORD="your_password"
# Optional: Specify a folder to save files in.
# If not set, files will be saved in the root directory.
NEXTCLOUD_USAGE_FOLDER="MyUploads"
You can get a secure app password from your Nextcloud account settings under Security > Devices & sessions.
4. Usage
The save_and_share.py script provides a simple example of how to use the library.
python nextcloud_mcp/save_and_share.py
The script will:
- Load the configuration from your
.envfile. - Create a new text file with a timestamp.
- Upload the file to your Nextcloud instance.
- Print the public share URL to the console.
How It Works
The core logic is in the Ctx class (nextcloud_mcp/context.py), which handles the two main steps:
- File Upload: Uses the WebDAV protocol (
PUTrequest) to upload the file to the specified path. - Share Link Creation: Uses the Nextcloud OCS (Open Collaboration Services) API to create a public share link for the uploaded file.
Project Structure
.
├── nextcloud_mcp/
│ ├── __init__.py
│ ├── config.py # Configuration loading and validation
│ ├── context.py # Core Ctx class for Nextcloud interaction
│ ├── exceptions.py # Custom exception classes
│ └── save_and_share.py # Example usage script
├── tests/ # Unit tests
├── .env.example # Example environment file
├── pyproject.toml # Project metadata and dependencies
└── README.md
Metadata
Release files for nextcloud-mcp 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nextcloud_mcp-0.1.0.tar.gz | 6.2 kB | Without provenance | Details for nextcloud_mcp-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nextcloud_mcp-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for nextcloud_mcp-0.1.0-py3-none-any.whl |
Total release size: 11.6 kB
Release files / nextcloud_mcp-0.1.0.tar.gz
| Download URL | nextcloud_mcp-0.1.0.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
47337f50a311213e150b641a5b3c38dcdb042c37c467d21723f277031fa34f11
|
|
BLAKE2b-256 checksum How to use checksums |
d9f47c648fe6125764a9acc4d2ec33d41fa9ea06d0246c45faab71bb422fc787
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.7
|
Release files / nextcloud_mcp-0.1.0-py3-none-any.whl
| Download URL | nextcloud_mcp-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ae575d795fd46060206f365a3b0519b17b4404a12f0b0bcfd14fa4c30824cbc5
|
|
BLAKE2b-256 checksum How to use checksums |
cc2ad1b19f87910e016245267bd2b6ca8214ad1fa4e945d1f08d53ccdcac7555
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.7
|
Security for nextcloud-mcp 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.