peppa/openspec/changes/archive/2026-11-12-pep-8-remote-mcp/design.md
Асель 39367b1d82 PEP-8: remote MCP for ChatGPT with Peppa as OAuth 2.1 server
- OAuth: RFC 8414/9728 metadata, RFC 7591 dynamic registration,
  authorization code + PKCE S256 with a consent screen after Gitea login,
  refresh token rotation; tokens and codes stored hashed; revoke in web
- /mcp: stateless Streamable HTTP, Bearer → user; PM tools from
  @peppa/mcp/manager: projects, goals, tasks, create, move (board
  semantics, starts agents), inbox, answer/accept — owner-scoped
- login keeps ?next= through Gitea OAuth; Settings page with MCP URL and
  connected apps
- 5 new tests (53 e2e total, green); verified on prod as a client:
  DCR → consent → token → MCP over HTTPS → revoke → 401
- OpenSpec: pep-8 archived into spec remote-mcp

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 21:38:09 +05:00

22 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Design: PEP-8
## Decisions
1. **Пеппа — свой сервер авторизации** (не Gitea): ChatGPT нужен DCR, а токен должен
ограничиваться проектами пользователя Пеппы. Вход пользователя — существующая cookie
(Gitea OAuth), затем согласие.
2. **Непрозрачные токены** (32 байта, base64url), в БД — HMAC-хэш; без JWT: проверка
всё равно ходит в БД (отзыв).
3. **MCP stateless**: на каждый POST — новый `McpServer` + `WebStandardStreamableHTTPServerTransport`
с `enableJsonResponse`; пользователь берётся из токена. Инструменты PM — модуль
`@peppa/mcp/manager`, тонкие обёртки над core/runner (`moveTask`, `acceptTask`,
`answerAndDeliver`) с `projectForUser`.
4. **Redirect URI** при регистрации — только https или http://localhost/127.0.0.1;
при авторизации — точное совпадение с зарегистрированным.
## Risks / Trade-offs
- [Широкий доступ одного токена ко всем проектам пользователя] → согласие явно говорит
об этом; отзыв в вебе.
- [Спам регистраций DCR] → клиенты без токенов дешёвые; чистка неиспользуемых позже.