Skip to content

Instantly share code, notes, and snippets.

@EngincanV
Created April 9, 2025 09:58
Show Gist options
  • Save EngincanV/3cdc9cfdc1fa1ee7b99e7c5b02f58b8b to your computer and use it in GitHub Desktop.
Save EngincanV/3cdc9cfdc1fa1ee7b99e7c5b02f58b8b to your computer and use it in GitHub Desktop.
[McpServerToolType]
public static class TimeTools
{
[McpServerTool, Description("Gets the current time")]
public static string GetCurrentTime()
{
return DateTimeOffset.Now.ToString();
}
[McpServerTool, Description("Gets time in specific timezone")]
public static string GetTimeInTimezone(string timezone)
{
try
{
var tz = TimeZoneInfo.FindSystemTimeZoneById(timezone);
return TimeZoneInfo.ConvertTime(DateTimeOffset.Now, tz).ToString();
}
catch
{
return "Invalid timezone specified";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment