wegene-get-profiles
Retrieve all genetic testing profiles associated with your WeGene account to access and manage your DNA analysis data.
Instructions
Retrieve all the profiles under the current account
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The main handler function that fetches profiles from WeGene API using the access token stored in Redis, creates Profile objects, and returns a TextContent response along with the profiles list or an error message.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
- Tool schema definition including name, description, and empty input schema (no parameters required).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 (registration)Tool registration and dispatch in the call_tool handler: calls the wegene_get_profiles function, updates the global profiles list, sends resource list changed notification, 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