Repository navigation
feat(mcp): MCP transport next to REST, Verwalten page over MCP - #15
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 sametraining.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(officialmodelcontextprotocol/go-sdkv1.8.0): its own wire types with explicit mapping, consumer-definedTrainer/PeopleEditor/PlanEditorinterfaces, and no rules. Domain errors become tool errors (isError: true) with the same message REST gives; other errors are logged and reported asinternal error. One log line per call with tool name, duration and outcome.Service.Roster(people with their plan on a day),Service.StatsandService.Exercises(newExerciseCatalogport, implemented in SQLite).api/mcp-tools.jsonis thetools/listsnapshot, with names, descriptions, annotations, and input and output schemas. A golden test fails on drift; regenerate it withgo test ./internal/mcpapi -run TestToolsMatchSnapshot -update. The SDK validates every input and output against its schema.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 tidymovesgo.yaml.in/yaml/v4to 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.Close)./apicalls; 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
npx @modelcontextprotocol/inspector --cli http://127.0.0.1:8080/mcp --transport http --method tools/list/mcpthrough the home gateway.Notes
featcommits, so 0.4.0 after the merge.type Text map[...],type StepKind stringand plain string keys. Your conventions ask for opaque types there, which would be a separate refactor./metricsendpoint. Counting the per-call log lines in Loki covers the two-week review.🤖 Generated with Claude Code