You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add appwrite_get_context as a first-class operator tool for workspace/project orientation.
Return adaptive context for API-key project connections and OAuth console connections.
Summarize per-project service usage with tablesdb, users, storage, functions, sites, messaging, and teams.
Use Appwrite Python SDK models for response shaping, with generic compaction/redaction for agent-friendly output.
Testing
uv run ruff check src tests
uv run python -m unittest discover -s tests/unit -v
Live local Appwrite smoke against http://localhost:9501/v1: created disposable projects/keys and verified appwrite_get_context returned project metadata plus service totals/samples, including a scenario with TablesDB, users, storage, and functions.
This PR adds appwrite_get_context as a first-class MCP tool that gives agents an adaptive workspace summary — project metadata plus per-service counts and samples — for both API-key and OAuth console connections. It also introduces AGENTS.md/CLAUDE.md contributor guidance and updates the README and system instructions accordingly.
context.py implements the new tool with a _safe_call wrapper that catches all exceptions (both AppwriteException and broad Exception), ensuring partial context is returned even when individual service probes fail; boolean False values (e.g. enabled=False) are correctly preserved in compact output by guarding the zero-skip filter with isinstance(value, bool).
_normalize_sample_limit handles non-numeric sample_limit inputs gracefully, and _compact_document enforces a 12-field cap with priority ranking to keep output agent-friendly.
All three issues surfaced in prior review threads are addressed and covered by new targeted unit tests in test_context.py.
Confidence Score: 5/5
Safe to merge; the new context tool is well-isolated, all previously identified correctness issues have been fixed and tested, and the changes do not touch auth or data-mutation paths.
The implementation is careful: error handling in _safe_call is now broad enough to survive transport-level failures, the boolean-filter fix preserves disabled-resource state, and sample-limit normalization is centralized and tested. No correctness or security defects were found in the new code paths.
No files require special attention, though context.py's _list_projects_for_organization silently caps at 100 projects without surfacing the total, and _compact_document includes the prefs dict without recursive redaction.
Important Files Changed
Filename
Overview
src/mcp_server_appwrite/context.py
New module implementing get_appwrite_context with adaptive API-key and OAuth paths, resilient service probes, and compact/redacted document output; all three previously flagged issues are addressed here.
src/mcp_server_appwrite/operator.py
Adds appwrite_get_context tool definition and ContextProvider type; wires _get_context dispatch; context responses are returned inline rather than stored as resources.
src/mcp_server_appwrite/server.py
Introduces _get_context_for_request and wires context_provider lambda into build_operator; updates instructions text for both transport modes.
tests/unit/test_context.py
New unit tests with a FakeClient covering API-key mode, OAuth discovery, enabled=False preservation, OSError resilience, and invalid sample_limit fallback.
tests/unit/test_operator.py
Updates existing operator tests for the new tool count and adds dispatch + inline-response tests for appwrite_get_context.
AGENTS.md
New guidance document for AI agents and contributors describing architecture, local-dev setup, and pre-PR checklist.
README.md
Updates tool count from 3 to 4 and adds appwrite_get_context description to the operator tool surface section.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
appwrite_get_contextas a first-class operator tool for workspace/project orientation.tablesdb, users, storage, functions, sites, messaging, and teams.Testing
uv run ruff check src testsuv run python -m unittest discover -s tests/unit -vhttp://localhost:9501/v1: created disposable projects/keys and verifiedappwrite_get_contextreturned project metadata plus service totals/samples, including a scenario with TablesDB, users, storage, and functions.