m
hi
t
Thanks for reaching out, Rahib. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'd love to help you out! Could you please share a bit more about your question or the issue you're experiencing? That way, I can make sure to assist you in the best possible way.
m
When a call is made to the agent in telephony, i want to call an MCP server basically the notion MCP and the call should not be picked until that is resolved. How do i do that ? Is it possible? I am using self hosting. If you have any question let me know
t
I’m happy to help you with delaying SIP call pickup until MCP resolution in your self-hosted LiveKit setup. A good approach is to use a pre-call MCP resolution pattern, where you run your MCP logic before creating a SIP participant. This way, you only initiate the call (using
CreateSIPParticipant
) after the MCP process is successfully resolved, ensuring that no telephony connection is established until MCP gives the green light. For inbound calls, LiveKit creates the SIP participant right away when it receives an INVITE. Although it’s not possible to delay the SIP ANSWER, you can accept the call, perform the MCP check, and then terminate the call if the MCP denies it. Could you please share a bit more about whether you’re working with inbound or outbound calls? Also, is the MCP check mainly for authorization, routing, or data enrichment? Knowing this will really help me guide you with the best implementation approach. Sources: SIP & Telephony Integration | livekit/livekit_composite | DeepWiki | SIP Integration | livekit/livekit_composite | DeepWiki | cmd/lk/sip.go | Docs::Telephony | Integrating with Telephony | LiveKit Docs
m
Yeah so basically i am wortking with the inbound calls and I do understand that it will just pick it up and we cant delay it. SO if that is the case how do I do it ?
t
I’m glad you reached out about handling inbound calls! Since LiveKit creates the SIP participant right away when it gets an INVITE, here’s a friendly step-by-step way to manage this smoothly: 1. First, accept the inbound call so the SIP participant gets created. 2. Next, immediately run your MCP logic to check things like authorization or routing. 3. If the MCP check doesn’t pass, you can gracefully end the call by removing the SIP participant or deleting the room. To give you a clearer picture, here’s an example flow you might find helpful:
Copy code
async def on_inbound_call(room: Room):
    # Identify the SIP participant
    sip_participant = next(p for p in room.participants.values() if p.identity.startswith("sip_"))

    # Run MCP check
    auth_result = await mcp_client.check_authorization(sip_participant.metadata)

    if not auth_result.allowed:
        # Remove the participant or delete the room
        await room.remove_participant(sip_participant)
        # Or delete the entire room if needed
This way, the call is dropped quickly if the MCP check fails, helping to avoid any unnecessary media flow. If you’d like, I’m here to help you with implementing this or answer any questions you have!
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!
m
How do i dynamically set tools when using MCP. I only want to allow certain tools at certain times of my MCP