Skip to content

Add Appwrite context overview tool#45

Merged
ChiragAgg5k merged 4 commits into
mainfrom
feat/appwrite-context-tool
Jun 24, 2026
Merged

Add Appwrite context overview tool#45
ChiragAgg5k merged 4 commits into
mainfrom
feat/appwrite-context-tool

Conversation

@ChiragAgg5k

Copy link
Copy Markdown
Member

Summary

  • 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.

@greptile-apps

greptile-apps Bot commented Jun 24, 2026

Copy link
Copy Markdown

Greptile Summary

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.

Reviews (2): Last reviewed commit: "Return context overview inline" | Re-trigger Greptile

Comment thread src/mcp_server_appwrite/context.py Outdated
Comment thread src/mcp_server_appwrite/context.py
Comment thread src/mcp_server_appwrite/server.py Outdated
@ChiragAgg5k ChiragAgg5k merged commit 44f1f75 into main Jun 24, 2026
7 checks passed
@ChiragAgg5k ChiragAgg5k deleted the feat/appwrite-context-tool branch June 24, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant