9e96999f02
- Add nc_webdav_list_directory tool for browsing any NextCloud directory - Add nc_webdav_read_file tool with automatic text/binary content handling - Add nc_webdav_write_file tool supporting text and base64 binary content - Add nc_webdav_create_directory tool for creating directories - Add nc_webdav_delete_resource tool for deleting files and directories - Extend WebDAV client beyond Notes attachments to general file operations - Add XML parsing for WebDAV PROPFIND responses with metadata extraction - Improve type annotations throughout codebase for better IDE support - Add comprehensive documentation with usage examples This transforms the NextCloud MCP server from a limited Notes/Tables tool into a full-featured file system interface, enabling complete NextCloud file management through LLM interactions.
187 lines
6.7 KiB
Markdown
187 lines
6.7 KiB
Markdown
# Nextcloud MCP Server
|
|
|
|
[](https://github.com/cbcoutinho/nextcloud-mcp-server/pkgs/container/nextcloud-mcp-server)
|
|
|
|
The Nextcloud MCP (Model Context Protocol) server allows Large Language Models (LLMs) like OpenAI's GPT, Google's Gemini, or Anthropic's Claude to interact with your Nextcloud instance. This enables automation of various Nextcloud actions, starting with the Notes API.
|
|
|
|
## Features
|
|
|
|
The server provides integration with multiple Nextcloud apps, enabling LLMs to interact with your Nextcloud data through a rich set of tools and resources.
|
|
|
|
## Supported Nextcloud Apps
|
|
|
|
| App | Support Status | Description |
|
|
|-----|----------------|-------------|
|
|
| **Notes** | ✅ Full Support | Create, read, update, delete, and search notes. Handle attachments via WebDAV. |
|
|
| **Tables** | ⚠️ Row Operations | Read table schemas and perform CRUD operations on table rows. Table management not yet supported. |
|
|
| **Files (WebDAV)** | ✅ Full Support | Complete file system access - browse directories, read/write files, create/delete resources. |
|
|
|
|
## Available Tools
|
|
|
|
### Notes Tools
|
|
|
|
| Tool | Description |
|
|
|------|-------------|
|
|
| `nc_get_note` | Get a specific note by ID |
|
|
| `nc_notes_create_note` | Create a new note with title, content, and category |
|
|
| `nc_notes_update_note` | Update an existing note by ID |
|
|
| `nc_notes_append_content` | Append content to an existing note with a clear separator |
|
|
| `nc_notes_delete_note` | Delete a note by ID |
|
|
| `nc_notes_search_notes` | Search notes by title or content |
|
|
|
|
### Tables Tools
|
|
|
|
| Tool | Description |
|
|
|------|-------------|
|
|
| `nc_tables_list_tables` | List all tables available to the user |
|
|
| `nc_tables_get_schema` | Get the schema/structure of a specific table including columns and views |
|
|
| `nc_tables_read_table` | Read rows from a table with optional pagination |
|
|
| `nc_tables_insert_row` | Insert a new row into a table |
|
|
| `nc_tables_update_row` | Update an existing row in a table |
|
|
| `nc_tables_delete_row` | Delete a row from a table |
|
|
|
|
### WebDAV File System Tools
|
|
|
|
| Tool | Description |
|
|
|------|-------------|
|
|
| `nc_webdav_list_directory` | List files and directories in any NextCloud path |
|
|
| `nc_webdav_read_file` | Read file content (text files decoded, binary as base64) |
|
|
| `nc_webdav_write_file` | Create or update files in NextCloud |
|
|
| `nc_webdav_create_directory` | Create new directories |
|
|
| `nc_webdav_delete_resource` | Delete files or directories |
|
|
|
|
## Available Resources
|
|
|
|
| Resource | Description |
|
|
|----------|-------------|
|
|
| `nc://capabilities` | Access Nextcloud server capabilities |
|
|
| `notes://settings` | Access Notes app settings |
|
|
| `nc://Notes/{note_id}/attachments/{attachment_filename}` | Access attachments for notes |
|
|
|
|
### WebDAV File System Access
|
|
|
|
The server provides complete file system access to your NextCloud instance, enabling you to:
|
|
|
|
- Browse any directory structure
|
|
- Read and write files of any type
|
|
- Create and delete directories
|
|
- Manage your NextCloud files directly through LLM interactions
|
|
|
|
**Usage Examples:**
|
|
|
|
```python
|
|
# List files in root directory
|
|
await nc_webdav_list_directory("")
|
|
|
|
# Browse a specific folder
|
|
await nc_webdav_list_directory("Documents/Projects")
|
|
|
|
# Read a text file
|
|
content = await nc_webdav_read_file("Documents/readme.txt")
|
|
|
|
# Create a new directory
|
|
await nc_webdav_create_directory("NewProject/docs")
|
|
|
|
# Write content to a file
|
|
await nc_webdav_write_file("NewProject/docs/notes.md", "# My Notes\n\nContent here...")
|
|
|
|
# Delete a file or directory
|
|
await nc_webdav_delete_resource("old_file.txt")
|
|
```
|
|
|
|
### Note Attachments
|
|
|
|
This server supports adding and retrieving note attachments via WebDAV. Please note the following behavior regarding attachments:
|
|
|
|
* When a note is deleted, its attachments remain in the system. This matches the behavior of the official Nextcloud Notes app.
|
|
* Orphaned attachments (attachments whose parent notes have been deleted) may accumulate over time.
|
|
* WebDAV permissions must be properly configured for attachment operations to work correctly.
|
|
|
|
## Installation
|
|
|
|
### Prerequisites
|
|
|
|
* Python 3.8+
|
|
* Access to a Nextcloud instance
|
|
|
|
### Local Installation
|
|
|
|
1. Clone the repository (if running from source):
|
|
```bash
|
|
git clone https://github.com/cbcoutinho/nextcloud-mcp-server.git
|
|
cd nextcloud-mcp-server
|
|
```
|
|
2. Install the package (if running as a library):
|
|
```bash
|
|
poetry install
|
|
```
|
|
|
|
### Docker
|
|
|
|
A pre-built Docker image is available: `ghcr.io/cbcoutinho/nextcloud-mcp-server`
|
|
|
|
## Configuration
|
|
|
|
The server requires credentials to connect to your Nextcloud instance. Create a file named `.env` (or any name you prefer) in the directory where you'll run the server, based on the `env.sample` file:
|
|
|
|
```dotenv
|
|
# .env
|
|
NEXTCLOUD_HOST=https://your.nextcloud.instance.com
|
|
NEXTCLOUD_USERNAME=your_nextcloud_username
|
|
NEXTCLOUD_PASSWORD=your_nextcloud_app_password_or_login_password
|
|
```
|
|
|
|
* `NEXTCLOUD_HOST`: The full URL of your Nextcloud instance.
|
|
* `NEXTCLOUD_USERNAME`: Your Nextcloud username.
|
|
* `NEXTCLOUD_PASSWORD`: **Important:** It is highly recommended to use a dedicated Nextcloud App Password for security. You can generate one in your Nextcloud Security settings. Alternatively, you can use your regular login password, but this is less secure.
|
|
|
|
## Running the Server
|
|
|
|
### Locally
|
|
|
|
Ensure your environment variables are loaded, then run the server using `mcp run`:
|
|
|
|
```bash
|
|
# Load environment variables from your .env file
|
|
export $(grep -v '^#' .env | xargs)
|
|
|
|
# Run the server
|
|
mcp run --transport sse nextcloud_mcp_server.server:mcp
|
|
```
|
|
|
|
The server will start, typically listening on `http://0.0.0.0:8000`.
|
|
|
|
### Using Docker
|
|
|
|
Mount your environment file when running the container:
|
|
|
|
```bash
|
|
docker run -p 127.0.0.1:8000:8000 --env-file .env --rm ghcr.io/cbcoutinho/nextcloud-mcp-server:latest
|
|
```
|
|
|
|
This will start the server and expose it on port 8000 of your local machine.
|
|
|
|
## Usage
|
|
|
|
Once the server is running, you can connect to it using an MCP client like `uvx`. Add the server to your `uvx` configuration:
|
|
|
|
```bash
|
|
uvx mcp add nextcloud-mcp http://localhost:8000 --default-transport sse
|
|
```
|
|
|
|
You can then interact with the server's tools and resources through your LLM interface connected to `uvx`.
|
|
|
|
## References:
|
|
|
|
- https://github.com/modelcontextprotocol/python-sdk
|
|
|
|
## Contributing
|
|
|
|
Contributions are welcome! Please feel free to submit issues or pull requests on the [GitHub repository](https://github.com/cbcoutinho/nextcloud-mcp-server).
|
|
|
|
## License
|
|
|
|
This project is licensed under the AGPL-3.0 License. See the [LICENSE](./LICENSE) file for details.
|
|
|
|
[](https://mseep.ai/app/cbcoutinho-nextcloud-mcp-server)
|