mirror of
https://github.com/Dasemu/nextcloud-mcp.git
synced 2026-11-26 07:16:09 +00:00
chore: bootstrap Claude setup
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
33bae54e91
commit
53fc8b2865
12 files changed
+237
No files matched your search
@@ -0,0 +1 @@
|
||||
2
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"hooks": {
|
||||
"PostToolUse": [
|
||||
{
|
||||
"matcher": "Edit|Write",
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "f=$(cat | python3 -c 'import json,sys; print(json.load(sys.stdin).get(\"tool_input\",{}).get(\"file_path\",\"\"))'); case \"$f\" in *.py) python3 -m py_compile \"$f\" ;; esac"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"Stop": [
|
||||
{
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "python3 -m py_compile server.py"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
# Nextcloud connection (required)
|
||||
NEXTCLOUD_HOST=
|
||||
NEXTCLOUD_USERNAME=
|
||||
NEXTCLOUD_PASSWORD=
|
||||
|
||||
# Server bind address (optional, defaults shown)
|
||||
BIND_HOST=127.0.0.1
|
||||
BIND_PORT=8082
|
||||
@@ -0,0 +1,25 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [development]
|
||||
push:
|
||||
branches: [development, main]
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
cache: "pip"
|
||||
|
||||
- name: Install dependencies
|
||||
run: pip install -r requirements.txt
|
||||
|
||||
# No linter or test suite configured yet; this is a compile-time sanity check.
|
||||
- name: Compile check
|
||||
run: python -m py_compile server.py
|
||||
@@ -0,0 +1,68 @@
|
||||
name: Version
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [development, main]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
bump:
|
||||
if: ${{ github.actor != 'github-actions[bot]' && !contains(github.event.head_commit.message, '[skip ci]') }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Configure git
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
- name: Bump version
|
||||
id: bump
|
||||
run: |
|
||||
set -euo pipefail
|
||||
current=$(cat VERSION)
|
||||
IFS='.' read -r major minor patch <<< "$current"
|
||||
|
||||
if [ "${{ github.ref_name }}" = "development" ]; then
|
||||
patch=$((patch + 1))
|
||||
else
|
||||
# main: a MINOR bump only when every commit in this push came from
|
||||
# development (i.e. an approved development -> main PR merge);
|
||||
# anything else pushed straight to main is treated as a hotfix.
|
||||
parents=$(git log -1 --pretty=%P HEAD | wc -w)
|
||||
if [ "${{ github.event_name }}" = "push" ] && [ "$parents" -gt 1 ] && \
|
||||
git log -1 --pretty=%s HEAD | grep -qiE "merge pull request|from .*/development"; then
|
||||
minor=$((minor + 1))
|
||||
patch=0
|
||||
else
|
||||
patch=$((patch + 1))
|
||||
fi
|
||||
fi
|
||||
|
||||
new_version="$major.$minor.$patch"
|
||||
echo "$new_version" > VERSION
|
||||
echo "version=$new_version" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Commit and tag
|
||||
run: |
|
||||
git add VERSION
|
||||
git commit -m "chore(release): v${{ steps.bump.outputs.version }} [skip ci]"
|
||||
git push origin HEAD:${{ github.ref_name }}
|
||||
|
||||
- name: Merge main back into development
|
||||
if: ${{ github.ref_name == 'main' }}
|
||||
run: |
|
||||
if git ls-remote --exit-code --heads origin development > /dev/null; then
|
||||
git fetch origin development
|
||||
git checkout development
|
||||
git merge --no-edit origin/main
|
||||
git push origin development
|
||||
else
|
||||
echo "No development branch yet; skipping merge-back."
|
||||
fi
|
||||
@@ -0,0 +1,5 @@
|
||||
__pycache__/
|
||||
*.pyc
|
||||
.env
|
||||
.venv/
|
||||
venv/
|
||||
@@ -0,0 +1,41 @@
|
||||
# CLAUDE.md
|
||||
|
||||
## Overview
|
||||
MCP server exposing a Nextcloud instance (files, calendars, address books,
|
||||
Talk) as tools for an MCP-compatible AI agent. Single file: `server.py`.
|
||||
|
||||
## Commands
|
||||
- Install: `pip install -r requirements.txt`
|
||||
- Run: `python server.py` (reads `NEXTCLOUD_HOST`, `NEXTCLOUD_USERNAME`,
|
||||
`NEXTCLOUD_PASSWORD` from the environment; see `.env.example`)
|
||||
- Test: none yet.
|
||||
- Lint: none yet.
|
||||
- Build: none (no packaging step; Nixpacks runs `python server.py` directly,
|
||||
see `nixpacks.toml`).
|
||||
- Sanity check: `python -m py_compile server.py`
|
||||
|
||||
## Architecture
|
||||
See [`docs/architecture.md`](docs/architecture.md).
|
||||
|
||||
## Conventions
|
||||
- One `@mcp.tool()` function per Nextcloud operation; docstring = tool
|
||||
description shown to the agent.
|
||||
- Parsing/formatting helpers are private (`_`-prefixed) and live near the
|
||||
tools that use them.
|
||||
|
||||
## Workflow quirks
|
||||
- No `development` branch yet; branch from `main`, PR into `main` directly
|
||||
until `development` is created.
|
||||
- No automated tests or linter are configured yet (no pytest/ruff/flake8 in
|
||||
`requirements.txt`). CI only runs `python -m py_compile server.py` as a
|
||||
sanity check.
|
||||
|
||||
## Deployment
|
||||
See [`docs/deployment.md`](docs/deployment.md). Currently deployed via
|
||||
Nixpacks, not the org's standard LXC/VPS + systemd setup.
|
||||
|
||||
## Gotchas
|
||||
- `NEXTCLOUD_HOST`, `NEXTCLOUD_USERNAME`, `NEXTCLOUD_PASSWORD` are required
|
||||
env vars; the process raises `KeyError` on import if any is missing.
|
||||
- Recurring calendar events are expanded server-side (`c:expand`) in
|
||||
`list_events`, so each occurrence is a separate item, unlike `get_event`.
|
||||
@@ -0,0 +1,3 @@
|
||||
# Lessons
|
||||
|
||||
Recurring mistakes and how to avoid them. Add an entry whenever one repeats.
|
||||
@@ -0,0 +1,15 @@
|
||||
# ZenvairoCloud-MCP
|
||||
|
||||
MCP server that exposes a Nextcloud instance (files, calendars, address books,
|
||||
and Talk) as tools for an MCP-compatible AI agent.
|
||||
|
||||
## Quick start
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
cp .env.example .env # fill in NEXTCLOUD_HOST, NEXTCLOUD_USERNAME, NEXTCLOUD_PASSWORD
|
||||
python server.py
|
||||
```
|
||||
|
||||
See [`docs/architecture.md`](docs/architecture.md) for how it works and
|
||||
[`docs/deployment.md`](docs/deployment.md) for running it in production.
|
||||
@@ -0,0 +1,29 @@
|
||||
# Architecture
|
||||
|
||||
`server.py` is a single-file MCP server (streamable-http transport, via the
|
||||
`mcp` package's `MCPServer`) that proxies calls to a Nextcloud instance.
|
||||
|
||||
## Layers
|
||||
|
||||
- **Files**: WebDAV (`PROPFIND`, `GET`, `PUT`, `DELETE`, `MKCOL`, `MOVE`) under
|
||||
`/remote.php/dav/files/{user}/`, plus the unified search OCS endpoint and
|
||||
the file-sharing OCS API.
|
||||
- **Calendars**: CalDAV under `/remote.php/dav/calendars/{user}/`. Events and
|
||||
tasks (VTODO) are built/parsed with `vobject`. `list_events` uses a
|
||||
server-side `calendar-query` with `c:expand` so recurring events come back
|
||||
as individual occurrences.
|
||||
- **Address books**: CardDAV under `/remote.php/dav/addressbooks/users/{user}/`,
|
||||
contacts as vCards via `vobject`.
|
||||
- **Talk**: Nextcloud Talk's OCS Spreed API (`/ocs/v2.php/apps/spreed/api/`)
|
||||
for listing conversations and reading/sending chat messages.
|
||||
|
||||
All Nextcloud calls use HTTP Basic auth (`NEXTCLOUD_USERNAME` /
|
||||
`NEXTCLOUD_PASSWORD`) through a short-lived `httpx.Client` per request
|
||||
(`_client()`).
|
||||
|
||||
## Adding a tool
|
||||
|
||||
Add a function decorated with `@mcp.tool()`; its docstring becomes the tool
|
||||
description shown to the agent. Keep request/response shaping (XML/vCard/
|
||||
iCalendar parsing) in a private helper near the existing `_parse_*` /
|
||||
`_summarize_*` functions so tools stay thin.
|
||||
@@ -0,0 +1,16 @@
|
||||
# Deployment
|
||||
|
||||
The repo currently ships a `nixpacks.toml` (`python server.py`), i.e. it is
|
||||
built/run through Nixpacks rather than this org's standard LXC/VPS + systemd
|
||||
setup.
|
||||
|
||||
This does not yet follow the `web-deploy` standard. Missing pieces, if the
|
||||
deployment target is ever moved to an LXC/VPS:
|
||||
|
||||
- A systemd unit file to run `server.py` as a service.
|
||||
- An idempotent `scripts/update.sh` (pull, install deps, restart).
|
||||
- An authenticated HTTP endpoint that triggers the update script (token auth,
|
||||
single-flight, status, rate limiting).
|
||||
|
||||
Until then, deploy via whatever platform consumes `nixpacks.toml` and set the
|
||||
environment variables listed in `.env.example`.
|
||||
Reference in new issue
Block a user