@@ -66,7 +66,7 @@ Now, add the MCP tool to your assistant:
66
66
67
67
The MCP integration follows these steps during a call:
68
68
69
- 1 . When a call starts, Vapi connects to your configured MCP server
69
+ 1 . When a call starts, Vapi connects to your configured MCP server using ** Streamable HTTP ** protocol by default
70
70
2 . The MCP server returns a list of available tools and their capabilities
71
71
3 . These tools are dynamically added to your assistant's available tools
72
72
4 . The assistant can then use these tools during the call
@@ -81,13 +81,29 @@ The MCP integration follows these steps during a call:
81
81
The tools available through MCP are determined by your MCP server provider. Different providers may offer different sets of tools.
82
82
</Note >
83
83
84
+ ### Request Headers
85
+
86
+ MCP requests from Vapi include identifying headers to help with context and debugging:
87
+
88
+ - ** ` X-Call-Id ` ** : Included in requests during voice calls to identify the specific call
89
+ - ** ` X-Chat-Id ` ** : Included in requests during chat interactions to identify the specific chat
90
+ - ** ` X-Session-Id ` ** : Included in requests during chat interaction if the chat is part of a session
91
+
84
92
## Tool Configuration
85
93
86
94
### MCP Tool
87
95
88
- This tool uses the following field to connect to your MCP server:
96
+ This tool uses the following configuration options:
97
+
98
+ ** Required:**
99
+ - ` server.url ` : The URL of your MCP server (e.g., https://actions.zapier.com/mcp/actions/ )
89
100
90
- - ` serverUrl ` : The URL of your MCP server (e.g., https://actions.zapier.com/mcp/actions/ )
101
+ ** Optional:**
102
+ - ` server.headers ` : Custom headers to include in requests to the MCP server
103
+ - ` metadata ` : Additional configuration options for the MCP connection
104
+ - ` protocol ` : Communication protocol to use. Options are:
105
+ - ` "shttp" ` (default): Uses Streamable HTTP protocol
106
+ - ` "sse" ` : (deprecated) Uses Server-Sent Events protocol
91
107
92
108
<Note >
93
109
The server URL should be treated as a credential and kept secure. It will be used to authenticate requests to the MCP server.
@@ -97,6 +113,8 @@ This tool uses the following field to connect to your MCP server:
97
113
98
114
Here's how the MCP tool can be used in your assistant's configuration:
99
115
116
+ ### Default Configuration (Streamable HTTP)
117
+
100
118
``` json
101
119
{
102
120
"model" : {
@@ -111,7 +129,9 @@ Here's how the MCP tool can be used in your assistant's configuration:
111
129
"tools" : [
112
130
{
113
131
"type" : " mcp" ,
114
- "name" : " mcpTools" ,
132
+ "function" : {
133
+ "name" : " mcpTools"
134
+ },
115
135
"server" : {
116
136
"url" : " https://actions.zapier.com/mcp/actions/"
117
137
}
@@ -121,13 +141,51 @@ Here's how the MCP tool can be used in your assistant's configuration:
121
141
}
122
142
```
123
143
144
+ ### Custom Configuration (SSE Protocol)
145
+
146
+ If you need to use Server-Sent Events protocol instead:
147
+
148
+ ``` json
149
+ {
150
+ "model" : {
151
+ "provider" : " openai" ,
152
+ "model" : " gpt-4" ,
153
+ "messages" : [
154
+ {
155
+ "role" : " system" ,
156
+ "content" : " You are a helpful personal assistant named Alex..."
157
+ }
158
+ ],
159
+ "tools" : [
160
+ {
161
+ "type" : " mcp" ,
162
+ "function" : {
163
+ "name" : " mcpTools"
164
+ },
165
+ "server" : {
166
+ "url" : " https://actions.zapier.com/mcp/actions/" ,
167
+ "headers" : {
168
+ "Authorization" : " Bearer your-token" ,
169
+ "X-Custom-Header" : " your-value"
170
+ }
171
+ },
172
+ "metadata" : {
173
+ "protocol" : " sse"
174
+ }
175
+ }
176
+ ]
177
+ }
178
+ }
179
+ ```
180
+
124
181
## Best Practices
125
182
126
- 1 . ** Dynamic Tool Awareness** : Be aware that the available tools may change between calls
127
- 2 . ** Clear Instructions** : Provide clear instructions in your assistant's system message about how to handle dynamic tools
128
- 3 . ** Error Handling** : Include fallback responses for cases where tools fail or are unavailable
129
- 4 . ** User Communication** : Explain to users what tools you're using and what actions you're taking
130
- 5 . ** Security** : Treat the MCP server URL as a credential and keep it secure
183
+ 1 . ** Protocol Selection** : Use the default Streamable HTTP protocol for better performance unless you specifically need SSE
184
+ 2 . ** Dynamic Tool Awareness** : Be aware that the available tools may change between calls
185
+ 3 . ** Clear Instructions** : Provide clear instructions in your assistant's system message about how to handle dynamic tools
186
+ 4 . ** Error Handling** : Include fallback responses for cases where tools fail or are unavailable
187
+ 5 . ** User Communication** : Explain to users what tools you're using and what actions you're taking
188
+ 6 . ** Security** : Treat the MCP server URL as a credential and keep it secure
131
189
132
190
## Example MCP Providers
133
191
0 commit comments