UNPKG

nextcloud-mcp-server

Version:

Professional NextCloud MCP server for file operations and sharing

587 lines (440 loc) โ€ข 14.3 kB
<div align="center"> # ๐ŸŒ NextCloud MCP Server [![npm version](https://badge.fury.io/js/nextcloud-mcp-server.svg)](https://badge.fury.io/js/nextcloud-mcp-server) [![Downloads](https://img.shields.io/npm/dm/nextcloud-mcp-server.svg)](https://www.npmjs.com/package/nextcloud-mcp-server) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?logo=typescript&logoColor=white)](https://www.typescriptlang.org/) **A professional Model Context Protocol (MCP) server for seamless NextCloud integration** *Empower your AI agents with comprehensive NextCloud file management and sharing capabilities* [Installation](#-installation) โ€ข [Quick Start](#-quick-start) โ€ข [Features](#-features) โ€ข [Documentation](#-documentation) โ€ข [Security](#-security) </div> --- ## ๐Ÿš€ Features <div align="center"> | ๐Ÿ“ **File Management** | ๐Ÿ”— **Sharing** | ๐Ÿ”’ **Security** | ๐Ÿ› ๏ธ **Developer Experience** | |-------------------------|-----------------|------------------|------------------------------| | List, upload, download | Public links | App passwords | Full TypeScript support | | Create directories | User/group shares | Environment variables | Comprehensive tests | | Delete files/folders | Password protection | Secure authentication | Professional documentation | | Move and rename | Expiration dates | HTTPS enforcement | Easy integration | </div> ### โœจ Key Capabilities - ๐ŸŽฏ **14 Comprehensive Tools** - Complete file operations and sharing management - ๐Ÿ” **Enhanced Security** - Built-in app password support and best practices - ๐Ÿ—๏ธ **Professional Architecture** - TypeScript-first with full type safety - ๐Ÿ“š **Rich Documentation** - Detailed guides and examples - ๐Ÿ”„ **WebDAV Integration** - Native NextCloud protocol support - โšก **High Performance** - Optimized for speed and reliability - ๐ŸŒ **Universal Compatibility** - Works with any NextCloud instance --- ## ๐Ÿ“ฆ Installation ### From NPM (Recommended) ```bash # Install globally for CLI usage npm install -g nextcloud-mcp-server # Or install locally in your project npm install nextcloud-mcp-server ``` ### From Source ```bash git clone https://github.com/abdullahMASHUK/nextcloud-mcp-server.git cd nextcloud-mcp-server npm install npm run build ``` --- ## ๐Ÿš€ Quick Start ### 1. ๐Ÿ” Setup App Password (Recommended) <details> <summary>Click to expand security setup instructions</summary> For enhanced security, create a dedicated app password: 1. **Navigate to NextCloud Settings** ``` NextCloud โ†’ Settings โ†’ Security โ†’ App passwords ``` 2. **Create New App Password** - Enter name: `MCP Server` - Click "Create new app password" - Copy the generated password: `xxxxx-xxxxx-xxxxx-xxxxx-xxxxx` 3. **Why App Passwords?** - โœ… Limited scope and permissions - โœ… Can be revoked independently - โœ… No access to your main account - โœ… Auditable access logs </details> ### 2. โš™๏ธ Configuration ```bash # Copy the environment template cp .env.example .env ``` Edit your `.env` file: ```bash NEXTCLOUD_URL=https://your-nextcloud-server.com NEXTCLOUD_USERNAME=your-username NEXTCLOUD_PASSWORD=your-app-password-here # Use app password! ``` ### 3. ๐ŸŽฎ Usage with MCP Clients <details> <summary>Claude Desktop Configuration</summary> Add to your `claude_desktop_config.json`: ```json { "mcpServers": { "nextcloud": { "command": "nextcloud-mcp-server", "env": { "NEXTCLOUD_URL": "https://your-nextcloud-server.com", "NEXTCLOUD_USERNAME": "your-username", "NEXTCLOUD_PASSWORD": "your-app-password" } } } } ``` </details> <details> <summary>Direct Usage</summary> ```bash # Run the MCP server nextcloud-mcp-server # Or with Node.js node build/index.js ``` </details> --- ## ๐Ÿ› ๏ธ Available Tools ### ๐Ÿ“ File Operations <table> <tr> <td><strong>๐Ÿ” test-connection</strong></td> <td>Test connectivity to your NextCloud server</td> </tr> <tr> <td><strong>๐Ÿ“‹ list-files</strong></td> <td>List files and directories with metadata</td> </tr> <tr> <td><strong>๐Ÿ“ create-directory</strong></td> <td>Create new directories in NextCloud</td> </tr> <tr> <td><strong>๐Ÿ—‘๏ธ delete-file</strong></td> <td>Delete files or directories</td> </tr> <tr> <td><strong>โฌ†๏ธ upload-file</strong></td> <td>Upload files with base64 encoding</td> </tr> <tr> <td><strong>โฌ‡๏ธ download-file</strong></td> <td>Download files from NextCloud</td> </tr> <tr> <td><strong>๐Ÿ”„ move-file</strong></td> <td>Move or rename files and directories</td> </tr> <tr> <td><strong>๐Ÿ“„ copy-file</strong></td> <td>Copy files and directories to new locations</td> </tr> <tr> <td><strong>๐Ÿ” search-files</strong></td> <td>Search for files and directories by name or content</td> </tr> <tr> <td><strong>๐Ÿ“š get-file-versions</strong></td> <td>Get version history of a file</td> </tr> <tr> <td><strong>๐Ÿ”„ restore-file-version</strong></td> <td>Restore a specific version of a file</td> </tr> </table> ### ๐Ÿ”— Sharing Operations <table> <tr> <td><strong>๐ŸŒ create-share</strong></td> <td>Create public links, user, or group shares</td> </tr> <tr> <td><strong>๐Ÿ“ค list-shares</strong></td> <td>List and filter existing shares</td> </tr> <tr> <td><strong>๐Ÿ—‘๏ธ delete-share</strong></td> <td>Remove shares by ID</td> </tr> </table> --- ## ๐Ÿ“– Documentation ### ๐ŸŽฏ Tool Examples <details> <summary><strong>๐Ÿ“‹ List Files</strong></summary> ```json { "name": "list-files", "arguments": { "path": "/Documents" } } ``` **Response:** Returns array of files with metadata (name, size, type, modification date) </details> <details> <summary><strong>โฌ†๏ธ Upload File</strong></summary> ```json { "name": "upload-file", "arguments": { "remotePath": "/documents/report.pdf", "content": "JVBERi0xLjQK..." // base64 encoded content } } ``` </details> <details> <summary><strong>๐Ÿ”„ Move File</strong></summary> ```json { "name": "move-file", "arguments": { "sourcePath": "/old-location/document.pdf", "destinationPath": "/new-location/document.pdf", "overwrite": false } } ``` **Response:** Confirmation message with source and destination paths </details> <details> <summary><strong>๐Ÿ“„ Copy File</strong></summary> ```json { "name": "copy-file", "arguments": { "sourcePath": "/Documents/template.docx", "destinationPath": "/Projects/new-document.docx", "overwrite": true } } ``` **Response:** Confirmation message with copy operation details </details> <details> <summary><strong>๐Ÿ” Search Files</strong></summary> ```json { "name": "search-files", "arguments": { "query": "quarterly report", "path": "/Documents", "limit": 20, "type": "file" } } ``` **Response:** Array of matching files with full metadata **Type Options:** `file`, `directory`, `all` </details> <details> <summary><strong>๐Ÿ“š Get File Versions</strong></summary> ```json { "name": "get-file-versions", "arguments": { "path": "/Documents/important-document.pdf" } } ``` **Response:** Array of file versions with timestamps, sizes, and user information </details> <details> <summary><strong>๐Ÿ”„ Restore File Version</strong></summary> ```json { "name": "restore-file-version", "arguments": { "path": "/Documents/important-document.pdf", "versionId": "1672531200" } } ``` **Response:** Confirmation of version restoration </details> <details> <summary><strong>๐ŸŒ Create Share</strong></summary> ```json { "name": "create-share", "arguments": { "path": "/Documents/presentation.pptx", "shareType": 3, "password": "secure123", "expireDate": "2024-12-31", "note": "Shared for team review" } } ``` **Share Types:** - `0` - User share - `1` - Group share - `3` - Public link - `4` - Email share </details> ### ๐Ÿ—๏ธ Development <details> <summary>Setup Development Environment</summary> ```bash # Clone and install git clone https://github.com/abdullahMASHUK/nextcloud-mcp-server.git cd nextcloud-mcp-server npm install # Development commands npm run dev # Run with auto-reload npm run build # Build TypeScript npm run test # Run test suite npm run lint # Check code quality npm run format # Format code ``` **Project Structure:** ``` src/ โ”œโ”€โ”€ index.ts # Main MCP server โ”œโ”€โ”€ services/ โ”‚ โ””โ”€โ”€ nextcloud.ts # NextCloud API client โ”œโ”€โ”€ types.ts # TypeScript definitions โ””โ”€โ”€ utils/ # Utility functions __tests__/ # Test suites build/ # Compiled output ``` </details> --- ## ๐Ÿ”’ Security ### ๐Ÿ›ก๏ธ Best Practices <div align="center"> | โœ… **Do** | โŒ **Don't** | |-----------|--------------| | Use app passwords | Use main account password | | Store in environment variables | Hardcode credentials | | Use HTTPS URLs | Use HTTP connections | | Rotate passwords regularly | Keep old passwords | | Monitor access logs | Ignore security events | </div> ### ๐Ÿ” Security Features - **๐Ÿ”‘ App Password Integration** - Dedicated authentication tokens - **๐ŸŒ HTTPS Enforcement** - Secure connections required - **๐Ÿ“ Environment Variables** - Safe credential storage - **๐Ÿ” Error Handling** - No credential exposure in logs - **๐Ÿ›ก๏ธ Permission Scoping** - Limited access rights ### โš ๏ธ Security Checklist - [ ] App password created and configured - [ ] HTTPS enabled on NextCloud server - [ ] Environment variables properly set - [ ] `.env` file added to `.gitignore` - [ ] Regular password rotation scheduled --- ## License MIT License - see LICENSE file for details. ## ๐Ÿค Contributing <div align="center"> ### We Welcome Contributions! [![Contributors Welcome](https://img.shields.io/badge/contributors-welcome-brightgreen.svg)](https://github.com/abdullahMASHUK/nextcloud-mcp-server/blob/main/CONTRIBUTING.md) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/abdullahMASHUK/nextcloud-mcp-server/pulls) </div> <details> <summary>๐Ÿš€ <strong>How to Contribute</strong></summary> 1. **๐Ÿด Fork the repository** 2. **๐ŸŒฟ Create your feature branch** ```bash git checkout -b feature/amazing-feature ``` 3. **๐Ÿ’ป Make your changes** 4. **โœ… Add tests for new features** 5. **๐Ÿงช Run the test suite** ```bash npm run test npm run lint ``` 6. **๐Ÿ“ Commit your changes** ```bash git commit -m "โœจ Add amazing feature" ``` 7. **๐Ÿš€ Push to your branch** ```bash git push origin feature/amazing-feature ``` 8. **๐Ÿ”„ Open a Pull Request** </details> ### ๐Ÿ’ก Ways to Contribute <table> <tr> <td align="center">๐Ÿ›<br><strong>Bug Reports</strong></td> <td align="center">โœจ<br><strong>Feature Requests</strong></td> <td align="center">๐Ÿ“š<br><strong>Documentation</strong></td> <td align="center">๐Ÿงช<br><strong>Testing</strong></td> </tr> <tr> <td align="center">Found an issue?<br>Report it!</td> <td align="center">Have an idea?<br>Share it!</td> <td align="center">Improve docs<br>and examples</td> <td align="center">Add tests and<br>improve coverage</td> </tr> </table> --- ## ๐Ÿ’– Support <div align="center"> ### Show Your Support! โญ If this project helped you, please consider giving it a โญ on GitHub! [![GitHub stars](https://img.shields.io/github/stars/abdullahMASHUK/nextcloud-mcp-server?style=social)](https://github.com/abdullahMASHUK/nextcloud-mcp-server/stargazers) [![GitHub forks](https://img.shields.io/github/forks/abdullahMASHUK/nextcloud-mcp-server?style=social)](https://github.com/abdullahMASHUK/nextcloud-mcp-server/network/members) ### ๐Ÿ—ฃ๏ธ Get Help - ๐Ÿ“– [Documentation](https://github.com/abdullahMASHUK/nextcloud-mcp-server#readme) - ๐Ÿ› [Report Issues](https://github.com/abdullahMASHUK/nextcloud-mcp-server/issues) - ๐Ÿ’ฌ [Discussions](https://github.com/abdullahMASHUK/nextcloud-mcp-server/discussions) - ๐Ÿ“ง [Contact Maintainer](https://github.com/abdullahMASHUK) ### ๐Ÿ”— Connect With Us [![GitHub](https://img.shields.io/badge/GitHub-abdullahMASHUK-181717?style=flat&logo=github)](https://github.com/abdullahMASHUK) [![npm](https://img.shields.io/badge/npm-nextcloud--mcp--server-CB3837?style=flat&logo=npm)](https://www.npmjs.com/package/nextcloud-mcp-server) </div> --- ## ๐Ÿ“œ License <div align="center"> **MIT License** ยฉ 2024 [Abdullah MASHUK](https://github.com/abdullahMASHUK) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) *Permission is hereby granted, free of charge, to any person obtaining a copy of this software...* [๐Ÿ“– Read Full License](./LICENSE) </div> --- ## ๐Ÿ“ˆ Changelog <details> <summary><strong>Version History</strong></summary> ### ๐ŸŽ‰ v1.0.3 - ๐ŸŽจ Beautified README with professional formatting and visual enhancements - ๐Ÿ“Š Added interactive tables, badges, and collapsible sections - ๐Ÿ‘ค Updated author information and git configuration - ๐Ÿ”— Enhanced navigation with emojis and better organization - โœจ Improved user experience for npm and GitHub viewers ### ๐Ÿš€ v1.0.2 - โœจ Enhanced documentation and README - ๐Ÿ”’ Added comprehensive security guidelines - ๐Ÿ“ Improved TypeScript definitions - ๐Ÿ› Bug fixes and stability improvements ### ๐Ÿš€ v1.0.1 - ๐Ÿ“š Updated documentation - ๐Ÿ”ง Configuration improvements - ๐Ÿ› ๏ธ Build process optimization ### ๐ŸŒŸ v1.0.0 - ๐ŸŽŠ Initial release - ๐Ÿ“ Basic file operations (list, upload, download, delete) - ๐Ÿ”— Share management (create, list, delete) - ๐Ÿ”ง TypeScript implementation - โœ… Comprehensive test coverage - ๐Ÿ“– Full documentation </details> --- <div align="center"> **Made with โค๏ธ by [Abdullah MASHUK](https://github.com/abdullahMASHUK)** *Building bridges between NextCloud and AI assistants* ๐ŸŒ‰ [![Built with TypeScript](https://img.shields.io/badge/Built%20with-TypeScript-3178C6?style=flat&logo=typescript)](https://www.typescriptlang.org/) [![Powered by MCP](https://img.shields.io/badge/Powered%20by-MCP-FF6B6B?style=flat)](https://modelcontextprotocol.io/) </div>