MCP Tools
Learn how to create MCP (Model Context Protocol) tools using the Meeting BaaS SDK functions.
Creating MCP Tools with the SDK
The Meeting BaaS SDK v5.0.0 provides a clean approach for creating MCP tools by using the SDK functions directly within your tool handlers. This gives you full control over tool schemas, descriptions, and registration.
Basic MCP Tool Creation
Here's how to create MCP tools using the SDK:
import { type JoinRequest, createBaasClient } from "@meeting-baas/sdk"
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"
import { z } from "zod"
// Create an MCP server
const server = new McpServer({
name: "meeting-baas-server",
version: "1.0.0"
})
// Define the input schema for the join meeting tool
const joinToolInputSchema = {
bot_name: z.string().default("Meeting BaaS Bot"),
meeting_url: z.string(),
reserved: z.boolean().default(false)
}
// Register the join meeting tool
server.registerTool(
"joinMeeting",
{
title: "Send a Meeting BaaS bot to a meeting",
description:
"Send a Meeting BaaS bot to a Google Meet/Teams/Zoom meeting to automatically record and transcribe the meeting with speech diarization",
inputSchema: joinToolInputSchema
},
async (args) => {
const client = createBaasClient({
api_key: "your-api-key"
})
const { success, data, error } = await client.joinMeeting(args as JoinRequest)
if (success) {
return {
content: [{ type: "text", text: `Successfully joined meeting: ${JSON.stringify(data)}` }]
}
}
return {
content: [{ type: "text", text: `Failed to join meeting: ${error}` }]
}
}
)Multiple Tools Example
Here's how to create multiple MCP tools:
import {
type JoinRequest,
type GetMeetingDataParams,
type LeaveRequest,
createBaasClient
} from "@meeting-baas/sdk"
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"
import { z } from "zod"
const server = new McpServer({
name: "meeting-baas-server",
version: "1.0.0"
})
// Join Meeting Tool
server.registerTool(
"joinMeeting",
{
title: "Send a Meeting BaaS bot to a meeting",
description: "Send a Meeting BaaS bot to a meeting to record and transcribe",
inputSchema: {
bot_name: z.string().default("Meeting BaaS Bot"),
meeting_url: z.string(),
reserved: z.boolean().default(false)
}
},
async (args) => {
const client = createBaasClient({ api_key: "your-api-key" })
const { success, data, error } = await client.joinMeeting(args as JoinRequest)
if (success) {
return {
content: [{ type: "text", text: `Bot joined successfully with ID: ${data.bot_id}` }]
}
}
return {
content: [{ type: "text", text: `Failed to join meeting: ${error}` }]
}
}
)
// Get Meeting Data Tool
server.registerTool(
"getMeetingData",
{
title: "Get meeting recording and metadata",
description: "Retrieve meeting data including transcripts and recording URL",
inputSchema: {
bot_id: z.string(),
include_transcripts: z.boolean().default(true)
}
},
async (args) => {
const client = createBaasClient({ api_key: "your-api-key" })
const { success, data, error } = await client.getMeetingData(args as GetMeetingDataParams)
if (success) {
return {
content: [{
type: "text",
text: `Meeting data retrieved: Duration: ${data.duration}s, MP4: ${data.mp4 || 'Not available'}`
}]
}
}
return {
content: [{ type: "text", text: `Failed to get meeting data: ${error}` }]
}
}
)
// Leave Meeting Tool
server.registerTool(
"leaveMeeting",
{
title: "Have a bot leave a meeting",
description: "Make a bot leave the meeting it's currently in",
inputSchema: {
uuid: z.string()
}
},
async (args) => {
const client = createBaasClient({ api_key: "your-api-key" })
const { success, data, error } = await client.leaveMeeting(args as LeaveRequest)
if (success) {
return {
content: [{ type: "text", text: `Bot left meeting successfully: ${data.bot_id}` }]
}
}
return {
content: [{ type: "text", text: `Failed to leave meeting: ${error}` }]
}
}
)Calendar Tools Example
Here's how to create calendar-related MCP tools:
import {
type CreateCalendarParams,
type ListCalendarEventsParams,
createBaasClient
} from "@meeting-baas/sdk"
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"
import { z } from "zod"
const server = new McpServer({
name: "meeting-baas-calendar-server",
version: "1.0.0"
})
// Create Calendar Tool
server.registerTool(
"createCalendar",
{
title: "Create a calendar integration",
description: "Integrate a new calendar with Meeting BaaS using OAuth credentials",
inputSchema: {
oauth_client_id: z.string(),
oauth_client_secret: z.string(),
oauth_refresh_token: z.string(),
platform: z.enum(["Google", "Microsoft"]),
raw_calendar_id: z.string().optional()
}
},
async (args) => {
const client = createBaasClient({ api_key: "your-api-key" })
const { success, data, error } = await client.createCalendar(args as CreateCalendarParams)
if (success) {
return {
content: [{
type: "text",
text: `Calendar created successfully: ${data.calendar.name} (${data.calendar.uuid})`
}]
}
}
return {
content: [{ type: "text", text: `Failed to create calendar: ${error}` }]
}
}
)
// List Calendar Events Tool
server.registerTool(
"listCalendarEvents",
{
title: "List calendar events",
description: "Get a list of events from a specific calendar",
inputSchema: {
calendar_id: z.string(),
start_date_gte: z.string().optional(),
start_date_lte: z.string().optional(),
status: z.enum(["upcoming", "past", "all"]).default("upcoming")
}
},
async (args) => {
const client = createBaasClient({ api_key: "your-api-key" })
const { success, data, error } = await client.listCalendarEvents(args as ListCalendarEventsParams)
if (success) {
const eventCount = data.events.length
return {
content: [{
type: "text",
text: `Found ${eventCount} events in calendar. Next cursor: ${data.next || 'None'}`
}]
}
}
return {
content: [{ type: "text", text: `Failed to list events: ${error}` }]
}
}
)Error Handling Best Practices
When creating MCP tools, it's important to handle errors gracefully:
server.registerTool(
"joinMeeting",
{
title: "Join Meeting",
description: "Join a meeting with a bot",
inputSchema: {
meeting_url: z.string(),
bot_name: z.string().default("Meeting BaaS Bot")
}
},
async (args) => {
try {
const client = createBaasClient({ api_key: "your-api-key" })
const { success, data, error } = await client.joinMeeting(args)
if (success) {
return {
content: [{
type: "text",
text: `Successfully joined meeting. Bot ID: ${data.bot_id}`
}]
}
} else {
// Handle API errors
if (error instanceof z.ZodError) {
return {
content: [{
type: "text",
text: `Validation error: ${error.errors.map(e => e.message).join(', ')}`
}]
}
}
return {
content: [{
type: "text",
text: `API error: ${error.message}`
}]
}
}
} catch (unexpectedError) {
// Handle unexpected errors
return {
content: [{
type: "text",
text: `Unexpected error: ${unexpectedError}`
}]
}
}
}
)Available SDK Methods for MCP Tools
You can create MCP tools for any of these SDK methods:
Bot Management
joinMeeting- Have a bot join a meetingleaveMeeting- Have a bot leave a meetinggetMeetingData- Get meeting recording and metadatadeleteBotData- Delete bot datalistBots- List bots with metadataretranscribeBot- Retranscribe bot recordingsgetScreenshots- Get bot screenshots
Calendar Management
createCalendar- Create a calendar integrationlistCalendars- List all calendarsgetCalendar- Get calendar detailsupdateCalendar- Update calendar credentialsdeleteCalendar- Delete a calendargetCalendarEvent- Get event detailsscheduleCalendarRecordEvent- Schedule recording for an eventunscheduleCalendarRecordEvent- Unschedule recordingpatchBot- Update scheduled bot configurationlistCalendarEvents- List calendar eventsresyncAllCalendars- Resync all calendarslistRawCalendars- List raw calendars from provider
Webhooks
getWebhookDocumentation- Get webhook documentationgetBotWebhookDocumentation- Get bot webhook documentationgetCalendarWebhookDocumentation- Get calendar webhook documentation
Benefits of This Approach
- Full Control: You have complete control over tool schemas and descriptions
- Type Safety: Full TypeScript support with generated types
- Flexibility: Customize error handling and responses
- Consistency: Use the same SDK functions across your application
- Maintainability: Easy to update when the SDK changes