mcp-server-appwrite 2.6.7__tar.gz → 2.7.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/AGENTS.md +1 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/PKG-INFO +1 -1
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/docs/self-hosted.md +20 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/docs/tool-surface.md +8 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/assets/instructions.json +17 -1
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/constants.py +5 -0
- mcp_server_appwrite-2.7.1/src/mcp_server_appwrite/data/docs_index.npz +4 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/instructions.py +14 -5
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/operator.py +38 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/server.py +28 -8
- mcp_server_appwrite-2.7.1/src/mcp_server_appwrite/zero.py +269 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/unit/test_server.py +257 -0
- mcp_server_appwrite-2.6.7/src/mcp_server_appwrite/data/docs_index.npz +0 -4
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/.dockerignore +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/.env.example +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/.github/workflows/ci.yml +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/.github/workflows/production.yml +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/.github/workflows/publish.yml +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/.github/workflows/staging.yml +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/.github/workflows/update-docs-index.yml +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/.gitignore +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/.python-version +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/CLAUDE.md +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/Dockerfile +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/LICENSE +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/README.md +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/compose.yaml +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/docs/apps.md +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/docs/appwrite-mcp-flow.png +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/docs/appwrite-mcp-flow.svg +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/docs/authentication.md +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/docs/development.md +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/docs/documentation-search.md +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/docs/events.md +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/docs/flags.md +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/docs/images/claude-desktop-local-mcp-servers.png +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/docs/images/codex-mcp.png +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/docs/images/cursor-mcp.png +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/glama.json +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/pyproject.toml +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/scripts/build_docs_index.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/scripts/docs_release_notes.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/scripts/render_server_json.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/server.template.json +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/__init__.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/__main__.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/apps/__init__.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/apps/executions.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/apps/files.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/apps/protocol.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/apps/resource.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/apps/usage.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/apps/users.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/apps/views.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/assets/__init__.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/assets/favicon.svg +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/assets/view.html +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/auth.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/catalog_policy.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/context.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/docs.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/docs_index.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/docs_search.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/docs_server.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/docs_source.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/error_classification.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/error_monitoring.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/events/__init__.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/events/bus.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/events/catalog.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/events/delivery.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/events/egress.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/events/envelope.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/events/errors.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/events/ingress.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/events/projection.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/events/protocol.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/events/streams.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/events/subscriptions.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/events/webhooks.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/flags.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/headers.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/http_app.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/legacy.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/redaction.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/service.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/telemetry.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/tool_manager.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/e2e/fixtures/appwrite/deployment_function_duplicate.json +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/e2e/fixtures/appwrite/deployment_function_failed.json +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/e2e/fixtures/appwrite/deployment_function_ready.json +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/e2e/fixtures/appwrite/deployment_site_ready.json +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/e2e/fixtures/appwrite/execution_async_failed.json +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/e2e/fixtures/appwrite/execution_async_waiting.json +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/e2e/fixtures/appwrite/execution_sync_failed.json +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/e2e/fixtures/appwrite/file_created.json +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/e2e/fixtures/appwrite/function_activation.json +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/e2e/fixtures/appwrite/row_created.json +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/e2e/fixtures/appwrite/user_created.json +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/e2e/support.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/e2e/test_apps.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/e2e/test_events_ingress.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/e2e/test_events_protocol.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/e2e/test_events_stream.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/e2e/test_events_subscribe.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/e2e/test_stdio.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/e2e/test_tools.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/integration/support.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/integration/test_avatars.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/integration/test_console_sdk_oauth.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/integration/test_docs_index.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/integration/test_docs_source.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/integration/test_functions.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/integration/test_locale.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/integration/test_messaging.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/integration/test_oauth_discovery.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/integration/test_operator.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/integration/test_sites.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/integration/test_storage.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/integration/test_tables_db.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/integration/test_teams.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/integration/test_users.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/test_all.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/unit/fixtures/jwe-v1.json +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/unit/test_auth.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/unit/test_context.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/unit/test_docs.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/unit/test_docs_search.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/unit/test_error_classification.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/unit/test_error_monitoring.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/unit/test_events_delivery.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/unit/test_events_egress.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/unit/test_events_envelope.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/unit/test_events_protocol.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/unit/test_http_app.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/unit/test_instructions.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/unit/test_operator.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/unit/test_release_metadata.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/unit/test_service.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/tests/unit/test_telemetry.py +0 -0
- {mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/uv.lock +0 -0
|
@@ -32,6 +32,7 @@ Source lives in `src/mcp_server_appwrite/`:
|
|
|
32
32
|
| `tool_manager.py` | Registry of all services and their generated tools. |
|
|
33
33
|
| `operator.py` | The compact "operator" surface — `appwrite_search_tools`, `appwrite_call_tool` / `appwrite_call_write_tool`, tool annotations, result/resource storage, write confirmation. |
|
|
34
34
|
| `instructions.py` | `serverInfo.description` and the server instructions sent on initialize, rendered from `assets/instructions.json` (a description plus ordered, transport/docs-conditional Markdown sections). Edit the JSON to change the wording; keep the `pyproject.toml` description in sync (a test enforces it). |
|
|
35
|
+
| `zero.py` | Appwrite Zero (stdio without credentials): `appwrite_create_zero_project` creates a temporary project with no account and points the shared client at it; `appwrite_get_zero_project` reports its status. |
|
|
35
36
|
| `context.py` | `appwrite_get_context` — workspace summary (project, services, account/org for OAuth, a focused project's environments). |
|
|
36
37
|
| `headers.py` | Per-call request headers: `X-Appwrite-Environment` (a project environment, next to the project's ID) and `X-Appwrite-Reason` (why a write is made, validated and percent-encoded as Appwrite expects). |
|
|
37
38
|
| `redaction.py` | Redacts the response fields Appwrite's spec marks `format: password` (carried on Console SDK model fields) from tool results, leaving a fingerprint, unless a call sets `reveal_secrets`. |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: mcp-server-appwrite
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.7.1
|
|
4
4
|
Summary: Build and deploy application backends. Add authentication, PostgreSQL/MySQL databases, vector databases, storage, serverless functions, realtime, messaging, hosting, domains, CDN and firewall.
|
|
5
5
|
License-File: LICENSE
|
|
6
6
|
Requires-Python: >=3.12
|
|
@@ -43,6 +43,26 @@ For a local Docker Appwrite instance the endpoint is typically
|
|
|
43
43
|
`http://localhost:9501/v1` (HTTP, not HTTPS). The value must be the API base
|
|
44
44
|
(`…/v1`), not the Console URL.
|
|
45
45
|
|
|
46
|
+
## No account: Appwrite Zero
|
|
47
|
+
|
|
48
|
+
Start the server with neither `APPWRITE_PROJECT_ID` nor `APPWRITE_API_KEY` and
|
|
49
|
+
it boots in Zero mode. The agent calls `appwrite_create_zero_project` to get a
|
|
50
|
+
temporary project (endpoint, project ID and an API key valid for 60 minutes),
|
|
51
|
+
and the other tools then operate on it. Open the returned `claimUrl` and sign in
|
|
52
|
+
to keep the project; an unclaimed one is deleted.
|
|
53
|
+
Until then its Sites and function domains are public under a "Powered by
|
|
54
|
+
Appwrite Zero" banner. Deployment preview domains open only with the returned
|
|
55
|
+
`accessToken`: open `https://<domain>/__appwrite/zero?token=<accessToken>` once
|
|
56
|
+
in the browser, or send it in the `X-Appwrite-Zero-Token` header.
|
|
57
|
+
|
|
58
|
+
The project is created in the nearest Appwrite Cloud region; pass `region`
|
|
59
|
+
(`fra`, `nyc`, `sfo`, `sgp`, `syd`, `tor`) to pick one. `region` needs the
|
|
60
|
+
default endpoint, so it is refused when `APPWRITE_ENDPOINT` points elsewhere.
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
claude mcp add appwrite -- uvx mcp-server-appwrite
|
|
64
|
+
```
|
|
65
|
+
|
|
46
66
|
## Project environments
|
|
47
67
|
|
|
48
68
|
On Appwrite Cloud, a project can have environments (for example `staging`).
|
|
@@ -40,6 +40,14 @@ flowchart LR
|
|
|
40
40
|
| `appwrite_call_tool` | Runs a read catalog tool (`list`, `get`). |
|
|
41
41
|
| `appwrite_call_write_tool` | Runs every other catalog tool (create, update, delete, upsert, unknown verbs). Requires `confirm_write=true` and a `reason`. |
|
|
42
42
|
| `appwrite_search_docs` | Semantic search over Appwrite docs (conditional — see above). |
|
|
43
|
+
| `appwrite_create_zero_project` | Zero mode only: creates a temporary project with no account and points the other tools at it. |
|
|
44
|
+
| `appwrite_get_zero_project` | Zero mode only: status, `expiresAt` and `claimBy` of a Zero project. |
|
|
45
|
+
|
|
46
|
+
**Zero mode**: stdio started with neither `APPWRITE_PROJECT_ID` nor
|
|
47
|
+
`APPWRITE_API_KEY` skips startup validation and adds the two Zero tools.
|
|
48
|
+
`appwrite_get_context`, `appwrite_call_tool`, `appwrite_call_write_tool` and
|
|
49
|
+
the MCP Apps view tools refuse until a Zero project exists; after that they
|
|
50
|
+
operate on it for the rest of the session.
|
|
43
51
|
|
|
44
52
|
## Behavior
|
|
45
53
|
|
|
@@ -90,10 +90,26 @@
|
|
|
90
90
|
"- For questions about Appwrite concepts, products, features, or guides, use appwrite_search_docs — it searches the official Appwrite documentation and needs no project or credentials."
|
|
91
91
|
]
|
|
92
92
|
},
|
|
93
|
+
{
|
|
94
|
+
"transports": ["stdio"],
|
|
95
|
+
"zero": false,
|
|
96
|
+
"lines": [
|
|
97
|
+
"- This local connection uses the API key, endpoint, and project configured in the server environment. Appwrite API calls target that configured APPWRITE_PROJECT_ID by default, and act in the project environment APPWRITE_ENVIRONMENT_ID names when it is set."
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"transports": ["stdio"],
|
|
102
|
+
"zero": true,
|
|
103
|
+
"lines": [
|
|
104
|
+
"- No Appwrite project is configured. When the user needs a backend and has no Appwrite project, call appwrite_create_zero_project: it creates a free project with no account, valid for 60 minutes, and points the other tools at it.",
|
|
105
|
+
"- Always give the user the returned claimUrl and tell them to open it to keep the project; an unclaimed project is deleted.",
|
|
106
|
+
"- Until the project is claimed, its Sites and function domains are public under a Powered by Appwrite Zero banner. Deployment preview domains open only with the returned accessToken: send it in the X-Appwrite-Zero-Token header when you fetch one, and give the user https://<domain>/__appwrite/zero?token=<accessToken> to open one in a browser.",
|
|
107
|
+
"- Use the returned endpoint, projectId and apiKey to configure the user's app or an Appwrite SDK."
|
|
108
|
+
]
|
|
109
|
+
},
|
|
93
110
|
{
|
|
94
111
|
"transports": ["stdio"],
|
|
95
112
|
"lines": [
|
|
96
|
-
"- This local connection uses the API key, endpoint, and project configured in the server environment. Appwrite API calls target that configured APPWRITE_PROJECT_ID by default, and act in the project environment APPWRITE_ENVIRONMENT_ID names when it is set.",
|
|
97
113
|
"- Project API keys cannot manage dedicated PostgreSQL/MySQL databases, domain registration, migrations or usage metrics; those need the hosted server at mcp.appwrite.io.",
|
|
98
114
|
"- Large results are stored as resources; read the URI returned by the tool."
|
|
99
115
|
]
|
{mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/constants.py
RENAMED
|
@@ -131,6 +131,11 @@ DATA_DIR = Path(__file__).parent / "data"
|
|
|
131
131
|
INDEX_FILE = "docs_index.npz"
|
|
132
132
|
META_MEMBER = "meta.json"
|
|
133
133
|
|
|
134
|
+
ZERO_CREATE_TOOL_NAME = "appwrite_create_zero_project"
|
|
135
|
+
ZERO_GET_TOOL_NAME = "appwrite_get_zero_project"
|
|
136
|
+
ZERO_SOURCE = "mcp"
|
|
137
|
+
ZERO_TIMEOUT_SECONDS = 60.0
|
|
138
|
+
|
|
134
139
|
SERVICE_PROBES = {
|
|
135
140
|
"tablesdb": {
|
|
136
141
|
"path": "/tablesdb",
|
{mcp_server_appwrite-2.6.7 → mcp_server_appwrite-2.7.1}/src/mcp_server_appwrite/instructions.py
RENAMED
|
@@ -8,6 +8,7 @@ only for those transports (the API-key stdio catalog lacks console-only APIs
|
|
|
8
8
|
such as dedicated databases and domain registration, see ``catalog_policy``),
|
|
9
9
|
and one with ``docs`` only when docs search availability matches. Lines within
|
|
10
10
|
a section are joined by newlines and sections by blank lines, in file order.
|
|
11
|
+
One with ``zero`` is included only when Zero mode (see ``zero``) matches.
|
|
11
12
|
"""
|
|
12
13
|
|
|
13
14
|
from __future__ import annotations
|
|
@@ -26,10 +27,13 @@ class Section:
|
|
|
26
27
|
lines: tuple[str, ...]
|
|
27
28
|
transports: frozenset[str] | None = None
|
|
28
29
|
docs: bool | None = None
|
|
30
|
+
zero: bool | None = None
|
|
29
31
|
|
|
30
|
-
def applies(self, transport: str, docs_enabled: bool) -> bool:
|
|
32
|
+
def applies(self, transport: str, docs_enabled: bool, zero: bool = False) -> bool:
|
|
31
33
|
if self.transports is not None and transport not in self.transports:
|
|
32
34
|
return False
|
|
35
|
+
if self.zero is not None and self.zero != zero:
|
|
36
|
+
return False
|
|
33
37
|
return self.docs is None or self.docs == docs_enabled
|
|
34
38
|
|
|
35
39
|
def render(self) -> str:
|
|
@@ -37,7 +41,7 @@ class Section:
|
|
|
37
41
|
|
|
38
42
|
@classmethod
|
|
39
43
|
def parse(cls, raw: dict[str, Any]) -> Section:
|
|
40
|
-
unknown = raw.keys() - {"lines", "transports", "docs"}
|
|
44
|
+
unknown = raw.keys() - {"lines", "transports", "docs", "zero"}
|
|
41
45
|
if unknown:
|
|
42
46
|
raise ValueError(f"Unknown instruction section keys: {sorted(unknown)}")
|
|
43
47
|
lines = raw["lines"]
|
|
@@ -54,7 +58,10 @@ class Section:
|
|
|
54
58
|
docs = raw.get("docs")
|
|
55
59
|
if docs is not None and not isinstance(docs, bool):
|
|
56
60
|
raise ValueError("Instruction section 'docs' must be a boolean.")
|
|
57
|
-
|
|
61
|
+
zero = raw.get("zero")
|
|
62
|
+
if zero is not None and not isinstance(zero, bool):
|
|
63
|
+
raise ValueError("Instruction section 'zero' must be a boolean.")
|
|
64
|
+
return cls(tuple(lines), transports, docs, zero)
|
|
58
65
|
|
|
59
66
|
|
|
60
67
|
@cache
|
|
@@ -78,9 +85,11 @@ def load_description() -> str:
|
|
|
78
85
|
return description
|
|
79
86
|
|
|
80
87
|
|
|
81
|
-
def build_instructions(
|
|
88
|
+
def build_instructions(
|
|
89
|
+
transport: str = "http", *, docs_enabled: bool = True, zero: bool = False
|
|
90
|
+
) -> str:
|
|
82
91
|
return "\n\n".join(
|
|
83
92
|
section.render()
|
|
84
93
|
for section in load_sections()
|
|
85
|
-
if section.applies(transport, docs_enabled)
|
|
94
|
+
if section.applies(transport, docs_enabled, zero)
|
|
86
95
|
)
|
|
@@ -31,9 +31,12 @@ from .constants import (
|
|
|
31
31
|
RESULT_URI_TEMPLATE,
|
|
32
32
|
SEARCH_LIMIT,
|
|
33
33
|
SEARCH_TOOL_NAME,
|
|
34
|
+
SHOW_TOOL_NAME,
|
|
34
35
|
UPDATE_HINTS,
|
|
35
36
|
VERBS,
|
|
37
|
+
VIEW_WRITE_TOOL_NAME,
|
|
36
38
|
WRITE_TOOL_NAME,
|
|
39
|
+
ZERO_CREATE_TOOL_NAME,
|
|
37
40
|
)
|
|
38
41
|
from .docs_search import DocsSearch
|
|
39
42
|
from .error_classification import (
|
|
@@ -45,6 +48,7 @@ from .error_classification import (
|
|
|
45
48
|
)
|
|
46
49
|
from .headers import REASON_LENGTH, reason_error
|
|
47
50
|
from .tool_manager import ToolManager
|
|
51
|
+
from .zero import Zero
|
|
48
52
|
|
|
49
53
|
ToolContent = types.TextContent | types.ImageContent | types.EmbeddedResource
|
|
50
54
|
# (tool_name, arguments, project_id, organization_id, environment_id, reason,
|
|
@@ -155,6 +159,7 @@ class Operator:
|
|
|
155
159
|
store_results: bool = True,
|
|
156
160
|
search_limit: int = SEARCH_LIMIT,
|
|
157
161
|
notice: str | None = None,
|
|
162
|
+
zero: Zero | None = None,
|
|
158
163
|
):
|
|
159
164
|
self._tools_manager = tools_manager
|
|
160
165
|
self._execute_tool = execute_tool
|
|
@@ -165,6 +170,7 @@ class Operator:
|
|
|
165
170
|
self._store_results = store_results
|
|
166
171
|
self._search_limit = search_limit
|
|
167
172
|
self._notice = notice
|
|
173
|
+
self._zero = zero
|
|
168
174
|
self._result_store = ResultStore()
|
|
169
175
|
self._catalog = self._build_catalog()
|
|
170
176
|
self._cached_catalog_json = self._catalog_json()
|
|
@@ -182,6 +188,10 @@ class Operator:
|
|
|
182
188
|
def docs_enabled(self) -> bool:
|
|
183
189
|
return self._docs_search is not None
|
|
184
190
|
|
|
191
|
+
@property
|
|
192
|
+
def zero_enabled(self) -> bool:
|
|
193
|
+
return self._zero is not None
|
|
194
|
+
|
|
185
195
|
@property
|
|
186
196
|
def docs_search(self) -> DocsSearch | None:
|
|
187
197
|
return self._docs_search
|
|
@@ -353,6 +363,16 @@ class Operator:
|
|
|
353
363
|
if self._docs_search is not None:
|
|
354
364
|
tools.append(PublicTool(self._docs_search.get_tool(), self._search_docs))
|
|
355
365
|
|
|
366
|
+
if self._zero is not None:
|
|
367
|
+
zero = self._zero
|
|
368
|
+
for tool in zero.get_tools():
|
|
369
|
+
tools.append(
|
|
370
|
+
PublicTool(
|
|
371
|
+
tool,
|
|
372
|
+
lambda arguments, name=tool.name: zero.execute(name, arguments),
|
|
373
|
+
)
|
|
374
|
+
)
|
|
375
|
+
|
|
356
376
|
return {public.tool.name: public for public in tools}
|
|
357
377
|
|
|
358
378
|
def execute_public_tool(
|
|
@@ -395,6 +415,12 @@ class Operator:
|
|
|
395
415
|
def _dispatch_public_tool(
|
|
396
416
|
self, name: str, arguments: dict[str, Any] | None
|
|
397
417
|
) -> ToolOutput:
|
|
418
|
+
if self._zero is not None and not self._zero.ready and name in _PROJECT_TOOLS:
|
|
419
|
+
raise ValueError(
|
|
420
|
+
"No Appwrite project is configured. Call "
|
|
421
|
+
f"{ZERO_CREATE_TOOL_NAME} to create a temporary one, or set "
|
|
422
|
+
"APPWRITE_PROJECT_ID and APPWRITE_API_KEY."
|
|
423
|
+
)
|
|
398
424
|
public = self._public_tools.get(name) or self._view_tools.get(name)
|
|
399
425
|
if public is None:
|
|
400
426
|
raise ValueError(f"Unknown public Appwrite tool {name}")
|
|
@@ -892,6 +918,18 @@ def _write_reason(
|
|
|
892
918
|
return reason
|
|
893
919
|
|
|
894
920
|
|
|
921
|
+
# Public tools that need a project; Zero mode refuses them until one exists.
|
|
922
|
+
_PROJECT_TOOLS = frozenset(
|
|
923
|
+
{
|
|
924
|
+
CONTEXT_TOOL_NAME,
|
|
925
|
+
CALL_TOOL_NAME,
|
|
926
|
+
WRITE_TOOL_NAME,
|
|
927
|
+
SHOW_TOOL_NAME,
|
|
928
|
+
VIEW_WRITE_TOOL_NAME,
|
|
929
|
+
}
|
|
930
|
+
)
|
|
931
|
+
|
|
932
|
+
|
|
895
933
|
_MIN_INFLECTION_TOKEN_LENGTH = 3
|
|
896
934
|
_MAX_INFLECTION_SUFFIX = 2
|
|
897
935
|
_SUGGESTION_LIMIT = 5
|
|
@@ -86,6 +86,7 @@ from .operator import Operator, ToolOutput, _parse_tool_name
|
|
|
86
86
|
from .redaction import note, redact, redact_payload
|
|
87
87
|
from .service import Service
|
|
88
88
|
from .tool_manager import ToolManager
|
|
89
|
+
from .zero import Zero
|
|
89
90
|
|
|
90
91
|
|
|
91
92
|
def _discover_service_classes() -> dict[str, type]:
|
|
@@ -1393,7 +1394,9 @@ def build_mcp_server(
|
|
|
1393
1394
|
``legacy.py``) leads the instructions so clients that truncate them keep it."""
|
|
1394
1395
|
_configure_uploads(transport)
|
|
1395
1396
|
instructions = build_instructions(
|
|
1396
|
-
transport,
|
|
1397
|
+
transport,
|
|
1398
|
+
docs_enabled=bool(getattr(operator, "docs_enabled", False)),
|
|
1399
|
+
zero=bool(getattr(operator, "zero_enabled", False)),
|
|
1397
1400
|
)
|
|
1398
1401
|
if notice:
|
|
1399
1402
|
instructions = f"{notice}\n\n{instructions}"
|
|
@@ -1825,6 +1828,7 @@ def build_operator(
|
|
|
1825
1828
|
*,
|
|
1826
1829
|
store_results: bool = True,
|
|
1827
1830
|
notice: str | None = None,
|
|
1831
|
+
zero: Zero | None = None,
|
|
1828
1832
|
) -> Operator:
|
|
1829
1833
|
"""Wire the operator surface to the per-request execution path. The execution
|
|
1830
1834
|
callback re-binds each call to a per-request client via `resolve_client` in
|
|
@@ -1861,6 +1865,7 @@ def build_operator(
|
|
|
1861
1865
|
require_target_context=client is None,
|
|
1862
1866
|
store_results=store_results,
|
|
1863
1867
|
notice=notice,
|
|
1868
|
+
zero=zero,
|
|
1864
1869
|
)
|
|
1865
1870
|
|
|
1866
1871
|
|
|
@@ -1930,18 +1935,33 @@ def build_catalog_tools_manager() -> ToolManager:
|
|
|
1930
1935
|
|
|
1931
1936
|
|
|
1932
1937
|
async def run_stdio(legacy_flags: Sequence[str] = ()) -> None:
|
|
1933
|
-
"""Serve a local stdio MCP using APPWRITE_* API-key configuration
|
|
1938
|
+
"""Serve a local stdio MCP using APPWRITE_* API-key configuration, or in
|
|
1939
|
+
Zero mode (see ``zero.py``) when no project or API key is configured."""
|
|
1934
1940
|
notice = legacy.notice(legacy_flags)
|
|
1935
1941
|
_log_startup("Loading Appwrite configuration")
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1942
|
+
load_environment()
|
|
1943
|
+
zero = None
|
|
1944
|
+
if os.getenv("APPWRITE_PROJECT_ID") or os.getenv("APPWRITE_API_KEY"):
|
|
1945
|
+
config = load_appwrite_config()
|
|
1946
|
+
client = build_client(config)
|
|
1947
|
+
endpoint = config.endpoint
|
|
1948
|
+
else:
|
|
1949
|
+
endpoint = _normalize_endpoint(os.getenv("APPWRITE_ENDPOINT", DEFAULT_ENDPOINT))
|
|
1950
|
+
client = _configure_mcp_client_headers(Client())
|
|
1951
|
+
client.set_endpoint(endpoint)
|
|
1952
|
+
zero = Zero(client, endpoint)
|
|
1953
|
+
_log_startup(f"Using Appwrite endpoint: {endpoint}")
|
|
1939
1954
|
_log_startup("Registering Appwrite services")
|
|
1940
1955
|
tools_manager = register_services(client, profile=API_KEY_PROFILE)
|
|
1941
|
-
|
|
1942
|
-
|
|
1956
|
+
if zero is None:
|
|
1957
|
+
_log_startup("Starting Appwrite service validation")
|
|
1958
|
+
validate_services(tools_manager)
|
|
1959
|
+
else:
|
|
1960
|
+
_log_startup(
|
|
1961
|
+
"No APPWRITE_PROJECT_ID or APPWRITE_API_KEY: starting in Zero mode"
|
|
1962
|
+
)
|
|
1943
1963
|
_log_startup("Building Appwrite operator surface")
|
|
1944
|
-
operator = build_operator(tools_manager, client=client, notice=notice)
|
|
1964
|
+
operator = build_operator(tools_manager, client=client, notice=notice, zero=zero)
|
|
1945
1965
|
server = build_mcp_server(operator, transport="stdio", notice=notice)
|
|
1946
1966
|
|
|
1947
1967
|
async with mcp.server.stdio.stdio_server() as (read_stream, write_stream):
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
"""Appwrite Zero: a temporary Appwrite project for an agent with no account.
|
|
2
|
+
|
|
3
|
+
The stdio server boots in Zero mode when neither ``APPWRITE_PROJECT_ID`` nor
|
|
4
|
+
``APPWRITE_API_KEY`` is set. Instead of failing at startup it exposes
|
|
5
|
+
``appwrite_create_zero_project``, which asks the Appwrite console API for a
|
|
6
|
+
fresh project (``POST /zero``, no authentication) and points the server's shared
|
|
7
|
+
SDK client at the returned endpoint, project and API key. Every hidden tool
|
|
8
|
+
re-binds that same client on each call (see ``server.execute_registered_tool``),
|
|
9
|
+
so the whole catalog works against the new project for the rest of the session.
|
|
10
|
+
|
|
11
|
+
The API key is valid until ``expiresAt``. The project is kept only if the human
|
|
12
|
+
opens ``claimUrl`` and signs in before ``claimBy``; otherwise it is deleted, so
|
|
13
|
+
the agent must hand that link to the user.
|
|
14
|
+
|
|
15
|
+
The project lands in whichever region serves ``POST /zero``; the default
|
|
16
|
+
endpoint is geo-routed. An optional ``region`` sends the request to that
|
|
17
|
+
region's host instead (``https://<region>.cloud.appwrite.io/v1``), so no API
|
|
18
|
+
change is needed to pick one.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from __future__ import annotations
|
|
22
|
+
|
|
23
|
+
import json
|
|
24
|
+
from typing import Any
|
|
25
|
+
|
|
26
|
+
import httpx
|
|
27
|
+
import mcp.types as types
|
|
28
|
+
from appwrite_console.client import Client
|
|
29
|
+
from appwrite_console.enums.region import Region
|
|
30
|
+
|
|
31
|
+
from .constants import (
|
|
32
|
+
CALL_TOOL_NAME,
|
|
33
|
+
CONTEXT_TOOL_NAME,
|
|
34
|
+
DEFAULT_ENDPOINT,
|
|
35
|
+
DEFAULT_PROJECT_ID,
|
|
36
|
+
SEARCH_TOOL_NAME,
|
|
37
|
+
SERVER_VERSION,
|
|
38
|
+
WRITE_TOOL_NAME,
|
|
39
|
+
ZERO_CREATE_TOOL_NAME,
|
|
40
|
+
ZERO_GET_TOOL_NAME,
|
|
41
|
+
ZERO_SOURCE,
|
|
42
|
+
ZERO_TIMEOUT_SECONDS,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
ToolContent = types.TextContent | types.ImageContent | types.EmbeddedResource
|
|
46
|
+
|
|
47
|
+
_CREATE_TITLE = "Create Appwrite Zero project"
|
|
48
|
+
_GET_TITLE = "Get Appwrite Zero project"
|
|
49
|
+
_REGIONS = [region.value for region in Region]
|
|
50
|
+
|
|
51
|
+
_ERRORS = {
|
|
52
|
+
"zero_unavailable": (
|
|
53
|
+
"Appwrite Zero has no capacity right now. Try again in a few minutes, or "
|
|
54
|
+
"ask the user to sign up for Appwrite and configure APPWRITE_PROJECT_ID "
|
|
55
|
+
"and APPWRITE_API_KEY."
|
|
56
|
+
),
|
|
57
|
+
"zero_disabled": "Appwrite Zero is not enabled on this Appwrite endpoint.",
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class _NotFound(Exception):
|
|
62
|
+
"""``zero_not_found``: the project is no longer an unclaimed Zero project."""
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class Zero:
|
|
66
|
+
"""Creates Zero projects and re-points ``client`` at the latest one."""
|
|
67
|
+
|
|
68
|
+
def __init__(self, client: Client, endpoint: str):
|
|
69
|
+
self._client = client
|
|
70
|
+
# The configured endpoint; a regional create leaves it untouched.
|
|
71
|
+
self._configured = endpoint
|
|
72
|
+
# Where /zero is called: the regional host once a project was created there.
|
|
73
|
+
self._endpoint = endpoint
|
|
74
|
+
self._manifest: dict[str, Any] | None = None
|
|
75
|
+
|
|
76
|
+
@property
|
|
77
|
+
def ready(self) -> bool:
|
|
78
|
+
return self._manifest is not None
|
|
79
|
+
|
|
80
|
+
def get_tools(self) -> list[types.Tool]:
|
|
81
|
+
return [
|
|
82
|
+
types.Tool(
|
|
83
|
+
name=ZERO_CREATE_TOOL_NAME,
|
|
84
|
+
title=_CREATE_TITLE,
|
|
85
|
+
annotations=types.ToolAnnotations(
|
|
86
|
+
title=_CREATE_TITLE,
|
|
87
|
+
read_only_hint=False,
|
|
88
|
+
open_world_hint=True,
|
|
89
|
+
destructive_hint=False,
|
|
90
|
+
idempotent_hint=False,
|
|
91
|
+
),
|
|
92
|
+
description=(
|
|
93
|
+
"Create a free, temporary Appwrite project. No Appwrite account "
|
|
94
|
+
"or credentials are needed. Returns the project's endpoint, "
|
|
95
|
+
"projectId and an apiKey with every project scope, valid for 60 "
|
|
96
|
+
"minutes (until expiresAt). After this call "
|
|
97
|
+
f"{CONTEXT_TOOL_NAME}, {SEARCH_TOOL_NAME}, {CALL_TOOL_NAME} and "
|
|
98
|
+
f"{WRITE_TOOL_NAME} operate on the new project; the same values also work with any Appwrite SDK or the "
|
|
99
|
+
"REST API. You MUST give the user the claimUrl: opening it and "
|
|
100
|
+
"signing in keeps the project and its API key. An unclaimed "
|
|
101
|
+
"project stops working at expiresAt and is deleted after claimBy. "
|
|
102
|
+
"Until it is claimed, its Sites and function domains are public "
|
|
103
|
+
"under a Powered by Appwrite Zero banner. Deployment preview "
|
|
104
|
+
"domains open only with the accessToken: send it in the "
|
|
105
|
+
"X-Appwrite-Zero-Token header when you fetch one, and give the user "
|
|
106
|
+
"https://<domain>/__appwrite/zero?token=<accessToken> to open one "
|
|
107
|
+
"in a browser. "
|
|
108
|
+
"Use this only when the user has no Appwrite project of their own. "
|
|
109
|
+
"Pass region to choose where the project lives; by default it "
|
|
110
|
+
"is the region nearest to this machine."
|
|
111
|
+
),
|
|
112
|
+
input_schema={
|
|
113
|
+
"type": "object",
|
|
114
|
+
"properties": {
|
|
115
|
+
"region": {
|
|
116
|
+
"type": "string",
|
|
117
|
+
"enum": _REGIONS,
|
|
118
|
+
"description": "Appwrite Cloud region for the project. Defaults to the nearest one.",
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
"additionalProperties": False,
|
|
122
|
+
},
|
|
123
|
+
),
|
|
124
|
+
types.Tool(
|
|
125
|
+
name=ZERO_GET_TOOL_NAME,
|
|
126
|
+
title=_GET_TITLE,
|
|
127
|
+
annotations=types.ToolAnnotations(
|
|
128
|
+
title=_GET_TITLE,
|
|
129
|
+
read_only_hint=True,
|
|
130
|
+
open_world_hint=True,
|
|
131
|
+
destructive_hint=False,
|
|
132
|
+
idempotent_hint=True,
|
|
133
|
+
),
|
|
134
|
+
description=(
|
|
135
|
+
"Get the status (active or expired), expiresAt and claimBy of "
|
|
136
|
+
"an unclaimed Appwrite Zero project. Defaults to the project "
|
|
137
|
+
f"{ZERO_CREATE_TOOL_NAME} created in this session. A project "
|
|
138
|
+
"that was claimed or deleted is reported as no longer an "
|
|
139
|
+
"unclaimed Zero project."
|
|
140
|
+
),
|
|
141
|
+
input_schema={
|
|
142
|
+
"type": "object",
|
|
143
|
+
"properties": {
|
|
144
|
+
"zero_id": {
|
|
145
|
+
"type": "string",
|
|
146
|
+
"description": "Zero project ID ($id, the same as projectId). Defaults to this session's.",
|
|
147
|
+
},
|
|
148
|
+
"secret": {
|
|
149
|
+
"type": "string",
|
|
150
|
+
"description": "Secret returned with the Zero project. Defaults to this session's.",
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
"additionalProperties": False,
|
|
154
|
+
},
|
|
155
|
+
),
|
|
156
|
+
]
|
|
157
|
+
|
|
158
|
+
def has_tool(self, name: str) -> bool:
|
|
159
|
+
return name in {ZERO_CREATE_TOOL_NAME, ZERO_GET_TOOL_NAME}
|
|
160
|
+
|
|
161
|
+
def execute(self, name: str, arguments: dict[str, Any]) -> list[ToolContent]:
|
|
162
|
+
if name == ZERO_CREATE_TOOL_NAME:
|
|
163
|
+
return self._create(arguments.get("region"))
|
|
164
|
+
if name == ZERO_GET_TOOL_NAME:
|
|
165
|
+
return self._get(arguments)
|
|
166
|
+
raise ValueError(f"Unknown Appwrite Zero tool {name}")
|
|
167
|
+
|
|
168
|
+
def _create(self, region: Any) -> list[ToolContent]:
|
|
169
|
+
base = self._configured
|
|
170
|
+
if region is not None:
|
|
171
|
+
if region not in _REGIONS:
|
|
172
|
+
raise ValueError(
|
|
173
|
+
f"Unknown region {region!r}. Use one of: {', '.join(_REGIONS)}."
|
|
174
|
+
)
|
|
175
|
+
if self._configured != DEFAULT_ENDPOINT:
|
|
176
|
+
raise ValueError(
|
|
177
|
+
f"region works only with the Appwrite Cloud endpoint "
|
|
178
|
+
f"{DEFAULT_ENDPOINT}; APPWRITE_ENDPOINT is {self._configured}. "
|
|
179
|
+
"Unset it or omit region."
|
|
180
|
+
)
|
|
181
|
+
base = DEFAULT_ENDPOINT.replace("://", f"://{region}.", 1)
|
|
182
|
+
manifest = self._request(
|
|
183
|
+
"post", "/zero", endpoint=base, json={"source": ZERO_SOURCE}
|
|
184
|
+
)
|
|
185
|
+
self._endpoint = base
|
|
186
|
+
endpoint = str(manifest.get("endpoint") or base).rstrip("/")
|
|
187
|
+
self._client.set_endpoint(endpoint)
|
|
188
|
+
self._client.set_project(manifest["projectId"])
|
|
189
|
+
self._client.set_key(manifest["apiKey"])
|
|
190
|
+
self._manifest = manifest
|
|
191
|
+
return [
|
|
192
|
+
types.TextContent(
|
|
193
|
+
type="text",
|
|
194
|
+
text=(
|
|
195
|
+
"Created a temporary Appwrite project. The other Appwrite tools "
|
|
196
|
+
"now operate on it. Give the user this link to keep the project: "
|
|
197
|
+
f"{manifest.get('claimUrl')}\n{json.dumps(manifest, indent=2)}"
|
|
198
|
+
),
|
|
199
|
+
)
|
|
200
|
+
]
|
|
201
|
+
|
|
202
|
+
def _get(self, arguments: dict[str, Any]) -> list[ToolContent]:
|
|
203
|
+
manifest = self._manifest or {}
|
|
204
|
+
zero_id = arguments.get("zero_id", arguments.get("zeroId")) or manifest.get(
|
|
205
|
+
"$id"
|
|
206
|
+
)
|
|
207
|
+
secret = arguments.get("secret") or manifest.get("secret")
|
|
208
|
+
if not zero_id or not secret:
|
|
209
|
+
raise ValueError(
|
|
210
|
+
f"zero_id and secret are required until {ZERO_CREATE_TOOL_NAME} "
|
|
211
|
+
"has created a project in this session."
|
|
212
|
+
)
|
|
213
|
+
try:
|
|
214
|
+
status = self._request("get", f"/zero/{zero_id}", params={"secret": secret})
|
|
215
|
+
except _NotFound:
|
|
216
|
+
# A uniform 404 covers claimed, deleted, unknown ID and wrong secret,
|
|
217
|
+
# so the endpoint cannot say which.
|
|
218
|
+
return [
|
|
219
|
+
types.TextContent(
|
|
220
|
+
type="text",
|
|
221
|
+
text=(
|
|
222
|
+
f"{zero_id} is no longer an unclaimed Zero project: it was "
|
|
223
|
+
"claimed or deleted (or the ID or secret is wrong). If the "
|
|
224
|
+
"user claimed it, it lives on in their Appwrite account."
|
|
225
|
+
),
|
|
226
|
+
)
|
|
227
|
+
]
|
|
228
|
+
return [types.TextContent(type="text", text=json.dumps(status, indent=2))]
|
|
229
|
+
|
|
230
|
+
def _request(
|
|
231
|
+
self, method: str, path: str, endpoint: str | None = None, **kwargs: Any
|
|
232
|
+
) -> dict[str, Any]:
|
|
233
|
+
# A plain HTTP client rather than the SDK one: the SDK client carries the
|
|
234
|
+
# current Zero project's API key, and /zero must be called without auth.
|
|
235
|
+
with httpx.Client(timeout=ZERO_TIMEOUT_SECONDS) as http:
|
|
236
|
+
response = http.request(
|
|
237
|
+
method,
|
|
238
|
+
f"{endpoint or self._endpoint}{path}",
|
|
239
|
+
headers={
|
|
240
|
+
"x-appwrite-project": DEFAULT_PROJECT_ID,
|
|
241
|
+
"x-sdk-name": "mcp",
|
|
242
|
+
"user-agent": f"AppwriteMCP/{SERVER_VERSION}",
|
|
243
|
+
},
|
|
244
|
+
**kwargs,
|
|
245
|
+
)
|
|
246
|
+
try:
|
|
247
|
+
body = response.json()
|
|
248
|
+
except ValueError:
|
|
249
|
+
body = {}
|
|
250
|
+
if response.status_code < 400 and isinstance(body, dict):
|
|
251
|
+
return body
|
|
252
|
+
|
|
253
|
+
error_type = body.get("type", "") if isinstance(body, dict) else ""
|
|
254
|
+
if error_type == "zero_not_found":
|
|
255
|
+
raise _NotFound()
|
|
256
|
+
message = body.get("message", "") if isinstance(body, dict) else ""
|
|
257
|
+
if response.status_code == 429:
|
|
258
|
+
guidance = (
|
|
259
|
+
"Too many Appwrite Zero projects were created from this network. "
|
|
260
|
+
"Ask the user to sign up for Appwrite and configure "
|
|
261
|
+
"APPWRITE_PROJECT_ID and APPWRITE_API_KEY, or try again later."
|
|
262
|
+
)
|
|
263
|
+
else:
|
|
264
|
+
guidance = _ERRORS.get(error_type, "Appwrite Zero request failed.")
|
|
265
|
+
details = [f"code={response.status_code}"]
|
|
266
|
+
if error_type:
|
|
267
|
+
details.append(f"type={error_type}")
|
|
268
|
+
suffix = f": {message}" if message else ""
|
|
269
|
+
raise RuntimeError(f"{guidance} ({', '.join(details)}){suffix}")
|