Skip to content

feat: Align with MCP Python SDK best practices#11

Merged
alaturqua merged 2 commits intomainfrom
sdk-alignment-improvements
Dec 1, 2025
Merged

feat: Align with MCP Python SDK best practices#11
alaturqua merged 2 commits intomainfrom
sdk-alignment-improvements

Conversation

@alaturqua
Copy link
Owner

Summary

This PR aligns the project with MCP Python SDK best practices based on analysis of the official SDK repository.

Changes

server.py

  • FastMCP now initialized with \host, \port, \stateless_http=True, \json_response=True\
  • Configuration via \MCP_HOST/\MCP_PORT\ environment variables with defaults (127.0.0.1:8000)
  • Transport handling uses \mcp.settings\ for dynamic configuration updates

Dockerfile

  • Added \MCP_HOST=0.0.0.0\ and \MCP_PORT=8000\ environment variables
  • Simplified CMD (removed redundant --host/--port args)

docker-compose.yml

  • Services now use environment variables instead of CLI arguments
  • Cleaner, more maintainable configuration

SDK Best Practices Applied

  • Settings-based configuration over CLI arguments
  • Environment variable support for containerized deployments
  • \stateless_http=True\ for better HTTP transport behavior
  • \json_response=True\ for consistent response formatting

- FastMCP initialization with host/port from environment variables
- Add stateless_http=True and json_response=True for production
- Use MCP_HOST/MCP_PORT env vars instead of CLI args
- Simplify docker-compose.yml to use environment variables
- Update Dockerfile with default MCP_HOST=0.0.0.0, MCP_PORT=8000
Copilot AI review requested due to automatic review settings December 1, 2025 00:40
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR modernizes the MCP Trino server configuration to align with MCP Python SDK best practices, introducing environment variable-based configuration and settings-driven transport handling.

Key changes:

  • Introduced environment variable configuration (MCP_HOST, MCP_PORT) with sensible defaults
  • Replaced CLI argument passing to mcp.run() with mcp.settings updates
  • Simplified Docker and docker-compose configurations by removing redundant CLI arguments

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/server.py Added environment variable support for host/port, updated FastMCP initialization with stateless_http and json_response settings, refactored transport handling to use mcp.settings
docker-compose.yml Simplified service commands by removing --host and --port arguments, added MCP_HOST and MCP_PORT environment variables
Dockerfile Added default MCP_HOST and MCP_PORT environment variables, updated comment to reflect simplified command pattern

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@alaturqua alaturqua merged commit a498cbf into main Dec 1, 2025
1 of 2 checks passed
@alaturqua alaturqua deleted the sdk-alignment-improvements branch December 1, 2025 00:42
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