50 KiB
phase, plan, type, wave, depends_on, files_modified, autonomous, requirements, estimate, must_haves
| phase | plan | type | wave | depends_on | files_modified | autonomous | requirements | estimate | must_haves | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 19.7-generic-mcp-module | 04 | execute | 4 |
|
|
false |
|
|
|
Planner decisions recorded here:
- P-16 (consent contract, D-35):
GET /oauth/mcp/requests/{request}(behindjwt.authandthrottle:oauth-authorize) answers{request_id, client: {name, redirect_host}, scopes: [...requested], expires_at, backend_admin: {login, name} | null};backend_adminis non-null only whenbackendis requested AND the user has a link.POST /oauth/mcp/requests/{request}with{decision: "allow"|"deny", scopes?: [...]}grantssubmitted ∩ requested(requested when omitted) minusbackendwhen there is no link, answers{redirect_uri}fromIssueCode/DenyPending; 404{"error":"request_not_found"}, 422{"error":"no_grantable_scopes"}. A later link needs a new consent (A8 accepted). - P-17 (Journal tool set, Claude's discretion):
journal_list_posts(GET /posts),journal_show_post(GET /posts/{slug}),journal_list_categories,journal_list_tags(read),journal_create_post(POST /posts),journal_update_post(PUT /posts/{id}),journal_delete_post(DELETE /posts/{id}, destructive); one promptjournal_draft_postwith argumentstopic(required) andtone. AllGuard: "backend",Permissions: ["golem15.journal.access_posts"]. Multipart upload routes are not tools. - P-18 (repos and sync): oauthserver and Journal are edited in their canonical repos (
../sm-oauthserver-pluginon master,../sm-journal-pluginon main); the demo's submodules are moved to the same commits by fetching from the local repo path (git -C ../sm-demo-app/plugins/golem15/<name> fetch /media/nvme/dev/golem15/summercms.io/summercms/sm-<name>-plugin <branch> && git checkout FETCH_HEAD) during development and to the tags at release; vue-demo-app is edited in the demo's submodule checkout (../sm-demo-app/vue-demo-app, master, the newer of the two checkouts). - P-19 (demo store, A7): the demo runs one instance without Redis, so
mcp.sessions.store: memory; DEPLOY.md documents the Redis switch (SUMMER_MCP__SESSIONS__STORE=redisplusSUMMER_REDIS__URL) for a multi-instance host. - P-20 (versions): oauthserver
v0.1.2, Journalv0.2.3, both additive; the user decides at the checkpoint.
Purpose: SC-4's "one connector per person" is demonstrable: a frontend sign-in, a verified link, the backend scope, Journal tools as the admin, and removal on unlink. Output: the verifier, the scope, the consent endpoints and pages, Journal's tools, the demo wiring, the e2e smoke, deploy notes, two plugin releases and the demo's pointer bumps.
<execution_context>
@/.claude/msd-core/workflows/execute-plan.md
@/.claude/msd-core/templates/summary.md
</execution_context>
<project_rules>
- Core-plugin rule for oauthserver and Journal: additive only; existing routes, payloads, tables, scopes (
read,write,ai,offline_access) and error bodies unchanged. Journal's management routes keeprequireBackendPrincipaland their PHP-parity error bodies. - Plugin repos first (commit, then tag and push only after the checkpoint); vue-demo-app is committed in its submodule checkout and pushed to its master only after the same checkpoint; pointer bumps in sm-demo-app as separate local commits (sm-demo-app itself is not pushed in this plan). Nothing is deployed in this plan; DEPLOY.md gains the instructions and the user deploys.
summer buildin the demo regeneratesplugins.gen.goandmain.go: install the CLI from the framework at the plan-02 tag first (go install ./cmd/summerfrom the framework checkout at that tag). The demo'smain.gocurrently shows an uncommitted diff from another session: rungit -C ../sm-demo-app status --shortfirst; ifmain.gois modified before this plan touches it, stash nothing, stage only the regeneration this plan produces, and note the pre-existing diff in the SUMMARY.- Stage by explicit path; one logical change per commit; no co-author tags; planning docs (framework repo) in their own commit. </project_rules>
Demo wiring: `summer.yaml` gains `build: { tags: [summercms_mcp] }`; `config/mcp.yaml` with `enabled: true`, `path: /mcp`, `sessions: { store: memory, idle_ttl: 30m }`, `allow_personal_tokens: false`, and a comment pointing at `docs/services/mcp.md`; `config/golem15.oauthserver.yaml` with `mcp: { enabled: true, resource: https://demo.summercms.io/mcp }` (local runs override through `SUMMER_GOLEM15__OAUTHSERVER__MCP__RESOURCE` and `SUMMER_MCP__RESOURCE` in `.env`, see DEPLOY.md task); move the oauthserver submodule to the new commit (P-18) and `go mod tidy` in the demo; `go install ./cmd/summer` from the framework at the plan-02 tag, then `summer build` in the demo to regenerate `plugins.gen.go` and `main.go` (commit only this plan's regeneration). `boot_test.go`: with the committed config the route list contains `POST /mcp` and `GET /.well-known/oauth-protected-resource` when the test binary carries the tag, and contains neither when built without it (two sub-tests or two build-tagged files: `boot_mcp_tagged_test.go` and `boot_mcp_untagged_test.go` are acceptable in place of editing boot_test.go, update files_modified accordingly in the SUMMARY); the existing assertions stay.
E2E smoke `mcp_e2e_test.go` (`//go:build summercms_mcp`, Postgres through `bootDemo`): assemble the handler with `surf.Assemble(demo.App, demo.Plugins)` on an `httptest.NewServer`; seed a frontend user and an `mcp` client row, mint an access token through `classes.NewMCPStore(demo.DB)` (its `Mint`, scopes `read write`) or by inserting the hashed row; with the go-sdk client and a bearer-injecting `http.Client`: `ListTools` contains `user_me` and contains no `journal_` tool (no link yet), `CallTool("user_me", {})` answers `isError false` with `structuredContent.user.email` equal to the seeded email; a bearer `oas_at_nope` is 401 with `WWW-Authenticate` naming `/.well-known/oauth-protected-resource/mcp`; `GET /.well-known/oauth-protected-resource/mcp` returns JSON whose `resource` equals the configured `mcp.resource`. Name the test `TestMCPEndToEnd` with sub-tests; Task 3 extends it with the Journal case.
go -C ../sm-oauthserver-plugin vet ./... && go -C ../sm-oauthserver-plugin test -count=1 -short ./... && go -C ../sm-oauthserver-plugin test -count=1 -run '^TestMCPTokenVerifierSmoke$' -v . 2>&1 | grep -q -- '^--- PASS: TestMCPTokenVerifierSmoke' && (cd ../sm-demo-app && go vet ./... && go test -count=1 -short ./... && go build -tags summercms_mcp ./... && go test -count=1 -tags summercms_mcp -run '^TestMCPEndToEnd$' -v . 2>&1 | grep -q -- '^--- PASS: TestMCPEndToEnd')
non-zero exit, "FAIL" in the output, or either PASS line is absent (a SKIP for a missing Docker daemon counts as absent)
- `grep -c '"backend"' ../sm-oauthserver-plugin/servers.go` prints 1 and the OIDC `opts` line is unchanged (`grep -c "mcpOpts.ScopesSupported" ../sm-oauthserver-plugin/servers.go` prints 1)
- `grep -c "func (v \*MCPTokenVerifier) MCPVerifyToken(\|func (v \*MCPTokenVerifier) MCPResource(" ../sm-oauthserver-plugin/classes/mcp_verifier.go` prints 2 and `grep -c "ClientKindMCP" ../sm-oauthserver-plugin/classes/mcp_verifier.go` prints at least 1
- `grep -c "pact.MCPTokenVerifier" ../sm-oauthserver-plugin/plugin.go` prints at least 1
- `grep -c "not here" ../sm-oauthserver-plugin/README.md` prints 0 and `grep -c "backend" ../sm-oauthserver-plugin/README.md` prints at least 1
- `grep -c "summercms_mcp" ../sm-demo-app/summer.yaml` prints 1; `grep -c "enabled: true" ../sm-demo-app/config/mcp.yaml` prints 1; `grep -c "resource:" ../sm-demo-app/config/golem15.oauthserver.yaml` prints 1
- `head -1 ../sm-demo-app/mcp_e2e_test.go` prints `//go:build summercms_mcp`
- `(cd ../sm-demo-app && go test -count=1 -tags summercms_mcp -run '^TestMCPEndToEnd$' -v .) 2>&1 | grep -q -- '^--- PASS: TestMCPEndToEnd'` on a Docker host
- `(cd ../sm-demo-app && go test -count=1 -short ./...)` passes without the tag (the untagged demo is unchanged apart from the new config files)
The demo, built with the tag, serves /mcp; a real MCP access token from its own authorization server is verified at the resource and the frontend tool runs end to end; the backend scope is advertised.
Task 2: MCP consent JSON endpoints with the linked-admin line, revoked events, and the /connect and /link-admin pages in vue-demo-app
../sm-oauthserver-plugin/routes.go, ../sm-oauthserver-plugin/controllers/mcp_consent_api.go, ../sm-oauthserver-plugin/controllers/authorizations.go, ../sm-oauthserver-plugin/classes/cascade.go, ../sm-oauthserver-plugin/classes/subject_events.go, ../sm-oauthserver-plugin/lang/en/lang.yaml, ../sm-oauthserver-plugin/lang/pl/lang.yaml, ../sm-oauthserver-plugin/mcp_consent_smoke_test.go, ../sm-oauthserver-plugin/README.md, ../sm-demo-app/vue-demo-app/app/pages/connect.vue, ../sm-demo-app/vue-demo-app/app/pages/link-admin.vue, ../sm-demo-app/vue-demo-app/i18n/locales/en.json, ../sm-demo-app/vue-demo-app/i18n/locales/pl.json
- ../sm-oauthserver-plugin/controllers/consent_api.go (ConsentShow, ConsentDecide, principalID, writeJSON) and routes.go 54-76 (the redirect-mode consent block and the MCP block)
- summercms.go/modules/wristband/consent.go 30-120 (PendingRequest, PendingRequestView, IssueCode, DenyPending, ErrNoGrantableScopes, ErrPendingNotFound) and authorize.go 165-180 (the `/connect?request=` redirect)
- ../fonoteka.go/plugins/golem15/fonoteka/controllers/api/oauth_consent_controller.go 1-140 (the MCP consent contract already proven in another application: PendingRequest, submitted ∩ requested, IssueCode, DenyPending)
- ../sm-oauthserver-plugin/controllers/authorizations.go 98-150 (AuthorizationsDestroy, revoke) and classes/cascade.go (OnUserDeleting, OnUserDeactivating, purge)
- summercms.go/modules/pact/mcp.go (MCPLinkedBackendResolver, LinkedBackendUser, MCPSubjectChanged, MCPSubjectRevoked, MCPSubjectDeleted)
- ../sm-demo-app/vue-demo-app/app/pages/login.vue (page shape, useDemoAuth, the `next` redirect rule), app/composables/useDemoAuth.ts (token cookie, login, logout, formErrors), i18n/locales/en.json `auth` block (key style), nuxt.config.ts 85-120 (runtimeConfig and the dev proxy of API paths to Go)
- .planning/phases/19.7-generic-mcp-module/19.7-RESEARCH.md § "Open Question 7", § "Pattern 7" step 2-3, Security Domain row "Consent phishing"
oauthserver consent (P-16): `controllers.MCPConsentShow(app, srv)` and `controllers.MCPConsentDecide(app, srv)` in `mcp_consent_api.go`, mounted inside the `MCPEnabled` block of `Routes` as `r.GroupRaw("/", surf.Use("jwt.auth", authorize), ...)` with `g.Get("/oauth/mcp/requests/{request}", ...)` and `g.Post("/oauth/mcp/requests/{request}", ...)`. Show: `srv.PendingRequest(ctx, id, userID)`; `ErrPendingNotFound` → 404 `request_not_found`; body per P-16 where `backend_admin` is filled from `app.Lookup[pact.MCPLinkedBackendResolver]()` → `LinkedBackendUser(ctx, userID)` only when `backend` ∈ `view.ScopesRequested` and the resolver answers true, else JSON null. Decide: body up to 16 KiB `{decision, scopes}`; granted = (submitted ∩ requested, or requested when `scopes` is absent) minus `backend` when no link; `allow` → `srv.IssueCode(ctx, id, userID, granted, nil)` (`ErrNoGrantableScopes` → 422 `no_grantable_scopes`), else `srv.DenyPending`; answer `{redirect_uri}`; `writeJSON` keeps `Cache-Control: no-store, private`. Revoked events (D-26): `classes/subject_events.go` `FireSubjectChanged(ctx, app, "user", userID, kind)`; call with `pact.MCPSubjectRevoked` from `revoke` (authorizations destroy) and with `pact.MCPSubjectDeleted` from `OnUserDeleting` and `OnUserDeactivating` after the purge. README: the two routes (Routes table and the MCP paragraph), the `backend_admin` field, the events. Lang: none needed server-side (the page translates); add keys only if a server message is introduced. Smoke `TestMCPConsentSmoke` (Postgres): a pending MCP request for `read write backend`: show for a user without a link has `backend_admin: null`; decide allow grants `read write` only (the issued code's scopes exclude backend); with a link (seed through `*userclasses.BackendLinks`.SetLink, the plugin now requires the plan-03 user plugin) show carries the admin's login and name and decide grants `backend` too; deny answers an `error=access_denied` redirect; an unknown request is 404; a user other than the request's owner gets 404; `DELETE /oauth/authorizations/{client_id}` fires a `revoked` event (test listener).
vue-demo-app pages (in `../sm-demo-app/vue-demo-app`): `app/pages/connect.vue` reads `request` from the query; when not `loggedIn` it `navigateTo('/login?next=' + encodeURIComponent('/connect?request=' + request))` (the login page already honours a same-origin `next`); it fetches `GET /oauth/mcp/requests/{request}` with the `Authorization: Bearer` from `useDemoAuth().token`, renders the client name and redirect host, the requested scopes as a list with one explanatory line each (`connect.scope.read`, `.write`, `.ai`, `.offline_access`, `.backend`), and when `backend_admin` is present the line `connect.actAsAdmin` with the admin's name; when `backend` is requested without a link it shows `connect.noLinkedAdmin` (backend access will not be granted); Allow and Deny buttons POST the decision (Allow sends the full requested scope list) and `navigateTo(redirect_uri, { external: true })`; 404/410 show `connect.expired`; `useSeoMeta({ robots: 'noindex' })`. `app/pages/link-admin.vue` reads `code`; `GET /_user/api/v1/backend-link/{code}` → shows `linkAdmin.question` with the admin's name and the expiry; when not logged in, a button to `/login?next=/link-admin?code=...`; when logged in, a Confirm button POSTs `/_user/api/v1/backend-link/confirm` with the bearer; on `409 stale_session` it calls `logout()` and sends the user to `/login?next=...` with the message `linkAdmin.signInAgain` (D-05 fresh sign-in); `already_linked` and 404 show their messages; success shows `linkAdmin.done` with the admin's login; `robots: noindex`. i18n keys under `connect` and `linkAdmin` in en.json and pl.json. `npm --prefix ../sm-demo-app/vue-demo-app run test` (vitest) and `npm --prefix ../sm-demo-app/vue-demo-app run build` must pass; add a vitest case per page only if the demo's existing tests cover pages (otherwise rely on the build and the manual check in Task 5).
go -C ../sm-oauthserver-plugin vet ./... && go -C ../sm-oauthserver-plugin test -count=1 -short ./... && go -C ../sm-oauthserver-plugin test -count=1 -run '^TestMCPConsentSmoke$' -v . 2>&1 | grep -q -- '^--- PASS: TestMCPConsentSmoke' && npm --prefix ../sm-demo-app/vue-demo-app run test && npm --prefix ../sm-demo-app/vue-demo-app run build
non-zero exit, "FAIL" in the Go output, a vitest summary that is not all passing, or a Nuxt build error
- `grep -c "/oauth/mcp/requests/{request}" ../sm-oauthserver-plugin/routes.go` prints 2 and both lines sit inside the `MCPEnabled` block (`awk '/MCPEnabled/,/^\t}/' ../sm-oauthserver-plugin/routes.go | grep -c "mcp/requests"` prints 2)
- `grep -c "func MCPConsentShow(\|func MCPConsentDecide(" ../sm-oauthserver-plugin/controllers/mcp_consent_api.go` prints 2 and `grep -c "backend_admin" ../sm-oauthserver-plugin/controllers/mcp_consent_api.go` prints at least 1
- `grep -c "MCPLinkedBackendResolver" ../sm-oauthserver-plugin/controllers/mcp_consent_api.go` prints at least 1
- `grep -c "FireSubjectChanged(" ../sm-oauthserver-plugin/controllers/authorizations.go ../sm-oauthserver-plugin/classes/cascade.go` prints a non-zero count per file
- `test -f ../sm-demo-app/vue-demo-app/app/pages/connect.vue && test -f ../sm-demo-app/vue-demo-app/app/pages/link-admin.vue`
- `grep -c "oauth/mcp/requests" ../sm-demo-app/vue-demo-app/app/pages/connect.vue` prints at least 2 and `grep -c "backend-link" ../sm-demo-app/vue-demo-app/app/pages/link-admin.vue` prints at least 2
- `grep -c "stale_session" ../sm-demo-app/vue-demo-app/app/pages/link-admin.vue` prints 1 and `grep -c "noindex" ../sm-demo-app/vue-demo-app/app/pages/connect.vue ../sm-demo-app/vue-demo-app/app/pages/link-admin.vue` prints 1 per file
- `grep -c '"connect"' ../sm-demo-app/vue-demo-app/i18n/locales/en.json ../sm-demo-app/vue-demo-app/i18n/locales/pl.json` prints 1 per file and the same for `"linkAdmin"`
- `TestMCPConsentSmoke` prints `--- PASS` on a Docker host
The MCP consent is served as JSON with the linked-admin line and the backend scope is granted only with a link; grants and users that go away fire events; the demo site has the consent and link-proof pages.
Task 3: Journal's backend tools and prompt, the optionalBackendPrincipal fix, and the end-to-end case as the linked admin
../sm-journal-plugin/mcp.go, ../sm-journal-plugin/controllers/api/auth.go, ../sm-journal-plugin/README.md, ../sm-journal-plugin/go.mod, ../sm-journal-plugin/go.sum, ../sm-journal-plugin/mcp_smoke_test.go, ../sm-demo-app/mcp_e2e_test.go, ../sm-demo-app/plugins/golem15/journal, ../sm-demo-app/go.mod, ../sm-demo-app/go.sum
- ../sm-journal-plugin/routes.go (the exact method+pattern of every bind target and the `slug`/`id` Where constraints), controllers/api/auth.go 60-100 (optionalBackendPrincipal, requireBackendPrincipal, permission constants), controllers/api/posts.go (Index query parameters, Store and Update body keys from posts_helpers.go: grep `body["` to list the accepted keys), plugin.go 125-150 (the journal-api bucket keyed by backend principal)
- summercms.go/modules/pact/mcp.go (MCPTool, MCPPrompt, the tag mapping rules in the doc comments) and modules/pier/example_mcp_test.go (the acme.blog example from plan 02)
- .planning/phases/19.7-generic-mcp-module/19.7-RESEARCH.md § "Code Examples: Journal backend tools", § "Pitfall 6" (raw body forwarding; mark optional fields with omitempty or pointers), § "Pattern 6" (the optionalBackendPrincipal fix)
- ../sm-demo-app/mcp_e2e_test.go as left by Task 1; ../sm-demo-app/plugins/golem15/user (the plan-03 plugin: classes.BackendLinks.SetLink for seeding a link in the test)
Journal `mcp.go` (P-17): `(*Plugin) MCP()` declares the seven tools and one prompt. Input structs live in `mcp.go` with `jsonschema` descriptions: list posts `{ Page int `query:"page"`; PerPage int `query:"per_page"`; Search string `query:"search"`; Category string `query:"category"`; Tag string `query:"tag"`; Published *bool `query:"published"`; Sort string `query:"sort"` }` (match the names Index reads); show `{ Slug string `path:"slug"` }`; categories and tags `struct{}`; create `{ Title string; Slug string `json:"slug,omitempty"`; Content string; Excerpt string `json:"excerpt,omitempty"`; Published *bool `json:"published,omitempty"`; Categories []uint `json:"categories,omitempty"`; Tags []string `json:"tags,omitempty"` ... exactly the keys Store accepts }`; update `{ ID uint `path:"id"` plus the create fields all optional (pointers or omitempty, Pitfall 6) }`; delete `{ ID uint `path:"id"` }`. Every tool: `Guard: "backend"`, `Permissions: []string{permAccessPosts}` (export the constant or duplicate the string in mcp.go; do not change auth.go's constants), static Title and Description; delete sets `Destructive` true explicitly. Prompt `draft_post`: arguments `topic` (required), `tone`; `Render` returns one `user` message that asks for a post draft on the topic in the tone, with the site's style notes, and tells the agent to call `journal_create_post` with `published` false; `Guard: "backend"`, `Permissions: [permAccessPosts]`.
auth.go: `optionalBackendPrincipal` drops the `!hasBearer(r)` short-circuit (keep the nil check); `ResolveBackend` already answers `ErrUnauthenticated` for a missing bearer, so anonymous behaviour is identical and a dispatched request sees the marker (D-17). Nothing else in auth.go changes. `go.mod`: require the plan-02 framework tag; `go mod tidy` (the plugin's own go.work replaces the framework with `../summercms.go`). README: Features (the MCP tools and prompt, the guard and permission), a short "MCP tools" section listing the exposed names. Smoke `TestJournalMCPSmoke` (-short, no Docker): `MCP()` lists exactly the seven names and the prompt; every tool's Method+Path matches a route the plugin registers (build a `surf.BuildRouter` with the plugin and compare); `optionalBackendPrincipal` with a request carrying a backend dispatch marker returns a request whose context holds the principal, and with no bearer and no marker returns the request unchanged.
Demo e2e extension (`mcp_e2e_test.go`, Journal submodule moved to the new commit per P-18): seed an admin with `golem15.journal.access_posts` (role or override) and link the frontend user to it through `*userclasses.BackendLinks`.SetLink; mint a token with scopes `read write backend`: `ListTools` now contains `journal_create_post` and `journal_list_posts`; `CallTool("journal_create_post", {title, content, published: false})` answers `isError false` and the post row's author is the admin's id; `CallTool("journal_show_post", {slug})` returns it (a draft is visible to the editor through the marker); a token with `read write` only (no `backend`) lists no `journal_` tool and a call to `journal_create_post` is refused; after `RemoveLink` the next `ListTools` has no `journal_` tool. The unlink-removes-tools and revoke matrix is completed in plan 05; here one unlink case suffices.
go -C ../sm-journal-plugin vet ./... && go -C ../sm-journal-plugin test -count=1 -short ./... && go -C ../sm-journal-plugin test -count=1 -short -run '^TestJournalMCPSmoke$' -v . 2>&1 | grep -q -- '^--- PASS: TestJournalMCPSmoke' && (cd ../sm-demo-app && go test -count=1 -tags summercms_mcp -run '^TestMCPEndToEnd$' -v . 2>&1 | grep -q -- '^--- PASS: TestMCPEndToEnd')
non-zero exit, "FAIL" in the output, or either PASS line is absent (SKIP without Docker counts as absent for TestMCPEndToEnd)
- `grep -c "Name: *\"\(list_posts\|show_post\|list_categories\|list_tags\|create_post\|update_post\|delete_post\|draft_post\)\"" ../sm-journal-plugin/mcp.go` prints 8
- `grep -c "golem15.journal.access_posts\|permAccessPosts" ../sm-journal-plugin/mcp.go` prints at least 8
- `grep -c "hasBearer(r)" ../sm-journal-plugin/controllers/api/auth.go` prints 0 inside optionalBackendPrincipal (`awk '/^func optionalBackendPrincipal/,/^}/' ../sm-journal-plugin/controllers/api/auth.go | grep -c hasBearer` prints 0) while `func hasBearer` still exists
- `git -C ../sm-journal-plugin diff ffa2c8f -- routes.go | wc -l` prints 0 (no route changed)
- `grep -c "git.golem15.com/golem15/summercms " ../sm-journal-plugin/go.mod` prints 1 (substitute the recorded tag)
- `grep -c "journal_create_post" ../sm-demo-app/mcp_e2e_test.go` prints at least 2
- Both named tests print `--- PASS` (the e2e on a Docker host)
Journal exposes its post tools and a prompt to linked admins only, list and show see the dispatched principal, and the demo proves a frontend sign-in with a link and the backend scope creates a post as the admin while unlinking removes the tools.
Task 4: Give the go-ahead for every push of Task 5: tag and push oauthserver and Journal, push vue-demo-app
One go-ahead covering exactly the three pushes Task 5 performs, in three repositories: (1) sm-oauthserver-plugin (backend scope, oas_at_ verifier, MCP consent JSON, revoked events) — `git push origin master --tags` with its new tag; (2) sm-journal-plugin (MCP tools and prompt, optionalBackendPrincipal fix) — `git push origin main --tags` with its new tag; (3) vue-demo-app (the `/connect` consent page, the `/link-admin` proof page, the `connect.*` and `linkAdmin.*` i18n keys from Task 2) — `git -C ../sm-demo-app/vue-demo-app push origin master`, no tag. Both plugins are pinned to the plan-02 framework tag. The demo's three pointer bumps are local commits in sm-demo-app; sm-demo-app itself is neither pushed nor deployed in this plan (both are recorded in deferred-items.md for a separate go-ahead).
Both plugin releases are additive (plan 05's gate proves no removed export since d31f8e7 and ffa2c8f). Proposed versions (P-20): oauthserver v0.1.2, Journal v0.2.3. The demo then pins both tags in two commits (go.mod, go.sum, submodule pointer each) and the pushed vue-demo-app commit in a third. Pre-checks before asking: clean trees in both plugin repos and in `../sm-demo-app/vue-demo-app`, `go vet ./... && go test -count=1 ./...` on Docker in each plugin, `npm --prefix ../sm-demo-app/vue-demo-app run test` and `run build` green, READMEs updated, the demo e2e green with the submodules at the exact commits to be tagged and pushed. The checkpoint message lists the three repositories, their branches and the two versions so the answer names every push (CLAUDE.md: no push, tag or deploy without the user's go-ahead).
Tag oauthserver v0.1.2 and Journal v0.2.3 now and push all three repositories
The demo can pin released versions and a pushed vue-demo-app commit; plan 05's consumers stage runs against tags
A later fix needs patch tags
Hold both tags and the vue-demo-app push
Review the two plugin diffs and the two pages first
The demo keeps pointing at unreleased, unpushed commits until you continue
Answer tag-both (optionally with other version numbers; tag-both covers the vue-demo-app push as well) or hold
Task 5: Release both plugins, pin them in the demo, document nginx and deploy, and hand the demo to a real MCP client
Pushed plugin tags are pinned by the demo and announced; the pushed vue-demo-app commit publishes the consent and link pages; the nginx locations open the MCP paths on the public demo once deployed.
The Task 4 checkpoint answered tag-both (or named versions); `git -C ../sm-oauthserver-plugin status --short`, `git -C ../sm-journal-plugin status --short` and `git -C ../sm-demo-app/vue-demo-app status --short` are empty; `git -C ../sm-demo-app status --short` shows only this plan's files
../sm-oauthserver-plugin/go.mod, ../sm-oauthserver-plugin/go.sum, ../sm-journal-plugin/go.mod, ../sm-journal-plugin/go.sum, ../sm-demo-app/go.mod, ../sm-demo-app/go.sum, ../sm-demo-app/plugins/golem15/oauthserver, ../sm-demo-app/plugins/golem15/journal, ../sm-demo-app/vue-demo-app, ../sm-demo-app/deploy/nginx/demo.summercms.io.conf, ../sm-demo-app/DEPLOY.md, ../sm-demo-app/config/http.yaml, .planning/phases/19.7-generic-mcp-module/deferred-items.md
- ../sm-demo-app/deploy/nginx/demo.summercms.io.conf (the allow-listed Go locations 90-200; copy the `/_demo/` block's proxy settings for the new locations; the `/` fallback to Nuxt)
- ../sm-demo-app/DEPLOY.md § "Overview" 12-50 (which paths reach Go), § "Build" 325-352, § "Release" 353-414, § "Verify", § "Secrets"; ../sm-demo-app/scripts/check-deploy.sh (nginx -t, route checks of deploy/)
- ../sm-demo-app/config/http.yaml (cors.paths: the MCP path needs no CORS entry since pier handles Origin itself; confirm nothing else is required)
- .planning/notes/core-plugins-own-repos.md and CLAUDE.md § "Sibling repositories"
- .planning/phases/19.7-generic-mcp-module/19.7-VALIDATION.md § "Manual-Only Verifications" (the real-client row)
- summercms.go/docs/services/mcp.md § Operations (plan 02)
Releases: in each plugin repo `go.mod` already requires the plan-02 tag (Tasks 1-3); run the pre-checks, write the annotated tag message, `git tag -a ` and `git push origin --tags` (oauthserver master, Journal main). Then `git -C ../sm-demo-app/vue-demo-app push origin master` for the Task 2 commit with the `/connect` and `/link-admin` pages (no tag). These three pushes are exactly the ones the Task 4 go-ahead named; no other repository is pushed by this task. Demo pins, three local commits in sm-demo-app: `chore: bump oauthserver to ` (go.mod require, go.sum, submodule at the tag), `chore: bump journal to `, `chore: bump vue-demo-app (MCP consent and link pages)` (the submodule at the pushed commit). sm-demo-app itself is not pushed and not deployed here; both wait for the user's go-ahead and go to deferred-items.md below. Verify `go build -tags summercms_mcp ./... && go test -count=1 -short ./...` in the demo after each pin.
nginx (`deploy/nginx/demo.summercms.io.conf`): add Go locations `location = /mcp` (proxy with `proxy_buffering off`, `proxy_read_timeout 1h`, `proxy_http_version 1.1`, `chunked_transfer_encoding on` for SSE), `location ^~ /.well-known/oauth-protected-resource`, `location = /.well-known/oauth-authorization-server`, and `location ^~ /oauth/mcp/` (authorize, register, token and the consent JSON), each with the same `proxy_pass` and headers as the existing Go blocks (the ACME location stays first); run `scripts/check-deploy.sh`. DEPLOY.md: a new section "MCP endpoint" after Realtime: what is mounted, the `summercms_mcp` build tag already in `summer.yaml`, the `.env` keys (`SUMMER_MCP__RESOURCE=https://demo.summercms.io/mcp`, `SUMMER_GOLEM15__OAUTHSERVER__MCP__RESOURCE` the same, `SUMMER_MCP__SESSIONS__STORE=memory` with the Redis alternative per P-19), the nginx install step (reuse the "When deploy/nginx/... changed" instructions), how an editor connects (`https://demo.summercms.io/mcp`, OAuth sign-in, `/connect`, linking an admin from My account), and a smoke (`curl -sS https://demo.summercms.io/.well-known/oauth-protected-resource/mcp`). Update the Overview sentence that says `/oauth` and `/.well-known` are not routed to Go. Record the unresolved operational items in `.planning/phases/19.7-generic-mcp-module/deferred-items.md` (framework repo): pushing sm-demo-app's three pointer commits and the deploy itself (each needs the user's go-ahead), and Redis on rome if a second instance is ever added.
Local hand-off for the manual check: build the demo (`summer build` in the demo), start it against the compose Postgres with `.env` values for the resource URLs pointing at `http://127.0.0.1:8097/mcp`, start the Nuxt site (`npm --prefix ../sm-demo-app/vue-demo-app run dev`), seed through `demo:seed`, create a frontend user and an admin with Journal access, and leave both processes running for the human check below. Stop them after the check.
git -C ../sm-oauthserver-plugin describe --tags --exact-match HEAD && git -C ../sm-journal-plugin describe --tags --exact-match HEAD && (cd ../sm-demo-app && bash scripts/check-deploy.sh && go build -tags summercms_mcp ./... && go test -count=1 -short ./... && git diff --quiet HEAD -- go.mod go.sum plugins/golem15/oauthserver plugins/golem15/journal vue-demo-app)
non-zero exit: a plugin HEAD is not tagged, check-deploy reports an nginx or route problem, the demo fails to build or test, or a pin is uncommitted
With the demo and site running locally: add `http://127.0.0.1:8097/mcp` to an MCP client (Claude Desktop or Claude Code), complete the OAuth sign-in on the `/connect` page as the frontend user (requesting `backend`), see only `user_me`; in the admin's My account click "Link frontend account", finish on `/link-admin` with a fresh sign-in, reconnect (new consent shows "also act as admin "), see the `journal_` tools, create a draft post and find it in the admin; unlink and confirm the Journal tools disappear.
- `git -C ../sm-oauthserver-plugin describe --tags --exact-match HEAD` and `git -C ../sm-journal-plugin describe --tags --exact-match HEAD` print the chosen versions and `git ls-remote --tags origin` in each repo lists them
- `grep -c "sm-oauthserver-plugin " ../sm-demo-app/go.mod` prints 1 and `grep -c "sm-journal-plugin " ../sm-demo-app/go.mod` prints 1 (substitute the chosen versions)
- `grep -c "location = /mcp\|oauth-protected-resource\|oauth-authorization-server\|location ^~ /oauth/mcp/" ../sm-demo-app/deploy/nginx/demo.summercms.io.conf` prints at least 4 and `grep -c "proxy_buffering off" ../sm-demo-app/deploy/nginx/demo.summercms.io.conf` prints at least 1
- `grep -c "## MCP endpoint" ../sm-demo-app/DEPLOY.md` prints 1 and `grep -c "SUMMER_MCP__RESOURCE" ../sm-demo-app/DEPLOY.md` prints at least 1
- `(cd ../sm-demo-app && bash scripts/check-deploy.sh)` exits 0
- `test -f .planning/phases/19.7-generic-mcp-module/deferred-items.md`
Both plugins are released and pinned by the demo, the deploy path for the MCP endpoint is documented and checked, and a real MCP client has been connected locally through OAuth, the link and the backend scope.
<artifacts_this_phase_produces>
Artifacts this plan produces
sm-oauthserver-plugin (git.golem15.com/golem15/sm-oauthserver-plugin): classes.MCPTokenVerifier (published as pact.MCPTokenVerifier), controllers.MCPConsentShow, controllers.MCPConsentDecide, classes.FireSubjectChanged; routes GET|POST /oauth/mcp/requests/{request} (jwt.auth, throttle:oauth-authorize); the backend scope in the MCP server's ScopesSupported; consent body field backend_admin; release v0.1.2 (proposed)
sm-journal-plugin (git.golem15.com/golem15/sm-journal-plugin): mcp.go with (*Plugin) MCP(); tools journal_list_posts, journal_show_post, journal_list_categories, journal_list_tags, journal_create_post, journal_update_post, journal_delete_post; prompt journal_draft_post; optionalBackendPrincipal honours the marker; release v0.2.3 (proposed)
sm-demo-app: summer.yaml build.tags: [summercms_mcp]; config/mcp.yaml, config/golem15.oauthserver.yaml; regenerated plugins.gen.go, main.go; mcp_e2e_test.go (TestMCPEndToEnd, tagged); nginx locations /mcp, /.well-known/oauth-protected-resource*, /.well-known/oauth-authorization-server, /oauth/mcp/; DEPLOY.md "MCP endpoint"; pointer bumps for oauthserver, journal, vue-demo-app
vue-demo-app: pages /connect (app/pages/connect.vue) and /link-admin (app/pages/link-admin.vue); i18n keys connect.*, linkAdmin.* (en, pl)
Env keys documented: SUMMER_MCP__RESOURCE, SUMMER_GOLEM15__OAUTHSERVER__MCP__RESOURCE, SUMMER_MCP__SESSIONS__STORE, SUMMER_REDIS__URL
</artifacts_this_phase_produces>
<threat_model>
Trust Boundaries
| Boundary | Description |
|---|---|
| MCP client to the authorization server | DCR clients request scopes including backend; tokens are minted and later presented at /mcp |
| browser to the consent and link pages | the signed-in frontend user's decisions and the one-shot link code |
| pier to the oauthserver verifier | every /mcp request's bearer is judged here |
| internet to nginx to Go | the MCP paths become public on the demo |
STRIDE Threat Register
| Threat ID | Category | Component | Severity | Disposition | Mitigation Plan |
|---|---|---|---|---|---|
| T-19.7-30 | Spoofing | audience confusion at the verifier | high | mitigate | Only oas_at_ tokens pass the prefix gate; the row's client must exist with kind = mcp and not be revoked; an OIDC token or a foreign-kind client's token is ErrMCPTokenInvalid (TestMCPTokenVerifierSmoke) |
| T-19.7-31 | Elevation | consent phishing for the backend scope | high | mitigate | The consent page shows client name, redirect host and the "also act as admin " line only with a verified link; backend is granted only when a link exists at consent (A8); the scope is visible and revocable per grant (TestMCPConsentSmoke) |
| T-19.7-32 | Elevation | consent decided for another user's request | medium | mitigate | PendingRequest/IssueCode/DenyPending resolve the request for the acting JWT principal only (lookupOwnedPending); a foreign user gets 404; decisions are POST behind jwt.auth with no-store answers |
| T-19.7-33 | Elevation | submitted scopes beyond the request | medium | mitigate | granted = submitted ∩ requested (∩ the allow-list wristband already applied), minus backend without a link; an empty grant is 422 no_grantable_scopes |
| T-19.7-34 | Spoofing | superuser reach through an agent (D-22) | high | mitigate | The backend principal is the admin's real principal (superuser included) by decision; the D-20 ceiling and backend scope cap it; every call is audited with admin_id and client_id; plan 05's security review weighs an optional superuser refusal switch and records the verdict |
| T-19.7-35 | Information Disclosure | revoked grant keeps a live session | medium | mitigate | AuthorizationsDestroy and the user cascade fire revoked/deleted events that end sessions on every instance; the verifier refuses the revoked token on the very next request regardless |
| T-19.7-36 | Tampering | partial update tools zeroing fields | medium | mitigate | Update input fields are pointers or omitempty; pier forwards the agent's raw JSON minus path keys, so Journal's key-presence checks see only sent keys (Pitfall 6) |
| T-19.7-37 | Denial of Service | public /mcp and SSE through nginx |
medium | mitigate | mcp.throttle inline limiter, idle TTL and per-binding cap in pier; nginx proxy_read_timeout bounded; only the listed MCP paths are opened |
| T-19.7-38 | Spoofing | open redirect from the consent page | low | mitigate | The page navigates only to the redirect_uri the server returns from IssueCode/DenyPending, which wristband built from the client's registered URI; the next parameter stays same-origin as on the login page |
| </threat_model> |
<success_criteria>
- SC-4 is demonstrated end to end in the demo by
TestMCPEndToEndand by the real-client check: one OAuth sign-in, a verified link, the backend scope, Journal tools as the admin, removal on unlink - oauthserver and Journal diffs against d31f8e7 and ffa2c8f remove no route, export, scope or payload field
- The demo without the tag or with
mcp.enabledfalse behaves as before - Planner decisions P-16..P-20 are implemented as written and named in the SUMMARY </success_criteria>