Fix CST timezone ambiguity error in get_local_tz function #2097
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixed "No time zone found with key CST" error in the
get_local_tz
function. Enhanced timezone handling logic to intelligently identify ambiguous timezone abbreviations (like CST) and added mapping for common timezone abbreviations to IANA timezone names.Server Details
Motivation and Context
CST is an ambiguous timezone abbreviation that can represent multiple different timezones:
When the system returns "CST" as the timezone name, directly using
ZoneInfo("CST")
throws a "No time zone found with key CST" error because CST is not a valid IANA timezone identifier.This fix resolves the issue by:
How Has This Been Tested?
Breaking Changes
No breaking changes. This is a backward-compatible bug fix that does not require users to update their MCP client configurations.
Types of changes
Checklist
https://modelcontextprotocol.io
Additional context
Implementation Details
Design Decisions
This fix addresses a real user pain point, especially for users on Chinese systems or US Central timezone.