Skip to content

[Draft] Add experimental MCP server - #3196

Draft
Freika wants to merge 1 commit into
devfrom
feat/mcp-server-mvp
Draft

Freika wants to merge 1 commit into
devfrom
feat/mcp-server-mvp

Conversation

@Freika

@Freika Freika commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Draft status

Exploratory MVP for discussion. The endpoint and two tools are functional, but the initial product/security boundaries should be reviewed before merge.

Goal

Let an MCP client answer two useful questions from an authenticated user's own Dawarich data:

  • What did I do / where did I go during a bounded time range?
  • What is my latest recorded location?

Implementation

  • add the official Ruby MCP SDK
  • expose a stateless Streamable HTTP endpoint at /api/v1/mcp
  • authenticate with the existing Dawarich API key via a bearer authorization header
  • reuse ApiController authentication, pending-payment checks, API rate limiting, host authorization, and response metadata
  • expose get_timeline using Timeline::DayAssembler, strict inclusive ISO date semantics, a 7-calendar-day maximum, and a 500-entry preflight cap enforced before assembly
  • map timeline data through an MCP-specific minimal serializer with a closed JSON Schema contract and runtime output validation
  • expose get_latest_location using the authenticated user's non-anomalous, plan-scoped points
  • return structured MCP content plus JSON text fallback
  • mark both tools read-only, non-destructive, idempotent, and closed-world
  • document generic client configuration and a curl initialization smoke test

Security and deployment

  • every request creates a user-scoped server context from the bearer API key
  • both tools use existing user and plan-window scopes
  • timeline requests are bounded to 7 local calendar days and 500 returned entries using bounded preflight queries
  • preflight track counting shares the assembler's end-exclusive local-day semantics
  • runtime result validation enforces each tool's advertised JSON Schema
  • stateless mode retains no MCP session state and works with multi-process/multi-instance deployments
  • SDK Host/Origin checks remain enabled and use the trusted APPLICATION_HOSTS allowlist
  • the reused API key has broader Dawarich API authority; documentation explicitly limits setup to fully trusted clients
  • no write tools, OAuth server, resources, prompts, sampling, or live notifications

Questions before merge

  1. Is reusing the full-access Dawarich API key acceptable for the MVP, or should the feature wait for scoped/revocable MCP tokens?
  2. Are get_timeline and get_latest_location the right first tools?
  3. Should MCP remain available wherever the read API is available, or be feature/plan gated?
  4. Should a follow-up add visits/places search before this is announced?

Verification

  • MCP request specs: 16 examples, 0 failures
  • npm tests: 4 tests, 0 failures
  • changed-file RuboCop: no offenses
  • bundle exec rails zeitwerk:check: passed
  • git diff --check: passed
  • Brakeman: no warning in new MCP files; repository baseline warnings unchanged
  • Bundler Audit: only pre-existing base-lockfile advisories in loofah and rails-html-sanitizer
  • full RSpec: 6,871 examples passed; one pre-existing archive-task factory collision failed in-suite and passed when rerun alone
  • independent Rails, QA/security, and product reviews: all approved stable staged SHA a43d4a42f3b5ac20112dfe06389fdec7e9fbcd3332e219cc790feefa820858f8

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ea8b7d7b-9325-438b-a45f-3dea89d98315

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/mcp-server-mvp

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Freika
Freika force-pushed the feat/mcp-server-mvp branch from a1a0d0e to 49e850c Compare July 25, 2026 20:38
turmacar added a commit to turmacar/dawarich that referenced this pull request Aug 18, 2026
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