how to build on the MCP starter example so I can g...
# ask-ai
g
how to build on the MCP starter example so I can get the user who is calling the agent. Can that be gotten from JobContext?
t
Thanks for reaching out, Zachary. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To build on the MCP starter example and retrieve the user who is calling the agent, you can utilize the JobContext. Here are some approaches: • Accessing job metadata: You can retrieve user-specific data from the job metadata. For example:
Copy code
metadata = json.loads(ctx.job.metadata)
user_name = metadata["user_name"]
Using participant attributes: Once the user is connected, you can access participant attributes to get relevant details. For example:
call_status = participant.attributes.get("sip.callStatus")
Sending user-specific data: Ensure that user-specific data is sent in the job metadata, room metadata, or participant attributes. This data can then be used to identify the user. • Loading additional user information: Optionally, you can load more user details from your own database based on the identifier retrieved. These methods should help you extend the MCP starter example to identify the user calling the agent. Sources: Handling RAG Delays in Voice Agents | LiveKit Docs | Making calls using SIP | LiveKit Docs