getAuthenticatedUser
Retrieve current user context including ID, username, team, and roles for personalized API requests.
Instructions
Gets information about the authenticated user. Use this to get current user context (user.id, username, teamId, roles) for 'my ...' requests.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- tools/postman_tools.py:74-92 (handler)The GetAuthenticatedUserTool class is the handler for 'getAuthenticatedUser'. It extends ToolHandler and implements run_tool() which calls POSTMAN API GET /me and returns the result as JSON.
class GetAuthenticatedUserTool(ToolHandler): """Get authenticated user information""" def __init__(self): super().__init__("getAuthenticatedUser") def get_tool_description(self) -> Tool: return Tool( name=self.name, description="Gets information about the authenticated user. Use this to get current user context (user.id, username, teamId, roles) for 'my ...' requests.", inputSchema={ "type": "object", "properties": {}, }, ) async def run_tool(self, args: dict) -> list[TextContent]: result = await postman_api_call("GET", "/me") return [TextContent(type="text", text=json.dumps(result, indent=2))] - tools/postman_tools.py:80-88 (schema)The inputSchema for 'getAuthenticatedUser' is defined in get_tool_description(). It requires no parameters (empty properties object), as it simply returns info about the authenticated user.
def get_tool_description(self) -> Tool: return Tool( name=self.name, description="Gets information about the authenticated user. Use this to get current user context (user.id, username, teamId, roles) for 'my ...' requests.", inputSchema={ "type": "object", "properties": {}, }, ) - tools/postman_tools.py:1831-1835 (registration)The tool is registered in the register_all_tools() function by instantiating GetAuthenticatedUserTool() and including it in the returned list of handlers.
def register_all_tools() -> list[ToolHandler]: """Register all Postman tool handlers""" return [ # User Info GetAuthenticatedUserTool(), - tools/postman_tools.py:21-67 (helper)The postman_api_call helper function is called by the handler to make the GET /me API request to Postman API.
async def postman_api_call( method: str, endpoint: str, body: dict | None = None, params: dict | None = None, headers: dict | None = None ) -> dict: """Make an API call to Postman API""" if not POSTMAN_API_KEY: raise RuntimeError("POSTMAN_API_KEY environment variable is not set") url = f"{POSTMAN_BASE_URL}{endpoint}" # Prepare headers request_headers = { "X-Api-Key": POSTMAN_API_KEY, "Content-Type": "application/json", } if headers: request_headers.update(headers) async with httpx.AsyncClient(timeout=30.0) as client: try: response = await client.request( method=method, url=url, json=body, params=params, headers=request_headers ) response.raise_for_status() if response.status_code == 204: return {"success": True, "message": "Operation completed successfully"} return response.json() if response.content else {"success": True} except httpx.HTTPStatusError as e: error_detail = e.response.text try: error_json = e.response.json() error_detail = json.dumps(error_json, indent=2) except: pass raise RuntimeError(f"Postman API error ({e.response.status_code}): {error_detail}") except Exception as e: raise RuntimeError(f"Request failed: {str(e)}") - tools/toolhandler.py:9-24 (helper)The ToolHandler base class (ABC) that GetAuthenticatedUserTool extends. It requires implementing get_tool_description() and run_tool().
class ToolHandler(ABC): """Base class for all Postman tool handlers""" def __init__(self, name: str): self.name = name @abstractmethod def get_tool_description(self) -> Tool: """Return the MCP Tool description for this handler""" pass @abstractmethod async def run_tool(self, arguments: dict) -> list[TextContent | ImageContent | EmbeddedResource]: """Execute the tool with the given arguments""" pass