|
| 1 | +--- |
| 2 | +title: Vapi MCP Server |
| 3 | +subtitle: 'Integrate Vapi APIs with AI assistants through the Model Context Protocol (MCP)' |
| 4 | +slug: sdk/mcp-server |
| 5 | +--- |
| 6 | + |
| 7 | +The Vapi Model Context Protocol (MCP) server allows you to integrate with Vapi APIs through tool calling. This enables AI assistants like Claude to directly communicate with Vapi's services, making it possible to manage assistants, phone numbers, and create calls directly through conversational interfaces. |
| 8 | + |
| 9 | +<Note> |
| 10 | + Looking to use MCP tools with your assistants? See the [MCP Tool documentation](/tools/mcp) for integrating external MCP servers with your Vapi assistants. |
| 11 | +</Note> |
| 12 | + |
| 13 | +## What is Vapi MCP Server? |
| 14 | + |
| 15 | +Vapi MCP Server is an implementation of the Model Context Protocol that exposes Vapi's APIs as callable tools. This allows any MCP-compatible client (like Claude Desktop or custom applications using the MCP SDK) to access Vapi functionality, including: |
| 16 | + |
| 17 | +- Listing, creating, and managing Vapi assistants |
| 18 | +- Managing phone numbers |
| 19 | +- Creating and scheduling outbound calls |
| 20 | +- Retrieving call details and status |
| 21 | + |
| 22 | +## Supported Actions |
| 23 | + |
| 24 | +The Vapi MCP Server provides the following tools for integration: |
| 25 | + |
| 26 | +### Assistant Tools |
| 27 | +- `list_assistants`: Lists all Vapi assistants |
| 28 | +- `create_assistant`: Creates a new Vapi assistant |
| 29 | +- `get_assistant`: Gets a Vapi assistant by ID |
| 30 | + |
| 31 | +### Call Tools |
| 32 | +- `list_calls`: Lists all Vapi calls |
| 33 | +- `create_call`: Creates an outbound call |
| 34 | +- `get_call`: Gets details of a specific call |
| 35 | + |
| 36 | +> **Note:** The `create_call` action supports scheduling calls for immediate execution or for a future time using the optional `scheduledAt` parameter. |
| 37 | +
|
| 38 | +### Phone Number Tools |
| 39 | +- `list_phone_numbers`: Lists all Vapi phone numbers |
| 40 | +- `get_phone_number`: Gets details of a specific phone number |
| 41 | + |
| 42 | +## Setup Options |
| 43 | + |
| 44 | +There are two primary ways to connect to the Vapi MCP Server: |
| 45 | + |
| 46 | +1. **Local Setup**: Run the MCP server locally for development or testing |
| 47 | +2. **Remote SSE Connection**: Connect to Vapi's hosted MCP server via Server-Sent Events (SSE) |
| 48 | + |
| 49 | +## Claude Desktop Setup |
| 50 | + |
| 51 | +The easiest way to get started with Vapi MCP Server is through Claude Desktop. This allows you to interact with Vapi services directly through conversations with Claude. |
| 52 | + |
| 53 | +### Prerequisites |
| 54 | +- Claude Desktop application installed |
| 55 | +- Vapi API key (get it from the [Vapi dashboard](https://dashboard.vapi.ai/org/api-keys)) |
| 56 | + |
| 57 | +### Configuration Steps |
| 58 | + |
| 59 | +1. Open Claude Desktop and press `CMD + ,` (Mac) to go to `Settings` |
| 60 | +2. Click on the `Developer` tab |
| 61 | +3. Click on the `Edit Config` button |
| 62 | +4. This will open the `claude_desktop_config.json` file in your file explorer |
| 63 | +5. Add the following configuration to the file: |
| 64 | + |
| 65 | +```json |
| 66 | +{ |
| 67 | + "mcpServers": { |
| 68 | + "vapi-mcp-server": { |
| 69 | + "command": "npx", |
| 70 | + "args": [ |
| 71 | + "-y", |
| 72 | + "@vapi-ai/mcp-server" |
| 73 | + ], |
| 74 | + "env": { |
| 75 | + "VAPI_TOKEN": "<your_vapi_token>" |
| 76 | + } |
| 77 | + } |
| 78 | + } |
| 79 | +} |
| 80 | +``` |
| 81 | + |
| 82 | +6. Replace `<your_vapi_token>` with your actual Vapi API key |
| 83 | +7. Save the file and restart Claude Desktop |
| 84 | + |
| 85 | +### Example Usage with Claude Desktop |
| 86 | + |
| 87 | +After configuring Claude Desktop with the Vapi MCP server, you can ask Claude to help with Vapi-related tasks. |
| 88 | + |
| 89 | +#### Example 1: Request an immediate call |
| 90 | + |
| 91 | +``` |
| 92 | +I'd like to speak with my appointment scheduling assistant. Can you have it call me at +1234567890? |
| 93 | +``` |
| 94 | + |
| 95 | +#### Example 2: Schedule a future call |
| 96 | + |
| 97 | +``` |
| 98 | +I need to schedule a call with my customer service assistant for next Tuesday at 3:00 PM. My phone number is +1555123456. |
| 99 | +``` |
| 100 | + |
| 101 | +#### Example 3: Manage assistants |
| 102 | + |
| 103 | +``` |
| 104 | +Can you list all my Vapi assistants and help me create a new one for appointment scheduling? |
| 105 | +``` |
| 106 | + |
| 107 | +## Remote SSE Connection |
| 108 | + |
| 109 | +For production use or if you prefer not to run a local server, you can connect to Vapi's hosted MCP server via Server-Sent Events (SSE) Transport. |
| 110 | + |
| 111 | +### Connection Details |
| 112 | + |
| 113 | +- SSE Endpoint: `https://mcp.vapi.ai/sse` |
| 114 | +- Authentication: Include your Vapi API key as a bearer token in the request headers |
| 115 | + - Example header: `Authorization: Bearer your_vapi_api_key_here` |
| 116 | + |
| 117 | +This connection allows you to access Vapi's functionality remotely without running a local server. |
| 118 | + |
| 119 | +## Custom MCP Client Integration |
| 120 | + |
| 121 | +If you're building a custom application that needs to communicate with Vapi, you can use any MCP-compatible client SDK. |
| 122 | + |
| 123 | +### Available SDKs |
| 124 | + |
| 125 | +The Model Context Protocol supports clients in multiple languages: |
| 126 | + |
| 127 | +- [TypeScript SDK](https://github.com/modelcontextprotocol/typescript-sdk) |
| 128 | +- [Python SDK](https://github.com/modelcontextprotocol/python-sdk) |
| 129 | +- [Java SDK](https://github.com/modelcontextprotocol/java-sdk) |
| 130 | +- [Kotlin SDK](https://github.com/modelcontextprotocol/kotlin-sdk) |
| 131 | +- [C# SDK](https://github.com/modelcontextprotocol/csharp-sdk) |
| 132 | + |
| 133 | +### Integration Steps |
| 134 | + |
| 135 | +1. Install the MCP client SDK for your language of choice |
| 136 | +2. Configure the client to connect to the Vapi MCP Server (either locally or via SSE) |
| 137 | +3. Query the server for available tools |
| 138 | +4. Use the tools in your application logic |
| 139 | + |
| 140 | +Here's an example using the Node.js SDK with SSE transport: |
| 141 | + |
| 142 | +```javascript |
| 143 | +#!/usr/bin/env node |
| 144 | +import { Client } from '@modelcontextprotocol/sdk/client/index.js'; |
| 145 | +import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js'; |
| 146 | +import dotenv from 'dotenv'; |
| 147 | + |
| 148 | +// Load environment variables from .env file |
| 149 | +dotenv.config(); |
| 150 | + |
| 151 | +// Ensure API key is available |
| 152 | +if (!process.env.VAPI_TOKEN) { |
| 153 | + console.error('Error: VAPI_TOKEN environment variable is required'); |
| 154 | + process.exit(1); |
| 155 | +} |
| 156 | + |
| 157 | +async function main() { |
| 158 | + try { |
| 159 | + // Initialize MCP client |
| 160 | + const mcpClient = new Client({ |
| 161 | + name: 'vapi-client-example', |
| 162 | + version: '1.0.0', |
| 163 | + }); |
| 164 | + |
| 165 | + // Create SSE transport for connection to remote Vapi MCP server |
| 166 | + const transport = new SSEClientTransport({ |
| 167 | + url: 'https://mcp.vapi.ai/sse', |
| 168 | + headers: { |
| 169 | + 'Authorization': `Bearer ${process.env.VAPI_TOKEN}` |
| 170 | + } |
| 171 | + }); |
| 172 | + |
| 173 | + console.log('Connecting to Vapi MCP server via SSE...'); |
| 174 | + await mcpClient.connect(transport); |
| 175 | + console.log('Connected successfully'); |
| 176 | + |
| 177 | + try { |
| 178 | + // List available tools |
| 179 | + const toolsResult = await mcpClient.listTools(); |
| 180 | + console.log('Available tools:'); |
| 181 | + toolsResult.tools.forEach((tool) => { |
| 182 | + console.log(`- ${tool.name}: ${tool.description}`); |
| 183 | + }); |
| 184 | + |
| 185 | + // List assistants |
| 186 | + console.log('\nListing assistants...'); |
| 187 | + const assistantsResponse = await mcpClient.callTool({ |
| 188 | + name: 'list_assistants', |
| 189 | + arguments: {}, |
| 190 | + }); |
| 191 | + |
| 192 | + const assistants = assistantsResponse.content; |
| 193 | + if (!(Array.isArray(assistants) && assistants.length > 0)) { |
| 194 | + console.log('No assistants found. Please create an assistant in the Vapi dashboard first.'); |
| 195 | + return; |
| 196 | + } |
| 197 | + |
| 198 | + console.log('Your assistants:'); |
| 199 | + assistants.forEach((assistant) => { |
| 200 | + console.log(`- ${assistant.name} (${assistant.id})`); |
| 201 | + }); |
| 202 | + |
| 203 | + // List phone numbers |
| 204 | + console.log('\nListing phone numbers...'); |
| 205 | + const phoneNumbersResponse = await mcpClient.callTool({ |
| 206 | + name: 'list_phone_numbers', |
| 207 | + arguments: {}, |
| 208 | + }); |
| 209 | + |
| 210 | + const phoneNumbers = phoneNumbersResponse.content; |
| 211 | + if (!(Array.isArray(phoneNumbers) && phoneNumbers.length > 0)) { |
| 212 | + console.log('No phone numbers found. Please add a phone number in the Vapi dashboard first.'); |
| 213 | + return; |
| 214 | + } |
| 215 | + |
| 216 | + console.log('Your phone numbers:'); |
| 217 | + phoneNumbers.forEach((phoneNumber) => { |
| 218 | + console.log(`- ${phoneNumber.phoneNumber} (${phoneNumber.id})`); |
| 219 | + }); |
| 220 | + |
| 221 | + // Create a call using the first assistant and first phone number |
| 222 | + const phoneNumberId = phoneNumbers[0].id; |
| 223 | + const assistantId = assistants[0].id; |
| 224 | + |
| 225 | + console.log(`\nCreating a call using assistant (${assistantId}) and phone number (${phoneNumberId})...`); |
| 226 | + const createCallResponse = await mcpClient.callTool({ |
| 227 | + name: 'create_call', |
| 228 | + arguments: { |
| 229 | + assistantId: assistantId, |
| 230 | + phoneNumberId: phoneNumberId, |
| 231 | + customer: { |
| 232 | + phoneNumber: "+1234567890" // Replace with actual customer phone number |
| 233 | + } |
| 234 | + // Optional: schedule a call for the future |
| 235 | + // scheduledAt: "2025-04-15T15:30:00Z" |
| 236 | + }, |
| 237 | + }); |
| 238 | + |
| 239 | + console.log('Call created:', JSON.stringify(createCallResponse.content, null, 2)); |
| 240 | + } finally { |
| 241 | + console.log('\nDisconnecting from server...'); |
| 242 | + await mcpClient.close(); |
| 243 | + console.log('Disconnected'); |
| 244 | + } |
| 245 | + } catch (error) { |
| 246 | + console.error('Error:', error); |
| 247 | + process.exit(1); |
| 248 | + } |
| 249 | +} |
| 250 | + |
| 251 | +main(); |
| 252 | +``` |
| 253 | + |
| 254 | +This code shows how to: |
| 255 | +- Connect to the Vapi MCP Server using SSE transport |
| 256 | +- List available tools |
| 257 | +- List your existing assistants |
| 258 | +- List your phone numbers |
| 259 | +- Create an outbound call using your first assistant and phone number |
| 260 | + |
| 261 | +You can run this code by saving it as a script and executing it with Node.js: |
| 262 | + |
| 263 | +```bash |
| 264 | +# Install required packages |
| 265 | +npm install @modelcontextprotocol/sdk dotenv |
| 266 | + |
| 267 | +# Create a .env file with your Vapi API token |
| 268 | +echo "VAPI_TOKEN=your_vapi_api_token_here" > .env |
| 269 | + |
| 270 | +# Run the script |
| 271 | +node vapi-client.js |
| 272 | +``` |
| 273 | + |
| 274 | +For more detailed examples and complete client implementations, refer to the [MCP Client Quickstart](https://modelcontextprotocol.io/quickstart/client). |
| 275 | + |
| 276 | +## References |
| 277 | + |
| 278 | +- [Vapi MCP Server Repository](https://github.com/VapiAI/mcp-server) |
| 279 | +- [Model Context Protocol Documentation](https://modelcontextprotocol.io) |
| 280 | +- [Vapi Dashboard](https://dashboard.vapi.ai) |
| 281 | +- [Model Context Protocol Client Quickstart](https://modelcontextprotocol.io/quickstart/client) |
| 282 | + |
| 283 | +<CardGroup cols={2}> |
| 284 | + <Card |
| 285 | + title="Need Help?" |
| 286 | + icon="question-circle" |
| 287 | + href="https://discord.gg/pUFNcf2WmH" |
| 288 | + > |
| 289 | + Join our Discord community for support with MCP integration |
| 290 | + </Card> |
| 291 | + <Card |
| 292 | + title="API Reference" |
| 293 | + icon="book" |
| 294 | + href="/api-reference/tools/create" |
| 295 | + > |
| 296 | + View the complete API documentation for tools |
| 297 | + </Card> |
| 298 | +</CardGroup> |
0 commit comments