wegene-get-profiles
Retrieve all genetic profiles associated with your WeGene account to analyze and manage your DNA report data using OAuth and API integration.
Instructions
Retrieve all the profiles under the current account
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"properties": {},
"type": "object"
}
Implementation Reference
- Core handler function that retrieves user profiles from the WeGene API using the stored access token, parses the response into Profile objects, constructs a success message listing the profiles, or returns an error if token missing or API fails.async def wegene_get_profiles() -> tuple[list[TextContent], list[Profile] | None]: # Get access token from Redis access_token = redis_db.get('wegene_access_token') if not access_token: return [ TextContent( type="text", text="Error: No valid user access token. Please use wegene-oauth tool first." ) ], None # Make API request to get profiles try: headers = { "Authorization": f"Bearer {access_token.decode('utf-8')}" } async with httpx.AsyncClient() as client: response = await client.get( "https://api.wegene.com/user/", headers=headers ) response.raise_for_status() # Parse response and create new profiles list data = response.json() new_profiles = [ Profile( name=profile["name"], gender=str(profile["sex"]), profile_id=profile["id"] ) for profile in data["profiles"] ] profile_info = "\n".join( f"Profile {i+1}: ID={profile.profile_id}, Name={profile.name}" for i, profile in enumerate(new_profiles) ) return [ TextContent( type="text", text=f"Successfully retrieved {len(new_profiles)} profiles(s):\n{profile_info}" ) ], new_profiles except httpx.HTTPStatusError as e: return [ TextContent( type="text", text=f"Error: Failed to get profile {str(e)}" ) ], None
- src/wegene_assistant/server.py:147-154 (registration)Tool registration in list_tools(), including name, description, and empty input schema.types.Tool( name="wegene-get-profiles", description="Retrieve all the profiles under the current account", inputSchema={ "type": "object", "properties": {} }, ),
- src/wegene_assistant/server.py:228-234 (handler)Dispatch handler in call_tool() that invokes wegene_get_profiles(), updates global profiles list if new profiles found, notifies session of resource changes, and returns the result.elif name == "wegene-get-profiles": result, new_profiles = await wegene_get_profiles() if new_profiles: profiles.clear() profiles.extend(new_profiles) await server.request_context.session.send_resource_list_changed() return result
- Input schema definition for the tool (no required properties).inputSchema={ "type": "object", "properties": {} }, ),