8000 feat(mcp): add local agent support by ahmet-cetinkaya · Pull Request #309 · ahmet-cetinkaya/whph · GitHub
[go: up one dir, main page]

Skip to content

feat(mcp): add local agent support - #309

Merged
ahmet-cetinkaya merged 16 commits into
mainfrom
feat/mcp-agent-support
Sep 23, 2026
Merged

ahmet-cetinkaya merged 16 commits into
mainfrom
feat/mcp-agent-support

Conversation

@ahmet-cetinkaya
Copy link
Copy Markdown
Owner

🚀 Context

Adds user-authorized, loopback-only Model Context Protocol (MCP) access so local AI agents can use WHPH tasks, habits, notes, timers, app usage, settings, sync, and data-transfer actions without exposing access state to sync, export, or restore.

Important

The MCP server is disabled by default. Users explicitly enable it and issue scoped local grants from WHPH settings; raw tokens are shown only at issuance.


⚙️ Implementation Details

  • Adds a local authenticated Streamable HTTP MCP server, per-grant scopes, access grant persistence/revocation, request limits, resource ownership, local approval operations, and lifecycle management across Linux, Windows, and Android.
  • Registers 89 documented feature tools and grant-scoped resources, with MCP settings UI and localized permission selection.
  • Adds official modern and legacy client smoke coverage, contract/integration tests, and an MCP CI job.
  • Hardens the server against destructive tombstone imports without delete scope, pre-auth request floods, oversized operation/transfer metadata, legacy-session accumulation, and concurrent transfer metadata updates.
flowchart LR
  Agent[Local AI agent] -->|Bearer token / 127.0.0.1| MCP[MCP server]
  MCP -->|scope + rate + session checks| Tools[Feature tools/resources]
  Tools --> App[WHPH application data]
  MCP -->|user approval required| Approval[Local approval UI]
Loading

📋 Checklist for Reviewer

  • MCP CI-equivalent suite passed locally: 156 tests.
  • Full Dart analysis and project lint passed locally.
  • Linux debug bundle built successfully.
  • Live Claude Code client behavior verified for discovery, reads, writes, resources, and settings schema compatibility.
  • Independent security review passed after remediation.
  • Documentation updated: docs/MCP.md, README, privacy policy, and PRD.
  • Windows and true Flatpak runtime verification remain CI/platform follow-ups.

ahmet-cetinkaya and others added 12 commits September 9, 2026 19:27
- Add MCP server, operation service, access store, and data transfer
- Add MCP tool registry, factory, and resource definitions
- Add protocol models (JSON, tool definitions, errors, results)
- Add infrastructure layer for MCP access, operation store, file transfer
- Wire DI containers (main.dart, infrastructure_container, persistence_container)
- Add mcp_dart 2.4.2 and crypto dependencies to pubspec

Co-authored-by: Sisyphus <sisyphus@whph>
- Add MCP server factory, tool registry, and tool catalog
- Add application shared services: timer session, restore barrier,
  application transaction, and graceful shutdown abstractions
- Add drift query interceptor for restore barrier enforcement
- Add per-feature MCP action contracts and event interfaces:
  app_usages, habits, notes, tags, tasks
- Add feature MCP action implementations: app_usage, habit,
  note, settings, sync, task actions
- Add save_note_with_tags_command and tag relationship commands

Co-authored-by: Sisyphus <sisyphus@whph>
- Add MCP settings page, controller, and effects for user management
- Add timer session alarm scheduler for MCP-aware timer lifecycle
- Add MCP runtime service managing connection state and foreground/background
- Add application shutdown service for graceful cleanup
- Add app lifecycle integration with MCP runtime enter/leave foreground
- Add desktop and Flatpak system tray exit with graceful shutdown

Co-authored-by: Sisyphus <sisyphus@whph>
- Extend all feature commands with MCP-aware operations:
  - tasks: complete, delete, save, time records
  - habits: add, delete, complete, toggle, time records
  - notes: save, delete, save_with_tags
  - tags: delete, save, set_relationships, update
  - app_usages: save, delete, queries
  - settings: export, import
- Add MCP task actions, habit actions, sync actions
- Update registrations to expose MCP tool handlers
- Add timer session alarm scheduler integration
- Add habit record operations service
- Add save_note_with_tags_command

Co-authored-by: Sisyphus <sisyphus@whph>
- Adapt Android sync and app_usage services for MCP binding
- Adapt desktop sync services for MCP client/server protocol
- Update Flatpak system tray with graceful shutdown
- Extend drift repositories with MCP-aware query support
- Add database backup service and drift app context for MCP transactions
- Update persistence container for restore barrier integration

Co-authored-by: Sisyphus <sisyphus@whph>
feat(ui): add MCP settings page, locales, and UI parity < F438 button data-telemetry-action="pull_requests.activity.expand_commit_message" aria-expanded="false" aria-label="Commit message body" type="button" data-view-component="true" class="ellipsis-expander js-details-target btn"> …
- Add MCP settings page with locale support for all 22 translations
- Add settings translation keys for MCP configuration
- Update tag components for MCP-aware tag management
- Add platform initialization service for MCP bootstrap
- Add app bootstrap service with MCP runtime integration

Co-authored-by: Sisyphus <sisyphus@whph>
- Add MCP contract and production client CI test job
- Update Windows CI for MCP support
- Update Android CI for MCP test execution
- Update Privacy Policy with MCP data disclosure clause
- Update PRD with MCP access documentation
- Update docs README with MCP.md reference
- Update sync and migration tests for MCP-aware changes

Co-authored-by: Sisyphus <sisyphus@whph>
…ntation

- Add MCP documentation (MCP.md) with tool contract for all 89 handlers
- Add MCP smoke test client (Node.js) for official client compatibility
- Add integration tests: data management, mutation parity, user actions
- Add contract tests: protocol contract, tool catalog, resource tests
- Add infrastructure tests: mcp_access_store, mcp_http_server, restore_barrier
- Add presentation tests: all tool tests (tasks, habits, notes, tags, timer, settings)
- Add timer session service test
- Add settings MCP test

Co-authored-by: Sisyphus <sisyphus@whph>
Move MCP settings from an inline settings-page section into a dedicated
'AI' tile that opens in a responsive dialog, matching the pattern used
by the other settings pages. Rework the scope picker from FilterChips
into a checkbox list with readable per-scope labels, add Select all /
Clear bulk actions, and localize the new strings across all 22 locales.
Bound abandoned operations so grant slots recover, make settings and import schemas usable by external MCP clients, and correct the affected contract coverage.
Require destructive import scopes and bound local request, session, operation, and transfer state before it can exhaust the MCP service.
Use the staged transfer filename required by the import approval endpoint.
@ahmet-cetinkaya ahmet-cetinkaya added the enhancement New feature or request label Sep 21, 2026
@ahmet-cetinkaya ahmet-cetinkaya self-assigned this Sep 21, 2026
@ahmet-cetinkaya
ahmet-cetinkaya marked this pull request as ready for review September 22, 2026 05:51
Use the shell that receives the Windows FVM installation path so the MCP test job can invoke FVM.
Ensure the full Linux test job can execute MCP user-action integration tests
with the official client dependencies available.
Keep test access stores inside the Windows user application directory so the storage safety invariant is satisfied in Windows CI.
Keep reading past the body-size limit instead of aborting mid-stream, so the client finishes writing before the connection closes. Fixes a Windows-only reset observed in CI for the oversized chunked-body test.
@ahmet-cetinkaya
ahmet-cetinkaya merged commit e716d48 into main Sep 23, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0