Skip to content

Handle shutdown and exit lifecycle methods per MCP spec #14

@jserv

Description

@jserv

Summary

shutdown and exit are not matched in the dispatch loop and fall through to METHOD_NOT_FOUND (-32601), violating the MCP spec.

Details

  • shutdown (request with id): MCP spec requires the server to respond {} then stop accepting new requests. Currently returns -32601.
  • exit (notification): MCP spec requires unconditional process exit. Currently silently ignored.
  • notifications/cancelled is already handled (silently dropped, correct per JSON-RPC). The in-progress scan is not aborted, which is acceptable for sync transport where scans are <500ms.
  • Fix: add "shutdown" arm returning {} then break the serve loop; add "exit" arm calling process::exit(0). Apply to both sync and async transports.
  • Gate: E2E test verifies shutdown{} + clean exit; exit → process terminates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    architectureArchitectural improvements

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions