from mcp.server.fastmcp import FastMCP
import getpass
# Initialize the MCP server
mcp = FastMCP("WhoAmI")
# Define a tool to fetch the current system username
@mcp.tool()
def whoami() -> str:
"""Returns the username of the current system user as my identity."""
try:
# Get the current system username using getpass.getuser()
username = getpass.getuser()
# Return a simple dictionary with the username
return username
except Exception as e:
# Handle any unexpected errors (e.g., environment issues)
return {"error": f"Failed to fetch username: {str(e)}"}
# Start the server
if __name__ == "__main__":
mcp.run()
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/kukapay/whoami-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server