feat: expose password generator as an MCP server (remote + stdio)#1
Merged
Conversation
Add a Model Context Protocol server alongside the existing REST API, sharing a single generation core. Two tools: generate_password and list_charset_presets. - lib/password-core.ts: transport-agnostic generatePasswords/listPresets with typed errors and bounds; the REST route becomes a thin adapter - lib/mcp-server.ts: createServer() registering both tools - mcp/stdio.ts: local stdio entry point - routes/mcp.ts: remote Streamable HTTP endpoint (stateless, JSON mode) - lib/mcp-sdk.ts: centralizes the SDK's @deno-types workaround for the broken exports types wildcard - vite.config.ts: ssr.external for the SDK so dev SSR can load it - main.ts: exempt /mcp from the page-oriented CSP Also: - fix: use Fresh 2's ctx.req in /api/generate (it was relying on a Request/Context .url coincidence); the unit-test mock now passes a Context so it genuinely guards the signature - test: add e2e suite (e2e/) exercising stdio, prod-build, and vite-dev /mcp over real MCP clients; split `deno task test` (unit) from `deno task test:e2e` - ci: add GitHub Actions workflow (check+unit and e2e jobs) - docs: README "MCP server" section for both transports Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
vite's dev server is slow/flaky to start in a headless CI runner (it timed out reporting its port within 30s), while CI already validates the deployment artifact via the prod-build and stdio e2e tests plus the `vite build` step. The dev test's real purpose is guarding `ssr.external` during local development, so it now runs everywhere except CI. Also: the server helper now includes the child's recent output in its timeout error and allows 60s, so a slow/failed startup is debuggable. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
What
Exposes the password generator as a Model Context Protocol server alongside the existing REST API, sharing one generation core. Two tools:
generate_passwordandlist_charset_presets, available over both transports.Changes
lib/password-core.ts— transport-agnosticgeneratePasswords/listPresetswith typed errors + bounds. The REST route is now a thin adapter over it.lib/mcp-server.ts(createServer()),mcp/stdio.ts(local stdio),routes/mcp.ts(remote Streamable HTTP, stateless + JSON mode).lib/mcp-sdk.tscentralizes the@deno-typesworkaround for the SDK's brokenexportstypes wildcard;vite.config.tsaddsssr.externalso dev SSR can load the SDK;main.tsexempts/mcpfrom the page CSP./api/generatenow uses Fresh 2'sctx.req(was relying on aRequest/Context.urlcoincidence). The unit-test mock now passes aContext, so it genuinely guards the signature.e2e/suite exercising stdio, prod-build, and vite-dev/mcpover real MCP clients.deno task test(unit) anddeno task test:e2e(build + e2e) are now separate.check + unitande2ejobs.Verification
deno task checkclean · 60 unit tests · 3 e2e tests (11 steps) · live REST + MCP checked against a realdeno serve.ssr.externaland pass with it.🤖 Generated with Claude Code