Skip to content

Feature request: make stdio shutdown grace periods configurable in CommandTransport.Close() #322

@cruffinoni

Description

@cruffinoni

Is your feature request related to a problem? Please describe.
CommandTransport.Close() currently hardcodes a 5s wait after closing stdin before escalating. This follows the MCP spec's "reasonable time" requirement, but the fixed value leads to noticeable delays (e.g., when testing with processes like sleep that never exit quickly).

Describe the solution you'd like
Make this timeout configurable via a TermGrace time.Duration field on CommandTransport. Default should remain 5 * time.Second to preserve current behavior.

Describe alternatives you've considered

  • Keeping the hardcoded 5s wait (current behavior) — but this hurts short-lived or test scenarios.
  • Manually killing the process from outside — works, but breaks the intended MCP shutdown sequence.

Additional context
The MCP spec requires a shutdown sequence of closing stdin → waiting a reasonable time → sending SIGTERM, but does not prescribe exact durations. Making TermGrace configurable would keep spec compliance while offering flexibility for different environments and use cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions