modelcontextprotocol / modelcontextprotocol/python-sdk

Support clean server shutdown

Open
#1,739 1 comment 2 reactions 1 assignee View on GitHub

@felixweinberger is already working on this.

Since Jan 15, 2026.

enhancement P1 v2
Dominant language
Python
Stars
24.3k
Forks
4k
Avg merge
1d 1h
Merged PRs (30d)
31

Description

Summary

Provide a reliable way to cleanly shut down a running MCP server, ensuring all resources are properly released.

Motivation

  • Currently there's no clean way to stop a running server programmatically
  • Resources (connections, tasks, file handles) may not be properly cleaned up on shutdown
  • Important for testing, graceful restarts, and production deployments

Goal

  • API for triggering graceful shutdown
  • Proper cleanup of all active sessions and transports
  • Configurable shutdown timeout / drain period

AI Disclaimer

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.