Model Context Protocol (MCP) Integration

Connect your assistant to dynamic tools through MCP servers for enhanced capabilities.

The Model Context Protocol (MCP) integration allows your Vapi assistant to dynamically access tools from MCP servers during calls. This enables your assistant to:

  1. Connect to any MCP-compatible server
  2. Access tools dynamically at runtime
  3. Execute actions through the MCP server

This powerful integration allows your assistant to leverage a wide range of tools without requiring individual integrations for each service.

Prerequisites

Before you can use the MCP integration, you need to:

  1. Have access to the Vapi Dashboard
  2. Have an assistant created in Vapi
  3. Have access to an MCP server URL (e.g., from Zapier, Composio, or other MCP providers)

Setup Steps

1. Obtain MCP Server URL

First, you need to obtain an MCP server URL from your chosen provider:

  1. Sign up for an MCP-compatible service (e.g., Zapier, Composio)
  2. Navigate to the MCP configuration section of your provider
  3. Generate or copy your MCP server URL

For Zapier MCP, visit https://actions.zapier.com/settings/mcp/ to generate your MCP server URL. This URL should be treated as a credential and kept secure.

2. Create and Configure MCP Tool

After obtaining your MCP server URL, create and configure the tool:

  1. Go to Dashboard > Tools page
  2. Click the Create Tool button
  3. Select MCP from the available options
  4. Provide a name and description explaining when it should be invoked
  5. Configure the tool with the following required field:
    • serverUrl: The URL of your MCP server

The MCP server URL should be treated as a credential and kept secure. It will be used to authenticate requests to the MCP server.

3. Add Tool to Assistant

Now, add the MCP tool to your assistant:

  1. Navigate to Dashboard > Assistants page
  2. Select your assistant
  3. Go to the Tools tab
  4. In the tools dropdown, select your MCP tool
  5. Click Publish to save your changes

How MCP Works

The MCP integration follows these steps during a call:

  1. When a call starts, Vapi connects to your configured MCP server
  2. The MCP server returns a list of available tools and their capabilities
  3. These tools are dynamically added to your assistant’s available tools
  4. The assistant can then use these tools during the call
  5. When a tool is invoked, Vapi sends the request to the MCP server
  6. The MCP server executes the action and returns the result

The MCP tool itself is not meant to be invoked by the model. It serves as a configuration mechanism for Vapi to fetch and inject the specific tool definitions from the MCP server into the model’s context.

The tools available through MCP are determined by your MCP server provider. Different providers may offer different sets of tools.

Tool Configuration

MCP Tool

This tool uses the following field to connect to your MCP server:

The server URL should be treated as a credential and kept secure. It will be used to authenticate requests to the MCP server.

Example Usage

Here’s how the MCP tool can be used in your assistant’s configuration:

1{
2 "model": {
3 "provider": "openai",
4 "model": "gpt-4",
5 "messages": [
6 {
7 "role": "system",
8 "content": "You are a helpful personal assistant named Alex. You can help users with various tasks through voice commands. You have access to tools that allow you to perform actions on the user's behalf.\n\nWhen a user requests an action, check if any of the available tools can help accomplish that task.\n\nCommon tasks you can help with include:\n- Scheduling appointments and meetings\n- Sending messages or emails\n- Creating or updating documents\n- Managing to-do lists and reminders\n- Searching for information\n- Making reservations\n- Ordering food or services\n- Checking account balances or transaction history\n- Controlling smart home devices\n\nAlways be polite, professional, and helpful. If a tool fails or isn't available, explain the situation to the user and suggest alternatives if possible."
9 }
10 ],
11 "tools": [
12 {
13 "type": "mcp",
14 "name": "mcpTools",
15 "server": {
16 "url": "https://actions.zapier.com/mcp/actions/"
17 }
18 }
19 ]
20 }
21}

Best Practices

  1. Dynamic Tool Awareness: Be aware that the available tools may change between calls
  2. Clear Instructions: Provide clear instructions in your assistant’s system message about how to handle dynamic tools
  3. Error Handling: Include fallback responses for cases where tools fail or are unavailable
  4. User Communication: Explain to users what tools you’re using and what actions you’re taking
  5. Security: Treat the MCP server URL as a credential and keep it secure

Example MCP Providers

Zapier MCP

Zapier offers an MCP server that provides access to thousands of app integrations:

  1. Go to https://actions.zapier.com/settings/mcp/
  2. Generate your MCP server URL
  3. Add the URL to your MCP tool configuration
  4. Your assistant will now have access to Zapier’s extensive integration network

Zapier MCP provides access to over 7,000+ apps and 30,000+ actions without requiring complex API integrations.

References