Skip to content

Add hardened seconv MCP stdio server - #110

Draft
Blackspirits wants to merge 1 commit into
fix/seconv-cancellation-serialization-c77cfrom
feature/seconv-mcp-hardened-c77c
Draft

Add hardened seconv MCP stdio server#110
Blackspirits wants to merge 1 commit into
fix/seconv-cancellation-serialization-c77cfrom
feature/seconv-mcp-hardened-c77c

Conversation

@Blackspirits

@Blackspirits Blackspirits commented Sep 14, 2026

Copy link
Copy Markdown
Owner

Purpose

Current-base audited port of upstream PR SubtitleEdit#14129 (seconv mcp), stacked on draft #109.

The original PR was based on adbc446a... and is now more than 1,000 upstream commits behind. Its MCP surface still maps cleanly onto current seconv, but a literal port would miss important long-lived-server concerns and would overstate parity with the much-expanded current CLI.

What this PR adds

  • seconv mcp stdio server using ModelContextProtocol 2.2.0;
  • current Microsoft.Extensions.Hosting 10.0.12;
  • tools:
    • list_formats
    • subtitle_info
    • read_subtitle
    • lint_subtitle
    • convert_subtitle
    • list_fix_common_errors_rules
    • list_remove_formatting_rules
  • stdout reserved for MCP JSON-RPC; incidental console/log output goes to stderr;
  • CLI help, --help-json, README and current command-line reference updated.

Hardening vs. SubtitleEdit#14129

  • builds on Make seconv conversion cancellation-aware and serialize global state #109 so conversion has a real cooperative cancellation contract and process-global conversion state is serialized;
  • MCP CancellationToken is accepted explicitly and is therefore bound by the SDK without appearing in tool input schemas;
  • all MCP calls are serialized inside the server while libse/seconv still depend on process-wide settings;
  • caller cancellation is rethrown, not converted into an ordinary tool error;
  • completed write operations are not retroactively reported as cancelled;
  • read/list tools explicitly advertise ReadOnly=true, Destructive=false, Idempotent=true, OpenWorld=false;
  • convert_subtitle explicitly advertises ReadOnly=false, Destructive=true, Idempotent=false, OpenWorld=false;
  • known client validation errors remain actionable; unexpected internal exceptions are logged to stderr and return a generic tool error instead of leaking raw exception details/paths;
  • missing-file errors expose only the file name, not the full local directory;
  • documentation no longer falsely claims every subcommand accepts --json;
  • the MCP conversion surface is documented as a focused subset of the current CLI rather than claiming complete option parity.

Filesystem boundary

The server operates on explicit local filesystem paths and does not add a second sandbox. Access remains limited by the OS permissions of the seconv process and by the MCP client's own approval/sandbox policy. MCP roots were considered, but roots are deprecated in the 2026-07-28 protocol revision, so this port does not build a security contract on that retiring mechanism.

Tests

The original functional coverage is retained and extended to verify:

  • real stdio server startup and tool calls;
  • tool annotations returned by tools/list;
  • CancellationToken is absent from generated input schemas;
  • pre-cancelled conversion throws and writes nothing;
  • missing-file errors do not expose the test directory;
  • conversion/offset and rule-selection behavior still use the shared seconv core.

Stack / validation

  • base: draft Make seconv conversion cancellation-aware and serialize global state #109, HEAD f83e30793665214f054f411feb0c2254b8b68d8a
  • this branch is exactly one commit ahead of that base
  • HEAD: 946a7f00f19a91fcd4303a224ff169d4b771b75e
  • full solution restore passed
  • full solution build passed
  • full solution test suite passed on the first run
  • SeConvTests: 498 passed, 2 skipped, 0 failed (500 total)
  • LibUiLogicTests: 873 passed, 0 skipped, 0 failed
  • LibSETests: 2,008 passed, 0 skipped, 0 failed
  • UITests: 5,151 passed, 9 skipped, 0 failed (5,160 total)
  • retry step was not used
  • validation run: #34795072886
  • audit draft only; no merge/promotion intended

AI assistance: ChatGPT was used to audit and port the stale MCP proposal, reconcile it with current seconv behavior, and add cancellation, concurrency, metadata and error-boundary hardening.

@Blackspirits
Blackspirits force-pushed the feature/seconv-mcp-hardened-c77c branch from 7a691fc to dbca266 Compare September 14, 2026 01:10
@Blackspirits
Blackspirits force-pushed the feature/seconv-mcp-hardened-c77c branch from dbca266 to 946a7f0 Compare September 14, 2026 01:10

@Blackspirits Blackspirits left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent adversarial re-check: this branch is exactly one MCP/docs/tests commit on the final #109 cancellation/concurrency base. The stdio transport uses Console.OpenStandardOutput directly, so redirecting incidental Console.Out writes to stderr does not corrupt JSON-RPC. Pre-dispatch bootstrap/HarfBuzz initialization does not write stdout. Client-visible tools/list annotations, cancellation-token schema exclusion, sanitized missing-file errors, cancellation-before-write and an end-to-end stdio tool call are covered by tests. Full CI #34795072886 passed restore, build and the complete suite on the first run; SeConvTests reported 498 passed, 2 skipped, 0 failed and UITests 5,151 passed, 9 skipped, 0 failed. Retry was not used. No blocker identified. Keep draft; no merge performed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant