busy-spoon-35253
05/02/2026, 2:38 PMtall-airline-16756
05/02/2026, 2:38 PMtall-airline-16756
05/02/2026, 2:38 PMbusy-spoon-35253
05/02/2026, 2:40 PMtall-airline-16756
05/02/2026, 2:41 PMbusy-spoon-35253
05/02/2026, 2:42 PMtall-airline-16756
05/02/2026, 2:42 PMbusy-spoon-35253
05/02/2026, 2:44 PMtall-airline-16756
05/02/2026, 2:44 PMAuthorization: Bearer <CALENDLY_API_KEY> when calling Calendly.
• Require JWT or API-key authentication for the MCP server itself if it’s reachable externally.
• Limit exposed tools with allowed_tools or toolset-level filtering when you connect to the agent.
4) Implement tool behavior & resilience
• Use idempotency for create-event calls (prevent double-booking) — include a client-generated idempotency key in metadata when calling Calendly.
• Validate and normalize timezones; accept ISO 8601 times and convert to organizer timezone before booking.
• Implement retries with exponential backoff for network calls and surface clear errors for rate-limit responses.
5) Connect MCP to your LiveKit agent
• Use MCPServerHTTP (or MCPServerStdio if running locally) to connect the Composio MCP server to your agent.
• Pass authentication headers in headers when constructing the MCP connection.
• Optionally filter tools with allowed_tools or toolset.filter_tools() to expose only scheduling-related tools.
6) Expose Calendly as a function tool fallback (optional)
• In addition to MCP, implement a local @function_tool wrapper that can call your MCP endpoints or Calendly directly. This is useful for testing or when MCP is unreachable.
• Ensure the same input/output schema so the agent logic stays consistent.
7) Agent orchestration and post-booking actions
• Agent calls the availability tool → shows options to user → agent calls create-event tool.
• On success, agent should:
◦ Create a LiveKit room (call LiveKit server API) and generate a join link/token.
◦ Add the LiveKit join link and event details to the Calendly event (if Calendly supports custom invitee notes) or send a follow-up email/calendar invite.
◦ Persist mapping: event_id_ ↔️ _LiveKit_room_id for later lookups (e.g., on join or cancellation hooks).
• Subscribe to Calendly webhooks (event.created, canceled) and forward webhook payloads to your MCP server or agent session so the agent can react to changes.
8) Webhooks & synchronization
• Configure Calendly webhooks to notify your MCP server or an internal webhook endpoint.
• On webhook receive:
◦ Verify signature/auth.
◦ Update your internal store and notify the LiveKit agent (via a tool call or event) to update the session state or resend links.
Code sketch (conceptual)
• Implement MCP tools that wrap Calendly HTTP calls (pseudo):
Tool: check_availability
Input: {organizer_id, start_iso, end_iso, duration, timezone}
Output: {available_slots: [{start_iso,end_iso}], errors}
Tool: create_event
Input: {organizer_id, slot_start_iso, invitee:{name,email}, metadata, idempotency_key}
Output: {success, event_id, start_iso, end_iso, join_url}
• Connect to agent:
◦ mcp = MCPServerHTTP(url="https://your-mcp", headers={"Authorization":"Bearer <MCP_KEY>"})
◦ agent = Agent(tools=[MCPToolset(mcp), local_function_tools...])
Testing checklist
• Unit test tool wrappers (mock Calendly API).
• Integration test flow: availability → create_event → webhook event.created → LiveKit room created.
• Test timezone edge cases and idempotency.
What I can provide next
• A runnable example of a @function_tool in Python that calls Calendly and returns the standardized JSON.
• A sample MCP tool descriptor and minimal MCP server endpoint for one operation (create_event).
• Example agent wiring showing MCPServerHTTP + MCPToolset usage.
Which of the three next items would you like first: runnable function-tool code, MCP endpoint example, or agent wiring sample?
, with interactive elements