Files
TREK/wiki/MCP-Overview.md
T
Maurice 7da0080557 docs(wiki): bring the wiki in line with 4.0.0 (#2034)
* docs(wiki): correct the install and operations pages for 4.0.0

Quick Start passed docker an empty ENCRYPTION_KEY: an assignment prefix is not
expanded on the same command line, so the server silently generated its own key
instead of taking the one the page told you to set. The tag examples pinned to
the 3.x line, the documented tmpfs size did not match the shipped compose file,
and several .env values were described as reaching the container when compose
never interpolates them.

* docs(wiki): match the MCP reference to the registered surface

The scope table was missing the whole Collections group and the totals said 27
scopes across 13 groups where the code registers 29 across 14. The Cloudflare
link on the setup page pointed at an anchor on its own page instead of the
heading on Troubleshooting.

* docs(wiki): correct the plugin and admin pages

Three links to Plugin-Development carried a .md suffix, which does not resolve on
the wiki. The admin pages described tabs, permissions and storage behaviour that
had moved on.

* docs(wiki): bring the feature pages back in line with the app

Costs still documented the old panel, where categories could be added, renamed,
reordered and deleted; they are fixed now and the panel is a day-grouped ledger
with settlements. Trip sharing, journeys, maps, packing, reservations and the
account pages had all drifted in the same way.

* docs(wiki): cover the pages the first pass did not reach

The MCP catalog listed 168 of the 201 registered tools; the settlement tools and
rate_place were missing here and the Collections family from the addon page.
Several resource rows claimed a trips:* scope where the handler asks for
trips:read.

* docs(wiki): tighten the corrections a review picked apart

The audit-log resource is the row id, not the credential id; an admin password
reset does not bump password_version the way the page implied; and a few of the
new paragraphs described behaviour more confidently than the code supports.

* docs(wiki): fix what a last read-through caught

Costs shows every figure in your display currency, not the trip's, and an
expense with no payer still counts against the members it is split between.
Studio's cutoff is a 1024px viewport rather than phones alone, and the
Integrations tab is gated on the providers an admin has configured.

* docs(wiki): the last few the review caught

A passkey satisfies the MFA policy everywhere except the WebSocket handshake,
which still asks for TOTP, so a passkey-only account under that policy gets no
live updates. Mobile optimizes a day from two places, not three. The ctx.db row
carried an unescaped pipe that split the table, and the Backups table linked
with a wiki link whose pipe did the same.
2026-08-25 12:36:52 +02:00

4.4 KiB
Raw Blame History

MCP Overview

TREK includes a built-in Model Context Protocol (MCP) server. MCP is an open standard that lets AI assistants read and modify data in external services through a structured API. When the MCP addon is enabled on your TREK instance, AI clients such as Claude.ai, Claude Desktop, Cursor, VS Code, and others can connect directly to your trips.

What you can do

Once connected, an AI assistant can work with your TREK data in a single conversation:

  • Create and update trips, days, and itineraries
  • Search for real-world places and add them to your trip
  • Build and manage packing lists and to-do items
  • Track budgets and expenses across trip members
  • Create reservations, transport bookings, and accommodations
  • Send collab messages and notes to other trip members
  • Mark countries and regions as visited in Atlas
  • Log vacation days in Vacay
  • Write journey entries across multiple trips

Changes made through MCP are broadcast to all connected clients in real-time — exactly like changes made in the web UI.

Authentication options

Use case Method
Interactive client (Claude.ai, Cursor, VS Code…) OAuth 2.1 with browser consent — TREK issues tokens after you approve scopes in a consent screen
AI agent or script running unattended Machine client (client_credentials) — token obtained directly via client_id + client_secret, no browser ever opened
Legacy setups Static API token — deprecated, full access, no scopes

See MCP-Setup for step-by-step instructions for each method.

Requirements

  • MCP addon enabled — an administrator must enable the MCP addon (mcp) from the Admin Panel before the /mcp endpoint becomes available and the MCP section appears in user settings.
  • APP_URL set — set the APP_URL environment variable to your TREK instance's public URL so OAuth discovery advertises the right issuer and endpoints. If it is unset or not a valid URL, TREK falls back to the first entry of ALLOWED_ORIGINS, and then to http://localhost:{PORT}. Only an https:// origin or localhost / 127.0.0.1 is accepted as the issuer — anything else is replaced by http://localhost:{PORT}, which remote OAuth clients cannot reach.

Rate limits and session limits

Setting Default Environment variable
Requests per minute per user 300 MCP_RATE_LIMIT
Max concurrent sessions per user 20 MCP_MAX_SESSION_PER_USER
Session idle timeout (seconds) 3600 MCP_SESSION_TTL
SSE keep-alive interval (seconds, 0 = off) 25 MCP_SSE_KEEPALIVE

Rate limits are tracked per user–client pair, so each OAuth client has its own independent window. Sessions expire after 1 hour of inactivity by default (MCP_SESSION_TTL); an open SSE stream counts as activity. The server also sends an SSE comment ping every 25 seconds so reverse proxies with idle timeouts (e.g. nginx's default 60s) don't kill the stream between tool calls.

Reaching MCP_MAX_SESSION_PER_USER does not refuse the request: the server closes that user's least-recently-active session to make room for the new one. This keeps a client that cannot hold onto its session id from locking itself out of the server.

Reverse proxy: MCP sessions depend on the Mcp-Session-Id header travelling in both directions. A proxy that strips it makes every tool call open a new session instead of reusing one. Nginx and Caddy pass it through by default — see Reverse-Proxy if you have customised header handling.

Kubernetes / multi-replica: MCP sessions are held in memory per instance. With more than one replica you need sticky sessions (or a single replica), or clients will intermittently see 404 Session not found.

Endpoint

https://<your-trek-instance>/mcp

If the MCP addon is not enabled, this endpoint returns 403. If authentication fails, it returns 401.

Admin: Enable the MCP addon in Admin-Addons. Set APP_URL for OAuth discovery. Revoke tokens and manage OAuth clients from Admin-MCP-Tokens. Adjust rate and session limits with MCP_RATE_LIMIT and MCP_MAX_SESSION_PER_USER — see Environment-Variables.

Next steps

  1. MCP-Setup — connect your AI client
  2. MCP-Scopes — choose the right permissions
  3. MCP-Tools-and-Resources — browse available tools