Skip to main content
Glama
jaipandya

product-hunt-mcp

by jaipandya

get_viewer

Retrieve details of the currently authenticated user on the MCP server, verifying token validity and returning user data or error information.

Instructions

Retrieve information about the currently authenticated user. Parameters: - None Returns: - success (bool) - data (dict): If successful, contains user details. - error (dict, optional) - rate_limits (dict) Notes: - Returns an error if the token is invalid or expired.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function for the 'get_viewer' tool. Fetches the current authenticated user's information via GraphQL VIEWER_QUERY, handles errors, and formats the response.
    @mcp.tool() @require_token @handle_errors def get_viewer() -> Dict[str, Any]: """ Retrieve information about the currently authenticated user. Parameters: - None Returns: - success (bool) - data (dict): If successful, contains user details. - error (dict, optional) - rate_limits (dict) Notes: - Returns an error if the token is invalid or expired. """ logger.info("users.get_viewer called") result, rate_limits, error = execute_graphql_query(VIEWER_QUERY) if error: return format_response(False, error=error, rate_limits=rate_limits) # Check if viewer info exists viewer_exists = check_data_exists(result["data"], "viewer") if not viewer_exists: return format_response( False, error={ "code": "AUTHENTICATION_ERROR", "message": "Unable to get viewer information. Token may be invalid or expired.", }, rate_limits=rate_limits, ) # Extract viewer data viewer_data = result["data"]["viewer"] # Check if the user field exists for nested viewer structure if "user" in viewer_data and viewer_data["user"] is not None: viewer_data = viewer_data["user"] return format_response(True, data=viewer_data, rate_limits=rate_limits)
  • Entry point registration call for user tools, including 'get_viewer', in the main MCP server CLI.
    register_user_tools(mcp)
  • Imports the register_user_tools function used to register the 'get_viewer' tool.
    from product_hunt_mcp.tools.users import register_user_tools

Other Tools

Related Tools

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/jaipandya/producthunt-mcp-server'

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