box_who_am_i
Retrieve current user details and verify connection status through the MCP Server Box, enabling secure interaction with Box API for file and folder operations.
Instructions
Get the current user's information. This is also useful to check the connection status.
return: dict: The current user's information.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"properties": {},
"title": "box_who_am_iArguments",
"type": "object"
}
Implementation Reference
- src/tools/box_tools_generic.py:28-39 (handler)The main handler function that executes the 'box_who_am_i' tool logic by retrieving the Box client and fetching the current user's information via the Box API.async def box_who_am_i(ctx: Context) -> dict: """ Get the current user's information. This is also useful to check the connection status. return: dict: The current user's information. """ box_client = get_box_client(ctx) return box_client.users.get_user_me().to_dict() # return f"Authenticated as: {current_user.name}"
- src/tool_registry/generic_tools.py:9-12 (registration)The registration function that adds the 'box_who_am_i' tool to the MCP server using the @mcp.tool() decorator.def register_generic_tools(mcp: FastMCP): mcp.tool()(box_who_am_i) mcp.tool()(box_authorize_app_tool)
- src/tools/box_tools_generic.py:9-26 (helper)Helper utility function used by the handler to obtain the appropriate BoxClient instance from the MCP context, supporting both OAuth and CCG authentication modes.def get_box_client(ctx: Context) -> BoxClient: """Helper function to get Box client from context. This works for both OAuth and CCG modes: - OAuth mode: Creates a client from the Bearer token in the request - CCG mode: Returns the pre-initialized client """ box_context = cast(BoxContext, ctx.request_context.lifespan_context) # For OAuth mode, we need the request to extract the token if box_context.client is None: # Store the request in the context if not already there if box_context.request is None and ctx.request_context.request is not None: box_context.request = ctx.request_context.request # Use the new get_active_client() method which handles both modes return box_context.get_active_client()