feat(mcp): add explicit fj mcp stdio subcommand #65

Merged
Claude-Run merged 1 commit from feat/FJ-50-mcp-stdio-subcommand into main 2026-07-03 13:41:14 +02:00
Member

Add a Stdio(ServeArgs) variant to McpSubcommand so an MCP client can select the stdio transport by subcommand, mirroring yt mcp stdio, instead of relying on FORGEJO_MCP_TRANSPORT being unset. It reuses ServeArgs, so the write-policy flags (--allow-edit, --allow-delete, --allow-global-write, and their FORGEJO_MCP_ALLOW_* env equivalents) apply identically to stdio.

In fj-mcp, factor the stdio path out of serve into a new serve_stdio(policy, host_override) entry point that builds the server and serves over stdio directly, never consulting http_transport_selected(). serve is unchanged: it still defaults to stdio and still selects HTTP on FORGEJO_MCP_TRANSPORT=http, so the deployed fj mcp service systemd unit keeps working. Shared setup (tracing init, server build, stdio serve loop) is extracted into init_server/run_stdio helpers.

Document fj mcp stdio in the README as the preferred explicit form for MCP-client configs, noting serve without FORGEJO_MCP_TRANSPORT remains equivalent for backward compatibility. Add clap parse tests guarding that mcp exposes serve, stdio, and service, and that stdio accepts the write-policy flags.

#FJ-50

Add a `Stdio(ServeArgs)` variant to `McpSubcommand` so an MCP client can select the stdio transport by subcommand, mirroring `yt mcp stdio`, instead of relying on `FORGEJO_MCP_TRANSPORT` being unset. It reuses `ServeArgs`, so the write-policy flags (`--allow-edit`, `--allow-delete`, `--allow-global-write`, and their `FORGEJO_MCP_ALLOW_*` env equivalents) apply identically to stdio. In `fj-mcp`, factor the stdio path out of `serve` into a new `serve_stdio(policy, host_override)` entry point that builds the server and serves over stdio directly, never consulting `http_transport_selected()`. `serve` is unchanged: it still defaults to stdio and still selects HTTP on `FORGEJO_MCP_TRANSPORT=http`, so the deployed `fj mcp service` systemd unit keeps working. Shared setup (tracing init, server build, stdio serve loop) is extracted into `init_server`/`run_stdio` helpers. Document `fj mcp stdio` in the README as the preferred explicit form for MCP-client configs, noting `serve` without `FORGEJO_MCP_TRANSPORT` remains equivalent for backward compatibility. Add clap parse tests guarding that `mcp` exposes `serve`, `stdio`, and `service`, and that `stdio` accepts the write-policy flags. #FJ-50
feat(mcp): add explicit fj mcp stdio subcommand
All checks were successful
Check / fmt + clippy + build + tests (pull_request) Successful in 1m0s
Create release / Create release from merged PR (pull_request) Has been skipped
ba384e6c9e
Add a `Stdio(ServeArgs)` variant to `McpSubcommand` so an MCP client can select the stdio transport by subcommand, mirroring `yt mcp stdio`, instead of relying on `FORGEJO_MCP_TRANSPORT` being unset. It reuses `ServeArgs`, so the write-policy flags (`--allow-edit`, `--allow-delete`, `--allow-global-write`, and their `FORGEJO_MCP_ALLOW_*` env equivalents) apply identically to stdio.

In `fj-mcp`, factor the stdio path out of `serve` into a new `serve_stdio(policy, host_override)` entry point that builds the server and serves over stdio directly, never consulting `http_transport_selected()`. `serve` is unchanged: it still defaults to stdio and still selects HTTP on `FORGEJO_MCP_TRANSPORT=http`, so the deployed `fj mcp service` systemd unit keeps working. Shared setup (tracing init, server build, stdio serve loop) is extracted into `init_server`/`run_stdio` helpers.

Document `fj mcp stdio` in the README as the preferred explicit form for MCP-client configs, noting `serve` without `FORGEJO_MCP_TRANSPORT` remains equivalent for backward compatibility. Add clap parse tests guarding that `mcp` exposes `serve`, `stdio`, and `service`, and that `stdio` accepts the write-policy flags.

#FJ-50
Claude-Run deleted branch feat/FJ-50-mcp-stdio-subcommand 2026-07-03 13:41:14 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
pandoras-box/forgejo-cli!65
No description provided.