elevenlabs-voice-agent-mcp 1.0.2 → 1.0.4

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.
Files changed (59) hide show
  1. package/README.md +170 -0
  2. package/dist/constants.d.ts.map +1 -1
  3. package/dist/constants.js +2 -1
  4. package/dist/constants.js.map +1 -1
  5. package/dist/schemas/agent-schemas.d.ts +6 -6
  6. package/dist/schemas/agent-schemas.d.ts.map +1 -1
  7. package/dist/schemas/agent-schemas.js +6 -6
  8. package/dist/schemas/agent-schemas.js.map +1 -1
  9. package/dist/tools/agent-tools.d.ts +6 -6
  10. package/dist/tools/agent-tools.d.ts.map +1 -1
  11. package/dist/tools/agent-tools.js +3 -2
  12. package/dist/tools/agent-tools.js.map +1 -1
  13. package/dist/types.d.ts +2 -2
  14. package/dist/types.d.ts.map +1 -1
  15. package/dist/utils/phone-normalizer.d.ts +47 -0
  16. package/dist/utils/phone-normalizer.d.ts.map +1 -0
  17. package/dist/utils/phone-normalizer.js +134 -0
  18. package/dist/utils/phone-normalizer.js.map +1 -0
  19. package/package.json +32 -3
  20. package/.claude/settings.local.json +0 -23
  21. package/.env.example +0 -3
  22. package/AGENTS.md +0 -37
  23. package/CLAUDE.md +0 -233
  24. package/call-exact-format.ts +0 -66
  25. package/call-wait-null.ts +0 -71
  26. package/create-agent-simple.ts +0 -84
  27. package/create-new-agent.ts +0 -98
  28. package/demo-agent-system-prompt.xml +0 -166
  29. package/elevenlabs-voice-agent-mcp-1.0.0.tgz +0 -0
  30. package/em_positive_leads.csv +0 -25
  31. package/list-resources.ts +0 -93
  32. package/make-call-now.ts +0 -66
  33. package/make-test-call.ts +0 -80
  34. package/openapi.json +0 -3238
  35. package/src/constants.ts +0 -62
  36. package/src/index.ts +0 -141
  37. package/src/schemas/agent-schemas.ts +0 -193
  38. package/src/schemas/batch-calling-schemas.ts +0 -96
  39. package/src/schemas/common-schemas.ts +0 -83
  40. package/src/schemas/conversation-schemas.ts +0 -44
  41. package/src/schemas/outbound-schemas.ts +0 -70
  42. package/src/schemas/phone-number-schemas.ts +0 -140
  43. package/src/schemas/tool-schemas.ts +0 -161
  44. package/src/services/elevenlabs-api.ts +0 -113
  45. package/src/services/formatters.ts +0 -623
  46. package/src/tools/agent-tools.ts +0 -425
  47. package/src/tools/batch-calling-tools.ts +0 -237
  48. package/src/tools/conversation-tools.ts +0 -167
  49. package/src/tools/knowledge-tools.ts +0 -73
  50. package/src/tools/outbound-tools.ts +0 -95
  51. package/src/tools/phone-number-tools.ts +0 -346
  52. package/src/tools/tool-tools.ts +0 -195
  53. package/src/tools/utility-tools.ts +0 -147
  54. package/src/types.ts +0 -327
  55. package/src/utils/error-handlers.ts +0 -98
  56. package/src/utils/truncation.ts +0 -97
  57. package/test-call-wait-for-hello.ts +0 -76
  58. package/test-call.json +0 -5
  59. package/tsconfig.json +0 -21
@@ -1,98 +0,0 @@
1
- /**
2
- * Error handling utilities for ElevenLabs API requests
3
- *
4
- * Provides consistent error handling and user-friendly error messages
5
- * for various API error scenarios.
6
- */
7
-
8
- import axios from "axios";
9
-
10
- /**
11
- * Handles errors from ElevenLabs API requests
12
- *
13
- * @param error - The error object from axios or other sources
14
- * @param context - Additional context about the operation (e.g., "creating agent")
15
- * @returns User-friendly error message with actionable guidance
16
- */
17
- export function handleElevenLabsError(error: unknown, context?: string): string {
18
- const prefix = context ? `Error ${context}: ` : "Error: ";
19
-
20
- if (axios.isAxiosError(error)) {
21
- if (error.response) {
22
- // Server responded with error status
23
- const status = error.response.status;
24
- const data = error.response.data as { detail?: string; message?: string };
25
- const detail = data?.detail || data?.message;
26
-
27
- switch (status) {
28
- case 400:
29
- return `${prefix}Invalid request - ${detail || "Check your parameters"}`;
30
- case 401:
31
- return `${prefix}Invalid API key. Please check your ELEVENLABS_API_KEY environment variable.`;
32
- case 403:
33
- return `${prefix}Access forbidden. Your API key may not have permission for this operation.`;
34
- case 404:
35
- return `${prefix}Resource not found. Please verify the ID is correct.`;
36
- case 409:
37
- return `${prefix}Conflict - ${detail || "Resource already exists or is in use"}`;
38
- case 422:
39
- return `${prefix}Validation error - ${detail || "Invalid data format"}`;
40
- case 429:
41
- return `${prefix}Rate limit exceeded. Please wait 60 seconds before retrying.`;
42
- case 500:
43
- return `${prefix}ElevenLabs server error. Please try again in a few moments.`;
44
- case 503:
45
- return `${prefix}Service temporarily unavailable. Please try again later.`;
46
- default:
47
- return `${prefix}API request failed with status ${status}${detail ? `: ${detail}` : ""}`;
48
- }
49
- } else if (error.code === "ECONNABORTED") {
50
- return `${prefix}Request timed out. Please try again or check your network connection.`;
51
- } else if (error.code === "ENOTFOUND" || error.code === "ECONNREFUSED") {
52
- return `${prefix}Cannot connect to ElevenLabs API. Please check your internet connection.`;
53
- } else if (error.message) {
54
- return `${prefix}Network error - ${error.message}`;
55
- }
56
- }
57
-
58
- // Generic error handling
59
- if (error instanceof Error) {
60
- return `${prefix}${error.message}`;
61
- }
62
-
63
- return `${prefix}Unexpected error occurred: ${String(error)}`;
64
- }
65
-
66
- /**
67
- * Validates that the API key is present in environment
68
- *
69
- * @throws Error if ELEVENLABS_API_KEY is not set
70
- */
71
- export function validateApiKey(): void {
72
- if (!process.env.ELEVENLABS_API_KEY) {
73
- throw new Error(
74
- "ELEVENLABS_API_KEY environment variable is not set. " +
75
- "Please set it to your ElevenLabs API key."
76
- );
77
- }
78
- }
79
-
80
- /**
81
- * Wraps an async function with error handling
82
- *
83
- * @param fn - The async function to wrap
84
- * @param context - Context for error messages
85
- * @returns Wrapped function that handles errors consistently
86
- */
87
- export function withErrorHandling<T extends unknown[], R>(
88
- fn: (...args: T) => Promise<R>,
89
- context?: string
90
- ): (...args: T) => Promise<R> {
91
- return async (...args: T): Promise<R> => {
92
- try {
93
- return await fn(...args);
94
- } catch (error) {
95
- throw new Error(handleElevenLabsError(error, context));
96
- }
97
- };
98
- }
@@ -1,97 +0,0 @@
1
- /**
2
- * Response truncation utilities
3
- *
4
- * Handles truncation of large responses to stay within MCP character limits
5
- * while providing clear guidance to users.
6
- */
7
-
8
- import { CHARACTER_LIMIT } from "../constants.js";
9
-
10
- /**
11
- * Truncates content if it exceeds the character limit
12
- *
13
- * @param content - The content to potentially truncate
14
- * @param context - Additional context or guidance for the user
15
- * @returns Original or truncated content with indicator
16
- */
17
- export function truncateIfNeeded(content: string, context?: string): string {
18
- if (content.length <= CHARACTER_LIMIT) {
19
- return content;
20
- }
21
-
22
- const truncated = content.substring(0, CHARACTER_LIMIT);
23
- const guidance = context || "Consider using filters or pagination to see more results";
24
-
25
- return `${truncated}\n\n[TRUNCATED: Response exceeded ${CHARACTER_LIMIT} characters. ${guidance}]`;
26
- }
27
-
28
- /**
29
- * Truncates an array of items and provides pagination guidance
30
- *
31
- * @param items - Array of items that might need truncation
32
- * @param formatter - Function to format each item as a string
33
- * @param currentOffset - Current pagination offset
34
- * @param context - Additional context for users
35
- * @returns Formatted and potentially truncated string
36
- */
37
- export function truncateArray<T>(
38
- items: T[],
39
- formatter: (item: T, index: number) => string,
40
- currentOffset: number = 0,
41
- context?: string
42
- ): string {
43
- let result = "";
44
- let count = 0;
45
-
46
- for (let i = 0; i < items.length; i++) {
47
- const formatted = formatter(items[i], i);
48
-
49
- if (result.length + formatted.length > CHARACTER_LIMIT) {
50
- const nextOffset = currentOffset + count;
51
- const guidance = context || `Use offset=${nextOffset} to continue from where truncation occurred`;
52
- result += `\n\n[TRUNCATED: Response exceeded ${CHARACTER_LIMIT} characters. ${guidance}]`;
53
- break;
54
- }
55
-
56
- result += formatted;
57
- count++;
58
- }
59
-
60
- return result;
61
- }
62
-
63
- /**
64
- * Safely truncates a string in the middle, preserving start and end
65
- *
66
- * @param content - Content to truncate
67
- * @param maxLength - Maximum length
68
- * @returns Truncated string with "..." indicator
69
- */
70
- export function truncateMiddle(content: string, maxLength: number): string {
71
- if (content.length <= maxLength) {
72
- return content;
73
- }
74
-
75
- const halfLength = Math.floor((maxLength - 3) / 2);
76
- const start = content.substring(0, halfLength);
77
- const end = content.substring(content.length - halfLength);
78
-
79
- return `${start}...${end}`;
80
- }
81
-
82
- /**
83
- * Formats a large JSON object with optional truncation
84
- *
85
- * @param obj - Object to format
86
- * @param indent - Indentation spaces (default: 2)
87
- * @returns JSON string, potentially truncated
88
- */
89
- export function formatJSON(obj: unknown, indent: number = 2): string {
90
- const json = JSON.stringify(obj, null, indent);
91
-
92
- if (json.length > CHARACTER_LIMIT) {
93
- return truncateIfNeeded(json, "Response is very large. Consider using filters or requesting specific fields");
94
- }
95
-
96
- return json;
97
- }
@@ -1,76 +0,0 @@
1
- /**
2
- * Test call using Demo Agent with first_message override
3
- * This makes the agent wait for the human to say hello first
4
- */
5
-
6
- import axios from 'axios';
7
-
8
- const apiKey = process.env.ELEVENLABS_API_KEY;
9
-
10
- if (!apiKey) {
11
- console.error('❌ Error: ELEVENLABS_API_KEY environment variable not set');
12
- process.exit(1);
13
- }
14
-
15
- async function makeTestCall() {
16
- try {
17
- console.log('🔄 Initiating test call to Connor...');
18
- console.log('📱 Using: Demo Agent with first_message override');
19
- console.log('⏳ Agent will WAIT for human to speak first\n');
20
-
21
- const response = await axios.post(
22
- 'https://api.elevenlabs.io/v1/convai/twilio/outbound-call',
23
- {
24
- agent_id: 'agent_2601kahgbheaftnr7150xp0x8jbf', // Demo Agent
25
- agent_phone_number_id: 'phnum_4501kayyj6xtfak80g09czq6yzxm', // Atlas St Louis
26
- to_number: '+16184072273', // Connor
27
- conversation_initiation_client_data: {
28
- dynamic_variables: {
29
- lead_name: 'Connor',
30
- rep_name: 'Connor',
31
- lead_email: 'connor@atlasdigitalusa.com',
32
- their_timezone: 'Central Time'
33
- },
34
- // Override the agent's first message to empty string
35
- // This makes it wait for the human to speak first
36
- conversation_config_override: {
37
- agent: {
38
- first_message: '' // Empty string = wait for human
39
- }
40
- }
41
- }
42
- },
43
- {
44
- headers: {
45
- 'xi-api-key': apiKey,
46
- 'Content-Type': 'application/json'
47
- }
48
- }
49
- );
50
-
51
- console.log('✅ Call initiated successfully!\n');
52
- console.log('📞 Call Details:');
53
- console.log('─────────────────────────────────────');
54
- console.log(`Conversation ID: ${response.data.conversation_id}`);
55
- console.log(`Twilio Call SID: ${response.data.callSid}`);
56
- console.log('─────────────────────────────────────\n');
57
- console.log('⚠️ CRITICAL: Agent configured to WAIT for human to speak first!');
58
- console.log(' Connor should say "hello" first, THEN agent will respond.\n');
59
- console.log('Full Response:');
60
- console.log(JSON.stringify(response.data, null, 2));
61
-
62
- } catch (error) {
63
- if (axios.isAxiosError(error)) {
64
- console.error('❌ API Error:', error.response?.status);
65
- console.error('Message:', error.response?.data?.detail || error.message);
66
- if (error.response?.data) {
67
- console.error('Full error:', JSON.stringify(error.response.data, null, 2));
68
- }
69
- } else {
70
- console.error('❌ Unexpected error:', error);
71
- }
72
- process.exit(1);
73
- }
74
- }
75
-
76
- makeTestCall();
package/test-call.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "agent_id": "agent_2601kahgbheaftnr7150xp0x8jbf",
3
- "agent_phone_number_id": "phnum_7801kay1k5qjekb9eqakq1x6a8h0",
4
- "to_number": "+19788066657"
5
- }
package/tsconfig.json DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "Node16",
5
- "moduleResolution": "Node16",
6
- "lib": ["ES2022"],
7
- "outDir": "./dist",
8
- "rootDir": "./src",
9
- "strict": true,
10
- "esModuleInterop": true,
11
- "skipLibCheck": true,
12
- "forceConsistentCasingInFileNames": true,
13
- "declaration": true,
14
- "declarationMap": true,
15
- "sourceMap": true,
16
- "allowSyntheticDefaultImports": true,
17
- "resolveJsonModule": true
18
- },
19
- "include": ["src/**/*"],
20
- "exclude": ["node_modules", "dist"]
21
- }