Skip to content

feat(mcp): MCP transport next to REST, Verwalten page over MCP - #15

Merged
subpathdev merged 4 commits into
mainfrom
feat/mcp-transport
Nov 30, 2026
Merged

subpathdev merged 4 commits into
mainfrom
feat/mcp-transport

Conversation

@subpathdev

Copy link
Copy Markdown
Owner

MCP as a first-class transport next to REST, as a time-boxed experiment: the Verwalten page switches to MCP, and the training page follows in a second PR. REST stays as it is.

What changes

  • /mcp: Streamable HTTP (JSON responses, sessions closed after 1 h idle, cross-origin browser requests refused) with task-shaped tools over the same training.Service: list_people, update_person, list_plans, get_plan, update_plan, list_exercises, today_plan, log_round, streak. They give agents and the page the same capabilities as the REST API.
  • internal/mcpapi (official modelcontextprotocol/go-sdk v1.8.0): its own wire types with explicit mapping, consumer-defined Trainer / PeopleEditor / PlanEditor interfaces, and no rules. Domain errors become tool errors (isError: true) with the same message REST gives; other errors are logged and reported as internal error. One log line per call with tool name, duration and outcome.
  • Domain: Service.Roster (people with their plan on a day), Service.Stats and Service.Exercises (new ExerciseCatalog port, implemented in SQLite).
  • Contract: api/mcp-tools.json is the tools/list snapshot, with names, descriptions, annotations, and input and output schemas. A golden test fails on drift; regenerate it with go test ./internal/mcpapi -run TestToolsMatchSnapshot -update. The SDK validates every input and output against its schema.
  • Verwalten page: web/mcp.js (handshake, tool calls, a new session after a 404). The page now loads with a handshake plus 4 tool calls instead of 2 + one per person + one per plan REST calls. The training page is unchanged.
  • go mod tidy moves go.yaml.in/yaml/v4 to indirect, because the code imports v3.

Verified

  • go build ./..., go vet ./..., go test -race ./.... Tests: table tests for the new use cases against real SQLite, tool tests against a fake (mapping, error mapping, schema validation, logging, HTTP + cross-origin), and an end-to-end test over MCP mixed with REST. A plan saved through one transport and read through the other is not a new version.
  • golangci-lint (latest v2, defaults; the repo has no config or CI step): nothing on changed lines. The 33 remaining findings are in existing code (mostly unchecked Close).
  • Local service in a browser: Verwalten loads with no /api calls; adding a person, a server restart with automatic re-handshake, saving a plan (v2, then "no change"), and a domain error shown on the page all work; the training page reads the new version over REST.

Not verified

  • MCP Inspector (the image download timed out). Command: npx @modelcontextprotocol/inspector --cli http://127.0.0.1:8080/mcp --transport http --method tools/list
  • The cluster, and the route to /mcp through the home gateway.

Notes

  • Release: feat commits, so 0.4.0 after the merge.
  • Not copied into the new code: the domain's existing type Text map[...], type StepKind string and plain string keys. Your conventions ask for opaque types there, which would be a separate refactor.
  • No Prometheus metrics: the service has no /metrics endpoint. Counting the per-call log lines in Loki covers the two-week review.

🤖 Generated with Claude Code

subpathdev and others added 4 commits November 30, 2026 12:59
Service.Roster lists every person with the plan they follow on a day,
Service.Stats returns a person's stats without loading the plan, and
Service.Exercises lists the shared exercise library (new ExerciseCatalog
port, implemented by the SQLite adapter).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Streamable HTTP at /mcp (JSON responses, sessions, cross-origin browser
requests refused) with task-shaped tools over the same domain service:
list_people, update_person, list_plans, get_plan, update_plan,
list_exercises, today_plan, log_round and streak. internal/mcpapi owns its
wire types and maps them; no rule lives in the transport.

The contract is api/mcp-tools.json, the tools/list snapshot, compared in a
golden test. Inputs and outputs are validated against their schemas, domain
errors become tool errors, and every call is logged with its tool name.

go mod tidy also moves go.yaml.in/yaml/v4 to indirect: the code imports v3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
web/mcp.js is a small client (handshake, tool calls, a new session after
a server restart). The page now loads with four tool calls instead of one
REST call per person and per plan. The training page stays on REST.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@subpathdev
subpathdev merged commit ddb783f into main Nov 30, 2026
5 checks passed
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