Skip to content

Conversation

yeoyujie
Copy link

Motivation and Context

Previously, the port could only be set during the initialization of the server. By allowing the port to be passed directly to run(), developers can now override the listening port at runtime. This change aligns with the ergonomics of popular Python web frameworks, enhancing the developer experience.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • [] I have added appropriate error handling
  • I have added or updated documentation as needed

@ihrpr
Copy link
Contributor

ihrpr commented Jul 10, 2025

Thank you for the contribution!

The port can already be modified at runtime before calling run():

  mcp = FastMCP("My Server")
  mcp.settings.port = 9000  # not a very nice way, but it works
  mcp.run(transport="sse")

The Settings class is mutable (not frozen). Thile adding it as a parameter is a cleaner approach, it adds complexity and might lead to the confusion which parameter to use.

@ihrpr ihrpr closed this Jul 10, 2025
gspencergoog pushed a commit to gspencergoog/mcp-python-sdk that referenced this pull request Jul 29, 2025
…delcontextprotocol#997)

* Backport changes to `lifecycle.mdx` from `2025-06-18` to `draft`.

In the PR releasing a new revision of the spec (modelcontextprotocol#783), commit e547813
changed a `SHOULD` to `MUST` in Lifecycle Operation section, but the
change was not backported to the draft file.

This PR backports the change avoiding potential regressions.

* Update docs/specification/draft/changelog.mdx

---------

Co-authored-by: Jonathan Hefner <[email protected]>
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.

2 participants