Skip to content

Commit 026c7c0

Browse files
authored
updated chat/mcp docs (VapiAI#524)
1 parent b0a472b commit 026c7c0

File tree

3 files changed

+127
-12
lines changed

3 files changed

+127
-12
lines changed

fern/chat/quickstart.mdx

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,48 @@ We'll create a customer support chat for "TechFlow", a software company that wan
162162

163163
---
164164

165-
## 5. Integrate with TypeScript
165+
## 5. Pass Dynamic Variables
166+
167+
<Steps>
168+
<Step title="Configure variables in your assistant">
169+
In your assistant's system prompt, you can reference dynamic variables using `{{variableName}}` syntax:
170+
171+
```txt title="System Prompt with Variables"
172+
You are a helpful customer support agent for {{companyName}}.
173+
174+
Your role:
175+
- Answer questions about {{companyName}}'s products
176+
- Help customers with their {{serviceType}} needs
177+
- Escalate to human agents when needed
178+
179+
Current customer tier: {{customerTier}}
180+
```
181+
</Step>
182+
<Step title="Pass variables in your chat request">
183+
Use `assistantOverrides.variableValues` to pass dynamic data:
184+
185+
```bash title="Chat Request with Variables"
186+
curl -X POST https://api.vapi.ai/chat \
187+
-H "Authorization: Bearer YOUR_API_KEY" \
188+
-H "Content-Type: application/json" \
189+
-d '{
190+
"assistantId": "your-assistant-id",
191+
"input": "I need help with my account",
192+
"assistantOverrides": {
193+
"variableValues": {
194+
"companyName": "TechFlow Solutions",
195+
"serviceType": "software",
196+
"customerTier": "Premium"
197+
}
198+
}
199+
}'
200+
```
201+
</Step>
202+
</Steps>
203+
204+
---
205+
206+
## 6. Integrate with TypeScript
166207

167208
<Steps>
168209
<Step title="Create a simple chat function">
@@ -236,7 +277,9 @@ We'll create a customer support chat for "TechFlow", a software company that wan
236277

237278
---
238279

239-
## 6. Test Your Chat Bot
280+
281+
282+
## 7. Test Your Chat Bot
240283

241284
<Steps>
242285
<Step title="Test various scenarios">
@@ -267,6 +310,14 @@ We'll create a customer support chat for "TechFlow", a software company that wan
267310
</Step>
268311
</Steps>
269312

313+
## Limitations
314+
315+
<Note>
316+
**Current chat functionality limitations:**
317+
- "Query" tool for knowledge-base searches is not yet supported
318+
- Server webhook events (status updates, end-of-call reports, etc.) are not supported
319+
</Note>
320+
270321
## Next Steps
271322

272323
Take your chat bot to the next level:

fern/sdk/mcp-server.mdx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,16 @@ async function main() {
414414
assistantId: assistantId,
415415
phoneNumberId: phoneNumberId,
416416
customer: {
417-
phoneNumber: "+1234567890" // Replace with actual customer phone number
417+
number: "+1234567890" // Replace with actual customer phone number
418418
}
419419
// Optional: schedule a call for the future
420420
// scheduledAt: "2025-04-15T15:30:00Z"
421+
// assistantOverrides: {
422+
// variableValues: {
423+
// name: 'John Doe',
424+
// age: '25',
425+
// },
426+
// },
421427
},
422428
});
423429
const createdCall = parseToolResponse(createCallResponse);

fern/tools/mcp.mdx

Lines changed: 67 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Now, add the MCP tool to your assistant:
6666

6767
The MCP integration follows these steps during a call:
6868

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
7070
2. The MCP server returns a list of available tools and their capabilities
7171
3. These tools are dynamically added to your assistant's available tools
7272
4. The assistant can then use these tools during the call
@@ -81,13 +81,29 @@ The MCP integration follows these steps during a call:
8181
The tools available through MCP are determined by your MCP server provider. Different providers may offer different sets of tools.
8282
</Note>
8383

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+
8492
## Tool Configuration
8593

8694
### MCP Tool
8795

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/)
89100

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
91107

92108
<Note>
93109
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:
97113

98114
Here's how the MCP tool can be used in your assistant's configuration:
99115

116+
### Default Configuration (Streamable HTTP)
117+
100118
```json
101119
{
102120
"model": {
@@ -111,7 +129,9 @@ Here's how the MCP tool can be used in your assistant's configuration:
111129
"tools": [
112130
{
113131
"type": "mcp",
114-
"name": "mcpTools",
132+
"function": {
133+
"name": "mcpTools"
134+
},
115135
"server": {
116136
"url": "https://actions.zapier.com/mcp/actions/"
117137
}
@@ -121,13 +141,51 @@ Here's how the MCP tool can be used in your assistant's configuration:
121141
}
122142
```
123143

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+
124181
## Best Practices
125182

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
131189

132190
## Example MCP Providers
133191

0 commit comments

Comments
 (0)