Skip to main content
Glama
batteryshark

System Information MCP Server

by batteryshark

get_user_environment

Retrieve user session details, timezone, and language settings to diagnose environment-specific issues and localization problems.

Instructions

Get user session and locale information - current user, timezone, language.

User context including session details, timezone, and system language settings. Important for environment-specific troubleshooting and localization issues.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The primary handler function for the get_user_environment tool. It is registered via the @mcp.tool decorator and orchestrates the collection of user environment data by calling helper functions get_user_session_info() and get_time_locale_info(), then formats and returns the result as ToolResult.
    @mcp.tool def get_user_environment() -> ToolResult: """Get user session and locale information - current user, timezone, language. User context including session details, timezone, and system language settings. Important for environment-specific troubleshooting and localization issues. """ info_sections = [] info_sections.append("# User Environment") info_sections.append(f"*Generated: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}*\n") try: info_sections.extend(get_user_session_info()) info_sections.extend(get_time_locale_info()) except Exception as e: info_sections.append(f"⚠️ **Environment detection error**: {str(e)}") return text_response("\n".join(info_sections))
  • Supporting helper function that collects current user details: username, full name (platform-specific), and approximate session start time using psutil.
    def get_user_session_info() -> List[str]: """Get current user and session information""" info = [] info.append("\n## 👤 User & Session") # Current user current_user = getpass.getuser() info.append(f"- **Current User**: {current_user}") # Try to get full name full_name = _get_user_full_name(current_user) if full_name: info.append(f"- **Full Name**: {full_name}") # Session info try: current_process = psutil.Process() login_time = datetime.fromtimestamp(current_process.create_time()) info.append(f"- **Session Start**: {login_time.strftime('%Y-%m-%d %H:%M:%S')}") except Exception: pass return info
  • Supporting helper function that gathers time-related information: current time, timezone name, UTC offset, and system locale/language settings.
    def get_time_locale_info() -> List[str]: """Get time, timezone, and locale information""" info = [] info.append("\n## 🕐 Time & Locale") now = datetime.now() info.append(f"- **Current Time**: {now.strftime('%Y-%m-%d %H:%M:%S')}") # Timezone try: timezone_name = time.tzname[0] if not time.daylight else time.tzname[1] info.append(f"- **Timezone**: {timezone_name}") # UTC offset utc_offset = time.timezone if not time.daylight else time.altzone offset_hours = -utc_offset // 3600 offset_sign = '+' if offset_hours >= 0 else '-' info.append(f"- **UTC Offset**: UTC{offset_sign}{abs(offset_hours):02d}:00") except Exception: pass # System language/locale try: system_locale = locale.getdefaultlocale() if system_locale[0]: info.append(f"- **System Language**: {system_locale[0]}") if system_locale[1]: info.append(f"- **Encoding**: {system_locale[1]}") except Exception: pass return info

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/batteryshark/mcp-sysinfo'

If you have feedback or need assistance with the MCP directory API, please join our Discord server