elevenlabs-voice-agent-mcp 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/dist/index.js +0 -0
- package/package.json +25 -2
- package/.claude/settings.local.json +0 -23
- package/.env.example +0 -3
- package/AGENTS.md +0 -37
- package/CLAUDE.md +0 -233
- package/call-exact-format.ts +0 -66
- package/call-wait-null.ts +0 -71
- package/create-agent-simple.ts +0 -84
- package/create-new-agent.ts +0 -98
- package/demo-agent-system-prompt.xml +0 -166
- package/elevenlabs-voice-agent-mcp-1.0.0.tgz +0 -0
- package/em_positive_leads.csv +0 -25
- package/list-resources.ts +0 -93
- package/make-call-now.ts +0 -66
- package/make-test-call.ts +0 -80
- package/openapi.json +0 -3238
- package/src/constants.ts +0 -62
- package/src/index.ts +0 -141
- package/src/schemas/agent-schemas.ts +0 -193
- package/src/schemas/batch-calling-schemas.ts +0 -96
- package/src/schemas/common-schemas.ts +0 -83
- package/src/schemas/conversation-schemas.ts +0 -44
- package/src/schemas/outbound-schemas.ts +0 -70
- package/src/schemas/phone-number-schemas.ts +0 -140
- package/src/schemas/tool-schemas.ts +0 -161
- package/src/services/elevenlabs-api.ts +0 -113
- package/src/services/formatters.ts +0 -623
- package/src/tools/agent-tools.ts +0 -425
- package/src/tools/batch-calling-tools.ts +0 -237
- package/src/tools/conversation-tools.ts +0 -167
- package/src/tools/knowledge-tools.ts +0 -73
- package/src/tools/outbound-tools.ts +0 -95
- package/src/tools/phone-number-tools.ts +0 -346
- package/src/tools/tool-tools.ts +0 -195
- package/src/tools/utility-tools.ts +0 -147
- package/src/types.ts +0 -327
- package/src/utils/error-handlers.ts +0 -98
- package/src/utils/truncation.ts +0 -97
- package/test-call-wait-for-hello.ts +0 -76
- package/test-call.json +0 -5
- package/tsconfig.json +0 -21
package/src/constants.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Constants for ElevenLabs Voice Agent MCP Server
|
|
3
|
-
*
|
|
4
|
-
* Contains API URLs, character limits, default values, and supported options
|
|
5
|
-
* for ElevenLabs Voice Agent API integration.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export const API_BASE_URL = "https://api.elevenlabs.io/v1";
|
|
9
|
-
|
|
10
|
-
// Response limits
|
|
11
|
-
export const CHARACTER_LIMIT = 25000;
|
|
12
|
-
export const DEFAULT_LIMIT = 20;
|
|
13
|
-
export const MAX_LIMIT = 100;
|
|
14
|
-
|
|
15
|
-
// Default configuration values
|
|
16
|
-
export const DEFAULT_LLM = "gpt-4o-mini";
|
|
17
|
-
export const DEFAULT_VOICE_MODEL = "eleven_flash_v2_5";
|
|
18
|
-
export const DEFAULT_VOICE_ID = "21m00Tcm4TlvDq8ikWAM"; // Rachel voice
|
|
19
|
-
export const DEFAULT_LANGUAGE = "en";
|
|
20
|
-
|
|
21
|
-
// Supported LLM models
|
|
22
|
-
export const SUPPORTED_LLMS = [
|
|
23
|
-
"gpt-4o",
|
|
24
|
-
"gpt-4o-mini",
|
|
25
|
-
"claude-3-5-sonnet-20241022",
|
|
26
|
-
"claude-3-5-haiku-20241022",
|
|
27
|
-
"gemini-2.0-flash-exp"
|
|
28
|
-
] as const;
|
|
29
|
-
|
|
30
|
-
// Supported voice models
|
|
31
|
-
export const SUPPORTED_VOICE_MODELS = [
|
|
32
|
-
"eleven_turbo_v2_5",
|
|
33
|
-
"eleven_flash_v2_5",
|
|
34
|
-
"eleven_multilingual_v2"
|
|
35
|
-
] as const;
|
|
36
|
-
|
|
37
|
-
// Supported languages
|
|
38
|
-
export const SUPPORTED_LANGUAGES = [
|
|
39
|
-
"en", "es", "fr", "de", "it", "pt", "pl", "nl", "ja", "zh", "ko", "ar", "hi"
|
|
40
|
-
] as const;
|
|
41
|
-
|
|
42
|
-
// Authentication types
|
|
43
|
-
export const AUTH_TYPES = ["none", "manual", "open"] as const;
|
|
44
|
-
|
|
45
|
-
// API timeouts
|
|
46
|
-
export const REQUEST_TIMEOUT = 30000; // 30 seconds
|
|
47
|
-
|
|
48
|
-
// Batch calling limits
|
|
49
|
-
export const MAX_BATCH_RECIPIENTS = 10000;
|
|
50
|
-
export const MIN_BATCH_RECIPIENTS = 1;
|
|
51
|
-
|
|
52
|
-
// Phone providers
|
|
53
|
-
export const PHONE_PROVIDERS = ["twilio", "sip_trunk"] as const;
|
|
54
|
-
|
|
55
|
-
// Phone number regions
|
|
56
|
-
export const REGION_IDS = ["us1", "ie1", "au1"] as const;
|
|
57
|
-
|
|
58
|
-
// Edge locations
|
|
59
|
-
export const EDGE_LOCATIONS = [
|
|
60
|
-
"ashburn", "dublin", "frankfurt", "sao-paulo",
|
|
61
|
-
"singapore", "sydney", "tokyo", "umatilla", "roaming"
|
|
62
|
-
] as const;
|
package/src/index.ts
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* ElevenLabs Voice Agent MCP Server
|
|
5
|
-
*
|
|
6
|
-
* Main entry point for the MCP server providing tools for voice agent development.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
10
|
-
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
11
|
-
import { validateApiKey } from "./utils/error-handlers.js";
|
|
12
|
-
|
|
13
|
-
// Import all tools
|
|
14
|
-
import {
|
|
15
|
-
elevenlabs_create_agent,
|
|
16
|
-
elevenlabs_get_agent,
|
|
17
|
-
elevenlabs_update_agent,
|
|
18
|
-
elevenlabs_delete_agent,
|
|
19
|
-
elevenlabs_list_agents
|
|
20
|
-
} from "./tools/agent-tools.js";
|
|
21
|
-
|
|
22
|
-
import { elevenlabs_add_knowledge_base } from "./tools/knowledge-tools.js";
|
|
23
|
-
|
|
24
|
-
import {
|
|
25
|
-
elevenlabs_create_webhook_tool,
|
|
26
|
-
elevenlabs_list_tools,
|
|
27
|
-
elevenlabs_delete_tool
|
|
28
|
-
} from "./tools/tool-tools.js";
|
|
29
|
-
|
|
30
|
-
import {
|
|
31
|
-
elevenlabs_get_conversation,
|
|
32
|
-
elevenlabs_list_conversations
|
|
33
|
-
} from "./tools/conversation-tools.js";
|
|
34
|
-
|
|
35
|
-
import {
|
|
36
|
-
elevenlabs_generate_widget_code,
|
|
37
|
-
elevenlabs_list_voices
|
|
38
|
-
} from "./tools/utility-tools.js";
|
|
39
|
-
|
|
40
|
-
import { elevenlabs_start_outbound_call } from "./tools/outbound-tools.js";
|
|
41
|
-
|
|
42
|
-
import {
|
|
43
|
-
elevenlabs_submit_batch_call,
|
|
44
|
-
elevenlabs_list_batch_calls,
|
|
45
|
-
elevenlabs_get_batch_call
|
|
46
|
-
} from "./tools/batch-calling-tools.js";
|
|
47
|
-
|
|
48
|
-
import {
|
|
49
|
-
elevenlabs_list_phone_numbers,
|
|
50
|
-
elevenlabs_get_phone_number,
|
|
51
|
-
elevenlabs_import_phone_number,
|
|
52
|
-
elevenlabs_update_phone_number,
|
|
53
|
-
elevenlabs_delete_phone_number
|
|
54
|
-
} from "./tools/phone-number-tools.js";
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Initialize and start the MCP server
|
|
58
|
-
*/
|
|
59
|
-
async function main() {
|
|
60
|
-
// Validate API key on startup
|
|
61
|
-
try {
|
|
62
|
-
validateApiKey();
|
|
63
|
-
} catch (error) {
|
|
64
|
-
console.error("Failed to start MCP server:", error instanceof Error ? error.message : String(error));
|
|
65
|
-
process.exit(1);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Create MCP server instance
|
|
69
|
-
const server = new McpServer({
|
|
70
|
-
name: "elevenlabs-voice-agent-mcp",
|
|
71
|
-
version: "1.0.0"
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
// Register all tools
|
|
75
|
-
const tools = [
|
|
76
|
-
// Tier 1: Core Agent Management
|
|
77
|
-
elevenlabs_create_agent,
|
|
78
|
-
elevenlabs_get_agent,
|
|
79
|
-
elevenlabs_update_agent,
|
|
80
|
-
elevenlabs_delete_agent,
|
|
81
|
-
elevenlabs_list_agents,
|
|
82
|
-
|
|
83
|
-
// Tier 2: Knowledge Base & Tools
|
|
84
|
-
elevenlabs_add_knowledge_base,
|
|
85
|
-
elevenlabs_create_webhook_tool,
|
|
86
|
-
elevenlabs_list_tools,
|
|
87
|
-
elevenlabs_delete_tool,
|
|
88
|
-
|
|
89
|
-
// Tier 3: Testing & Monitoring
|
|
90
|
-
elevenlabs_get_conversation,
|
|
91
|
-
elevenlabs_list_conversations,
|
|
92
|
-
elevenlabs_generate_widget_code,
|
|
93
|
-
|
|
94
|
-
// Tier 4: Utilities
|
|
95
|
-
elevenlabs_list_voices,
|
|
96
|
-
|
|
97
|
-
// Tier 5: Outbound Calling & Phone Management
|
|
98
|
-
elevenlabs_start_outbound_call,
|
|
99
|
-
elevenlabs_submit_batch_call,
|
|
100
|
-
elevenlabs_list_batch_calls,
|
|
101
|
-
elevenlabs_get_batch_call,
|
|
102
|
-
elevenlabs_list_phone_numbers,
|
|
103
|
-
elevenlabs_get_phone_number,
|
|
104
|
-
elevenlabs_import_phone_number,
|
|
105
|
-
elevenlabs_update_phone_number,
|
|
106
|
-
elevenlabs_delete_phone_number
|
|
107
|
-
];
|
|
108
|
-
|
|
109
|
-
// Register each tool with the server
|
|
110
|
-
for (const tool of tools) {
|
|
111
|
-
const zodSchema = (tool as any).zodSchema;
|
|
112
|
-
const annotations = (tool as any).annotations;
|
|
113
|
-
|
|
114
|
-
server.registerTool(
|
|
115
|
-
tool.name,
|
|
116
|
-
{
|
|
117
|
-
description: tool.description,
|
|
118
|
-
...(zodSchema && { inputSchema: zodSchema }),
|
|
119
|
-
...(annotations && { annotations })
|
|
120
|
-
},
|
|
121
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
122
|
-
tool.handler as any
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// Set up stdio transport
|
|
127
|
-
const transport = new StdioServerTransport();
|
|
128
|
-
|
|
129
|
-
// Connect server to transport
|
|
130
|
-
await server.connect(transport);
|
|
131
|
-
|
|
132
|
-
console.error("ElevenLabs Voice Agent MCP server running on stdio");
|
|
133
|
-
console.error(`Registered ${tools.length} tools`);
|
|
134
|
-
console.error("API Key:", process.env.ELEVENLABS_API_KEY ? "✓ Set" : "✗ Not set");
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// Start the server
|
|
138
|
-
main().catch((error) => {
|
|
139
|
-
console.error("Fatal error:", error);
|
|
140
|
-
process.exit(1);
|
|
141
|
-
});
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zod validation schemas for agent-related operations
|
|
3
|
-
*
|
|
4
|
-
* Provides strict input validation for creating, updating, and managing agents.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { z } from "zod";
|
|
8
|
-
import {
|
|
9
|
-
SUPPORTED_LLMS,
|
|
10
|
-
SUPPORTED_VOICE_MODELS,
|
|
11
|
-
SUPPORTED_LANGUAGES,
|
|
12
|
-
DEFAULT_LLM,
|
|
13
|
-
DEFAULT_VOICE_MODEL,
|
|
14
|
-
DEFAULT_VOICE_ID,
|
|
15
|
-
DEFAULT_LANGUAGE
|
|
16
|
-
} from "../constants.js";
|
|
17
|
-
import {
|
|
18
|
-
ResponseFormatSchema,
|
|
19
|
-
LimitSchema,
|
|
20
|
-
OffsetSchema,
|
|
21
|
-
AgentIdSchema,
|
|
22
|
-
VoiceIdSchema,
|
|
23
|
-
ColorSchema,
|
|
24
|
-
URLSchema
|
|
25
|
-
} from "./common-schemas.js";
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Schema for creating a new agent
|
|
29
|
-
*/
|
|
30
|
-
export const CreateAgentSchema = z.object({
|
|
31
|
-
name: z.string()
|
|
32
|
-
.min(1, "Agent name is required")
|
|
33
|
-
.max(100, "Name must not exceed 100 characters")
|
|
34
|
-
.describe("Display name for the agent (e.g., 'Customer Support Bot')"),
|
|
35
|
-
|
|
36
|
-
prompt: z.string()
|
|
37
|
-
.min(10, "Prompt must be at least 10 characters")
|
|
38
|
-
.max(5000, "Prompt must not exceed 5000 characters")
|
|
39
|
-
.describe("System prompt defining agent behavior and personality"),
|
|
40
|
-
|
|
41
|
-
llm: z.enum(SUPPORTED_LLMS, {
|
|
42
|
-
errorMap: () => ({ message: `LLM must be one of: ${SUPPORTED_LLMS.join(", ")}` })
|
|
43
|
-
})
|
|
44
|
-
.default(DEFAULT_LLM)
|
|
45
|
-
.describe(`LLM model to use (default: ${DEFAULT_LLM})`),
|
|
46
|
-
|
|
47
|
-
voice_id: VoiceIdSchema
|
|
48
|
-
.default(DEFAULT_VOICE_ID)
|
|
49
|
-
.describe(`ElevenLabs voice ID (default: ${DEFAULT_VOICE_ID} - Rachel)`),
|
|
50
|
-
|
|
51
|
-
voice_model: z.enum(SUPPORTED_VOICE_MODELS, {
|
|
52
|
-
errorMap: () => ({ message: `Voice model must be one of: ${SUPPORTED_VOICE_MODELS.join(", ")}` })
|
|
53
|
-
})
|
|
54
|
-
.default(DEFAULT_VOICE_MODEL)
|
|
55
|
-
.describe(`Voice model to use (default: ${DEFAULT_VOICE_MODEL})`),
|
|
56
|
-
|
|
57
|
-
first_message: z.string()
|
|
58
|
-
.max(500, "First message must not exceed 500 characters")
|
|
59
|
-
.optional()
|
|
60
|
-
.describe("Optional greeting message the agent will say first"),
|
|
61
|
-
|
|
62
|
-
language: z.enum(SUPPORTED_LANGUAGES, {
|
|
63
|
-
errorMap: () => ({ message: `Language must be one of: ${SUPPORTED_LANGUAGES.join(", ")}` })
|
|
64
|
-
})
|
|
65
|
-
.default(DEFAULT_LANGUAGE)
|
|
66
|
-
.describe(`Primary language code (default: ${DEFAULT_LANGUAGE})`),
|
|
67
|
-
|
|
68
|
-
temperature: z.number()
|
|
69
|
-
.min(0, "Temperature must be between 0 and 2")
|
|
70
|
-
.max(2, "Temperature must be between 0 and 2")
|
|
71
|
-
.optional()
|
|
72
|
-
.describe("LLM temperature for response randomness (0-2, higher = more creative)"),
|
|
73
|
-
|
|
74
|
-
max_tokens: z.number()
|
|
75
|
-
.int("Max tokens must be an integer")
|
|
76
|
-
.min(1, "Max tokens must be at least 1")
|
|
77
|
-
.max(4096, "Max tokens must not exceed 4096")
|
|
78
|
-
.optional()
|
|
79
|
-
.describe("Maximum tokens for LLM responses"),
|
|
80
|
-
|
|
81
|
-
stability: z.number()
|
|
82
|
-
.min(0, "Stability must be between 0 and 1")
|
|
83
|
-
.max(1, "Stability must be between 0 and 1")
|
|
84
|
-
.optional()
|
|
85
|
-
.describe("Voice stability (0-1, higher = more consistent)"),
|
|
86
|
-
|
|
87
|
-
similarity_boost: z.number()
|
|
88
|
-
.min(0, "Similarity boost must be between 0 and 1")
|
|
89
|
-
.max(1, "Similarity boost must be between 0 and 1")
|
|
90
|
-
.optional()
|
|
91
|
-
.describe("Voice similarity boost (0-1, higher = closer to original voice)"),
|
|
92
|
-
|
|
93
|
-
widget_color: ColorSchema.optional().describe("Widget theme color"),
|
|
94
|
-
|
|
95
|
-
widget_avatar_url: URLSchema.optional().describe("Widget avatar image URL"),
|
|
96
|
-
|
|
97
|
-
response_format: ResponseFormatSchema
|
|
98
|
-
}).passthrough();
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Schema for getting an agent by ID
|
|
102
|
-
*/
|
|
103
|
-
export const GetAgentSchema = z.object({
|
|
104
|
-
agent_id: AgentIdSchema,
|
|
105
|
-
response_format: ResponseFormatSchema
|
|
106
|
-
}).passthrough();
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Schema for updating an agent
|
|
110
|
-
*/
|
|
111
|
-
export const UpdateAgentSchema = z.object({
|
|
112
|
-
agent_id: AgentIdSchema,
|
|
113
|
-
|
|
114
|
-
name: z.string()
|
|
115
|
-
.min(1, "Agent name cannot be empty")
|
|
116
|
-
.max(100, "Name must not exceed 100 characters")
|
|
117
|
-
.optional()
|
|
118
|
-
.describe("New display name for the agent"),
|
|
119
|
-
|
|
120
|
-
prompt: z.string()
|
|
121
|
-
.min(10, "Prompt must be at least 10 characters")
|
|
122
|
-
.max(5000, "Prompt must not exceed 5000 characters")
|
|
123
|
-
.optional()
|
|
124
|
-
.describe("Updated system prompt"),
|
|
125
|
-
|
|
126
|
-
llm: z.enum(SUPPORTED_LLMS)
|
|
127
|
-
.optional()
|
|
128
|
-
.describe("Updated LLM model"),
|
|
129
|
-
|
|
130
|
-
voice_id: VoiceIdSchema
|
|
131
|
-
.optional()
|
|
132
|
-
.describe("Updated voice ID"),
|
|
133
|
-
|
|
134
|
-
voice_model: z.enum(SUPPORTED_VOICE_MODELS)
|
|
135
|
-
.optional()
|
|
136
|
-
.describe("Updated voice model"),
|
|
137
|
-
|
|
138
|
-
first_message: z.string()
|
|
139
|
-
.max(500, "First message must not exceed 500 characters")
|
|
140
|
-
.optional()
|
|
141
|
-
.describe("Updated first message"),
|
|
142
|
-
|
|
143
|
-
language: z.enum(SUPPORTED_LANGUAGES)
|
|
144
|
-
.optional()
|
|
145
|
-
.describe("Updated language"),
|
|
146
|
-
|
|
147
|
-
temperature: z.number()
|
|
148
|
-
.min(0)
|
|
149
|
-
.max(2)
|
|
150
|
-
.optional()
|
|
151
|
-
.describe("Updated temperature"),
|
|
152
|
-
|
|
153
|
-
max_tokens: z.number()
|
|
154
|
-
.int()
|
|
155
|
-
.min(1)
|
|
156
|
-
.max(4096)
|
|
157
|
-
.optional()
|
|
158
|
-
.describe("Updated max tokens"),
|
|
159
|
-
|
|
160
|
-
stability: z.number()
|
|
161
|
-
.min(0)
|
|
162
|
-
.max(1)
|
|
163
|
-
.optional()
|
|
164
|
-
.describe("Updated voice stability"),
|
|
165
|
-
|
|
166
|
-
similarity_boost: z.number()
|
|
167
|
-
.min(0)
|
|
168
|
-
.max(1)
|
|
169
|
-
.optional()
|
|
170
|
-
.describe("Updated similarity boost"),
|
|
171
|
-
|
|
172
|
-
widget_color: ColorSchema.optional().describe("Updated widget color"),
|
|
173
|
-
|
|
174
|
-
widget_avatar_url: URLSchema.optional().describe("Updated widget avatar URL"),
|
|
175
|
-
|
|
176
|
-
response_format: ResponseFormatSchema
|
|
177
|
-
}).passthrough();
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Schema for deleting an agent
|
|
181
|
-
*/
|
|
182
|
-
export const DeleteAgentSchema = z.object({
|
|
183
|
-
agent_id: AgentIdSchema
|
|
184
|
-
}).passthrough();
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Schema for listing agents
|
|
188
|
-
*/
|
|
189
|
-
export const ListAgentsSchema = z.object({
|
|
190
|
-
limit: LimitSchema,
|
|
191
|
-
offset: OffsetSchema,
|
|
192
|
-
response_format: ResponseFormatSchema
|
|
193
|
-
}).passthrough();
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zod validation schemas for batch calling operations
|
|
3
|
-
*
|
|
4
|
-
* Provides strict input validation for submitting batch call jobs,
|
|
5
|
-
* listing batch calls, and retrieving batch call details.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { z } from "zod";
|
|
9
|
-
import { ResponseFormatSchema, AgentIdSchema, LimitSchema } from "./common-schemas.js";
|
|
10
|
-
import { PhoneNumberSchema, PhoneNumberIdSchema } from "./outbound-schemas.js";
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Batch ID schema
|
|
14
|
-
*/
|
|
15
|
-
export const BatchIdSchema = z.string()
|
|
16
|
-
.min(1, "Batch ID is required")
|
|
17
|
-
.regex(/^[a-zA-Z0-9_-]+$/, "Batch ID must contain only alphanumeric characters, hyphens, and underscores")
|
|
18
|
-
.describe("Unique identifier for the batch call job");
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Recipient schema for batch calling
|
|
22
|
-
*/
|
|
23
|
-
export const OutboundCallRecipientSchema = z.object({
|
|
24
|
-
id: z.string()
|
|
25
|
-
.optional()
|
|
26
|
-
.describe("Optional recipient identifier for tracking"),
|
|
27
|
-
|
|
28
|
-
phone_number: PhoneNumberSchema
|
|
29
|
-
.optional()
|
|
30
|
-
.describe("Recipient phone number (required if whatsapp_user_id not provided)"),
|
|
31
|
-
|
|
32
|
-
whatsapp_user_id: z.string()
|
|
33
|
-
.optional()
|
|
34
|
-
.describe("WhatsApp user ID (alternative to phone_number)"),
|
|
35
|
-
|
|
36
|
-
conversation_initiation_client_data: z.record(z.any())
|
|
37
|
-
.optional()
|
|
38
|
-
.describe("Personalization data for this recipient (e.g., {dynamic_variables: {name: 'John', account_id: '123'}})")
|
|
39
|
-
}).refine(
|
|
40
|
-
(data) => data.phone_number || data.whatsapp_user_id,
|
|
41
|
-
{
|
|
42
|
-
message: "Either phone_number or whatsapp_user_id must be provided"
|
|
43
|
-
}
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Schema for submitting a batch call job
|
|
48
|
-
*/
|
|
49
|
-
export const SubmitBatchCallSchema = z.object({
|
|
50
|
-
call_name: z.string()
|
|
51
|
-
.min(1, "Call name is required")
|
|
52
|
-
.max(200, "Call name must not exceed 200 characters")
|
|
53
|
-
.describe("Descriptive name for this batch call job"),
|
|
54
|
-
|
|
55
|
-
agent_id: AgentIdSchema,
|
|
56
|
-
|
|
57
|
-
recipients: z.array(OutboundCallRecipientSchema)
|
|
58
|
-
.min(1, "At least one recipient is required")
|
|
59
|
-
.max(10000, "Maximum 10,000 recipients per batch")
|
|
60
|
-
.describe("Array of recipients to call"),
|
|
61
|
-
|
|
62
|
-
scheduled_time_unix: z.number()
|
|
63
|
-
.int("Scheduled time must be a Unix timestamp")
|
|
64
|
-
.positive("Scheduled time must be in the future")
|
|
65
|
-
.optional()
|
|
66
|
-
.describe("Optional Unix timestamp to schedule the batch for future execution"),
|
|
67
|
-
|
|
68
|
-
agent_phone_number_id: PhoneNumberIdSchema
|
|
69
|
-
.optional()
|
|
70
|
-
.describe("Phone number to use as caller ID (optional)"),
|
|
71
|
-
|
|
72
|
-
response_format: ResponseFormatSchema
|
|
73
|
-
}).passthrough();
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Schema for listing batch calls
|
|
77
|
-
*/
|
|
78
|
-
export const ListBatchCallsSchema = z.object({
|
|
79
|
-
limit: LimitSchema,
|
|
80
|
-
|
|
81
|
-
last_doc: z.string()
|
|
82
|
-
.optional()
|
|
83
|
-
.nullable()
|
|
84
|
-
.describe("Pagination cursor from previous response"),
|
|
85
|
-
|
|
86
|
-
response_format: ResponseFormatSchema
|
|
87
|
-
}).passthrough();
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Schema for getting batch call details
|
|
91
|
-
*/
|
|
92
|
-
export const GetBatchCallSchema = z.object({
|
|
93
|
-
batch_id: BatchIdSchema,
|
|
94
|
-
|
|
95
|
-
response_format: ResponseFormatSchema
|
|
96
|
-
}).passthrough();
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Common Zod validation schemas
|
|
3
|
-
*
|
|
4
|
-
* Shared schemas used across multiple tools for pagination,
|
|
5
|
-
* formatting, and common parameters.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { z } from "zod";
|
|
9
|
-
import { DEFAULT_LIMIT, MAX_LIMIT } from "../constants.js";
|
|
10
|
-
import { ResponseFormat } from "../types.js";
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Response format schema (JSON or Markdown)
|
|
14
|
-
*/
|
|
15
|
-
export const ResponseFormatSchema = z.nativeEnum(ResponseFormat, {
|
|
16
|
-
errorMap: () => ({ message: "Format must be 'json' or 'markdown'" })
|
|
17
|
-
}).default(ResponseFormat.MARKDOWN).describe(
|
|
18
|
-
"Output format: 'markdown' for human-readable or 'json' for structured data"
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Pagination limit schema
|
|
23
|
-
*/
|
|
24
|
-
export const LimitSchema = z.number()
|
|
25
|
-
.int("Limit must be an integer")
|
|
26
|
-
.min(1, "Limit must be at least 1")
|
|
27
|
-
.max(MAX_LIMIT, `Limit must not exceed ${MAX_LIMIT}`)
|
|
28
|
-
.default(DEFAULT_LIMIT)
|
|
29
|
-
.describe(`Maximum number of items to return (1-${MAX_LIMIT}, default: ${DEFAULT_LIMIT})`);
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Pagination offset schema
|
|
33
|
-
*/
|
|
34
|
-
export const OffsetSchema = z.number()
|
|
35
|
-
.int("Offset must be an integer")
|
|
36
|
-
.min(0, "Offset must be 0 or greater")
|
|
37
|
-
.default(0)
|
|
38
|
-
.describe("Number of items to skip for pagination (default: 0)");
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Agent ID schema
|
|
42
|
-
*/
|
|
43
|
-
export const AgentIdSchema = z.string()
|
|
44
|
-
.min(1, "Agent ID is required")
|
|
45
|
-
.regex(/^[a-zA-Z0-9_-]+$/, "Agent ID must contain only alphanumeric characters, hyphens, and underscores")
|
|
46
|
-
.describe("Unique identifier for the agent (e.g., 'ag_abc123')");
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Conversation ID schema
|
|
50
|
-
*/
|
|
51
|
-
export const ConversationIdSchema = z.string()
|
|
52
|
-
.min(1, "Conversation ID is required")
|
|
53
|
-
.regex(/^[a-zA-Z0-9_-]+$/, "Conversation ID must contain only alphanumeric characters, hyphens, and underscores")
|
|
54
|
-
.describe("Unique identifier for the conversation (e.g., 'conv_xyz789')");
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Voice ID schema
|
|
58
|
-
*/
|
|
59
|
-
export const VoiceIdSchema = z.string()
|
|
60
|
-
.min(1, "Voice ID is required")
|
|
61
|
-
.describe("ElevenLabs voice ID (e.g., '21m00Tcm4TlvDq8ikWAM' for Rachel)");
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* URL schema
|
|
65
|
-
*/
|
|
66
|
-
export const URLSchema = z.string()
|
|
67
|
-
.url("Must be a valid URL")
|
|
68
|
-
.describe("A valid HTTP or HTTPS URL");
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Color hex schema
|
|
72
|
-
*/
|
|
73
|
-
export const ColorSchema = z.string()
|
|
74
|
-
.regex(/^#[0-9A-Fa-f]{6}$/, "Must be a valid hex color (e.g., #FF5733)")
|
|
75
|
-
.describe("Hex color code (e.g., '#FF5733')");
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Date range schema
|
|
79
|
-
*/
|
|
80
|
-
export const DateRangeSchema = z.object({
|
|
81
|
-
start: z.string().datetime().optional().describe("Start date in ISO 8601 format"),
|
|
82
|
-
end: z.string().datetime().optional().describe("End date in ISO 8601 format")
|
|
83
|
-
}).optional().describe("Optional date range filter");
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zod validation schemas for conversation operations
|
|
3
|
-
*
|
|
4
|
-
* Provides strict input validation for retrieving and managing conversations.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { z } from "zod";
|
|
8
|
-
import {
|
|
9
|
-
AgentIdSchema,
|
|
10
|
-
ConversationIdSchema,
|
|
11
|
-
ResponseFormatSchema,
|
|
12
|
-
LimitSchema,
|
|
13
|
-
OffsetSchema,
|
|
14
|
-
DateRangeSchema
|
|
15
|
-
} from "./common-schemas.js";
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Schema for getting a single conversation
|
|
19
|
-
*/
|
|
20
|
-
export const GetConversationSchema = z.object({
|
|
21
|
-
conversation_id: ConversationIdSchema,
|
|
22
|
-
response_format: ResponseFormatSchema
|
|
23
|
-
}).passthrough();
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Schema for listing conversations
|
|
27
|
-
*/
|
|
28
|
-
export const ListConversationsSchema = z.object({
|
|
29
|
-
agent_id: AgentIdSchema
|
|
30
|
-
.optional()
|
|
31
|
-
.describe("Optional: filter by agent ID"),
|
|
32
|
-
|
|
33
|
-
status: z.enum(["in_progress", "completed", "failed"])
|
|
34
|
-
.optional()
|
|
35
|
-
.describe("Optional: filter by conversation status"),
|
|
36
|
-
|
|
37
|
-
date_range: DateRangeSchema,
|
|
38
|
-
|
|
39
|
-
limit: LimitSchema,
|
|
40
|
-
|
|
41
|
-
offset: OffsetSchema,
|
|
42
|
-
|
|
43
|
-
response_format: ResponseFormatSchema
|
|
44
|
-
}).passthrough();
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zod validation schemas for outbound calling operations
|
|
3
|
-
*
|
|
4
|
-
* Provides strict input validation for making single outbound calls via Twilio.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { z } from "zod";
|
|
8
|
-
import { ResponseFormatSchema, AgentIdSchema } from "./common-schemas.js";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Phone number schema with E.164 format validation
|
|
12
|
-
*/
|
|
13
|
-
export const PhoneNumberSchema = z.string()
|
|
14
|
-
.min(1, "Phone number is required")
|
|
15
|
-
.regex(/^\+?[1-9]\d{1,14}$/, "Phone number must be in E.164 format (e.g., +1234567890)")
|
|
16
|
-
.describe("Phone number in E.164 format (e.g., '+1234567890')");
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Phone number ID schema
|
|
20
|
-
*/
|
|
21
|
-
export const PhoneNumberIdSchema = z.string()
|
|
22
|
-
.min(1, "Phone number ID is required")
|
|
23
|
-
.regex(/^[a-zA-Z0-9_-]+$/, "Phone number ID must contain only alphanumeric characters, hyphens, and underscores")
|
|
24
|
-
.describe("Unique identifier for the phone number");
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Config overrides schema for conversation customization
|
|
28
|
-
*/
|
|
29
|
-
export const ConfigOverridesSchema = z.object({
|
|
30
|
-
agent: z.object({
|
|
31
|
-
first_message: z.string().optional(),
|
|
32
|
-
system_prompt: z.string().optional(),
|
|
33
|
-
language: z.string().optional()
|
|
34
|
-
}).optional(),
|
|
35
|
-
tts: z.object({
|
|
36
|
-
voice_id: z.string().optional(),
|
|
37
|
-
model_id: z.string().optional()
|
|
38
|
-
}).optional(),
|
|
39
|
-
turn: z.object({
|
|
40
|
-
mode: z.string().optional()
|
|
41
|
-
}).optional(),
|
|
42
|
-
conversation: z.object({
|
|
43
|
-
max_duration_seconds: z.number().int().positive().optional()
|
|
44
|
-
}).optional()
|
|
45
|
-
}).optional().describe("Configuration overrides for this specific call");
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Conversation initiation data schema
|
|
49
|
-
*/
|
|
50
|
-
export const ConversationInitDataSchema = z.record(z.any())
|
|
51
|
-
.optional()
|
|
52
|
-
.describe("Dynamic variables and configuration overrides for personalization");
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Schema for starting an outbound call
|
|
56
|
-
*/
|
|
57
|
-
export const StartOutboundCallSchema = z.object({
|
|
58
|
-
agent_id: AgentIdSchema,
|
|
59
|
-
|
|
60
|
-
agent_phone_number_id: PhoneNumberIdSchema,
|
|
61
|
-
|
|
62
|
-
to_number: PhoneNumberSchema
|
|
63
|
-
.describe("Destination phone number to call"),
|
|
64
|
-
|
|
65
|
-
conversation_initiation_client_data: z.record(z.any())
|
|
66
|
-
.optional()
|
|
67
|
-
.describe("Personalization data including dynamic_variables object (e.g., {dynamic_variables: {name: 'John', user_id: '123'}})"),
|
|
68
|
-
|
|
69
|
-
response_format: ResponseFormatSchema
|
|
70
|
-
}).passthrough();
|