Skip to content

Skills for Claude Code CLI such as full stack dev Cloudflare, React, Tailwind v4, and AI integrations.

refactor: inline critical references into elevenlabs-agents SKILL.md (#68)

marcusjezweb317b415e9e65
diff --git a/plugins/integrations/skills/elevenlabs-agents/SKILL.md b/plugins/integrations/skills/elevenlabs-agents/SKILL.md
index 49047ff6..90a21f23 100644
--- a/plugins/integrations/skills/elevenlabs-agents/SKILL.md
+++ b/plugins/integrations/skills/elevenlabs-agents/SKILL.md
@@ -23,7 +23,7 @@ npm install @elevenlabs/elevenlabs-js # Full API (server only)
npm install -g @elevenlabs/agents-cli # CLI ("Agents as Code")
```
-**DEPRECATED:** `@11labs/react`, `@11labs/client` — uninstall if present.
+**DEPRECATED:** `@11labs/react`, `@11labs/client` -- uninstall if present.
**Server-only warning:** `@elevenlabs/elevenlabs-js` uses Node.js `child_process` and won't work in browsers. Use `@elevenlabs/client` for browser environments, or create a proxy server.
@@ -31,51 +31,187 @@ npm install -g @elevenlabs/agents-cli # CLI ("Agents as Code")
### Step 1: Create Agent via Dashboard or CLI
-**Dashboard:** https://elevenlabs.io/app/conversational-ai → Create Agent
+**Dashboard:** https://elevenlabs.io/app/conversational-ai -> Create Agent
**CLI (Agents as Code):**
```bash
-elevenlabs-cli init my-agent
-# Edit agent.config.ts with agent settings
-elevenlabs-cli deploy
+elevenlabs agents init
+elevenlabs agents add "Support Bot" --template customer-service
+# Edit agent_configs/support-bot.json
+elevenlabs agents push --env dev
```
+Templates: `default`, `minimal`, `voice-only`, `text-only`, `customer-service`, `assistant`.
+
Configure:
-- **Voice** — Choose from 5000+ voices or clone
-- **LLM** — GPT, Claude, Gemini, or custom
-- **System prompt** — See `assets/system-prompt-template.md`
-- **First message** — What the agent says when conversation starts
+- **Voice** -- Choose from 5000+ voices or clone
+- **LLM** -- GPT, Claude, Gemini, or custom
+- **System prompt** -- Use the 6-component framework below
+- **First message** -- What the agent says when conversation starts
+
+### Step 2: Write the System Prompt
+
+Use the 6-component framework for effective agent prompts:
+
+**1. Personality** -- who the agent is:
+```
+You are [NAME], a [ROLE] at [COMPANY].
+You have [EXPERIENCE]. Your traits: [LIST TRAITS].
+```
+
+**2. Environment** -- communication context:
+```
+You're communicating via [phone/chat/video].
+Consider [environmental factors]. Adapt to [context].
+```
+
+**3. Tone** -- speech patterns and formality:
+```
+Tone: Professional yet warm. Use contractions for natural speech.
+Avoid jargon. Keep responses to 2-3 sentences. Ask one question at a time.
+```
+
+**4. Goal** -- objectives and success criteria:
+```
+Primary Goal: Resolve customer issues on the first call.
+Success: Customer verbally confirms issue is resolved.
+```
+
+**5. Guardrails** -- boundaries and ethics:
+```
+Never: provide medical/legal/financial advice, share confidential info.
+Always: verify identity before account access, document interactions.
+Escalation: customer requests manager, issue beyond knowledge base.
+```
+
+**6. Tools** -- available functions and when to use them:
+```
+1. lookup_order(order_id) -- Use when customer mentions an order.
+2. transfer_to_supervisor() -- Use when issue requires manager approval.
+Always explain what you're doing before calling a tool.
+```
-### Step 2: Add Tools
+### Step 3: Add Tools
-Tools let the agent take actions during conversation:
+**Client-side tools (run in browser):**
```typescript
-// Client-side tools (run in browser)
const clientTools = {
+ updateCart: {
+ description: "Add or remove items from the shopping cart",
+ parameters: z.object({
+ action: z.enum(['add', 'remove']),
+ item: z.string(),
+ quantity: z.number().min(1)
+ }),
+ handler: async ({ action, item, quantity }) => {
+ const cart = getCart();
+ action === 'add' ? cart.add(item, quantity) : cart.remove(item, quantity);
+ return { success: true, total: cart.total, items: cart.items.length };
+ }
+ },
navigate: {
- description: "Navigate to a page",
- parameters: { type: "object", properties: { url: { type: "string" } } },
- handler: async ({ url }) => { window.location.href = url; return "Navigated"; }
+ description: "Navigate user to a different page",
+ parameters: z.object({ url: z.string().url() }),
+ handler: async ({ url }) => { window.location.href = url; return { success: true }; }
}
};
+```
-// Server-side tools (webhooks)
-// Configure in dashboard: Settings → Tools → Add Webhook
+**Server-side tools (webhooks):**
+
+```json
+{
+ "name": "get_weather",
+ "description": "Fetch current weather for a city",
+ "url": "https://api.weather.com/v1/current",
+ "method": "GET",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "city": { "type": "string", "description": "City name" }
+ },
+ "required": ["city"]
+ },
+ "headers": {
+ "Authorization": "Bearer {{secret__weather_api_key}}"
+ }
+}
```
-See `references/tool-examples.md` for patterns.
+Use `{{secret__key_name}}` for API keys in webhook headers -- never hardcode.
+
+**MCP Tools -- CRITICAL COMPATIBILITY NOTE:**
+
+ElevenLabs labels their MCP integration as "Streamable HTTP" but does NOT support the actual MCP 2025-03-26 Streamable HTTP spec (SSE responses). ElevenLabs expects:
+
+- Plain JSON responses (`application/json`), NOT SSE (`text/event-stream`)
+- Protocol version `2024-11-05`, NOT `2025-03-26`
+- Simple JSON-RPC over HTTP with direct JSON responses
+
+What does NOT work:
+- Official MCP SDK's `createMcpHandler` (returns SSE)
+- Cloudflare Agents SDK `McpServer.serve()` (returns SSE)
+- Any server returning `Content-Type: text/event-stream`
+
+Working MCP server pattern for ElevenLabs:
+
+```typescript
+import { Hono } from 'hono';
+import { cors } from 'hono/cors';
+
+const tools = [{
+ name: "my_tool",
+ description: "Tool description",
+ inputSchema: {
+ type: "object",
+ properties: { param1: { type: "string", description: "Description" } },
+ required: ["param1"]
+ }
+}];
+
+async function handleMCPRequest(request, env) {
+ const { id, method, params } = request;
+ switch (method) {
+ case 'initialize':
+ return {
+ jsonrpc: '2.0', id,
+ result: {
+ protocolVersion: '2024-11-05', // MUST be 2024-11-05
+ serverInfo: { name: 'my-mcp', version: '1.0.0' },
+ capabilities: { tools: {} }
+ }
+ };
+ case 'tools/list':
+ return { jsonrpc: '2.0', id, result: { tools } };
+ case 'tools/call':
+ const result = await handleTool(params.name, params.arguments, env);
+ return { jsonrpc: '2.0', id, result };
+ default:
+ return { jsonrpc: '2.0', id, error: { code: -32601, message: `Unknown: ${method}` } };
+ }
+}
+
+const app = new Hono();
+app.use('/*', cors({ origin: '*', allowMethods: ['GET', 'POST', 'OPTIONS'] }));
+app.post('/mcp', async (c) => {
+ const body = await c.req.json();
+ return c.json(await handleMCPRequest(body, c.env)); // Plain JSON, NOT SSE
+});
+export default app;
+```
-### Step 3: Add Knowledge Base (RAG)
+### Step 4: Add Knowledge Base (RAG)
Upload documents for the agent to reference:
- PDFs, text files, web URLs
-- Configure via dashboard or API
+- Configure via dashboard: Agent -> Knowledge Base -> Upload
+- Or via API: `POST /v1/convai/knowledge-base/upload` (multipart/form-data)
- Agent automatically searches knowledge base during conversation
-### Step 4: Integrate SDK
+### Step 5: Integrate SDK
-**React** — copy and customise `assets/react-sdk-boilerplate.tsx`:
+**React** -- copy and customise `assets/react-sdk-boilerplate.tsx`:
```typescript
import { useConversation } from '@elevenlabs/react';
@@ -84,30 +220,119 @@ const { startConversation, stopConversation, status } = useConversation({
agentId: 'your-agent-id',
signedUrl: '/api/elevenlabs/auth',
clientTools,
+ dynamicVariables: {
+ user_name: 'John',
+ account_type: 'premium',
+ },
onEvent: (event) => { /* transcript, agent_response, tool_call */ },
});
```
-**React Native** — see `assets/react-native-boilerplate.tsx`
-**Widget embed** — see `assets/widget-embed-template.html`
-**Swift** — see `assets/swift-sdk-boilerplate.swift`
+System prompt references dynamic variables as `{{user_name}}`.
+
+**React Native** -- see `assets/react-native-boilerplate.tsx`
+**Widget embed** -- see `assets/widget-embed-template.html`
+**Swift** -- see `assets/swift-sdk-boilerplate.swift`
-### Step 5: Test and Deploy
+### Step 6: Test
+
+**CLI testing:**
```bash
-# Test locally
-elevenlabs-cli test my-agent
+# Run all tests for an agent
+elevenlabs agents test "Support Agent"
+
+# Add a test scenario
+elevenlabs tests add "Refund Request" --template basic-llm
+```
+
+**Test configuration:**
+
+```json
+{
+ "name": "Refund Request Test",
+ "scenario": "Customer requests refund for defective product",
+ "user_input": "I want a refund for order #12345. The product arrived broken.",
+ "success_criteria": [
+ "Agent acknowledges the issue empathetically",
+ "Agent asks for or uses provided order number",
+ "Agent verifies order details",
+ "Agent provides clear next steps or refund timeline"
+ ],
+ "evaluation_type": "llm"
+}
+```
-# Simulate conversation
-elevenlabs-cli simulate my-agent --scenario "Book appointment for tomorrow"
+**Tool call testing:**
-# Deploy
-elevenlabs-cli deploy my-agent
+```json
+{
+ "name": "Order Lookup Test",
+ "scenario": "Customer asks about order status",
+ "user_input": "What's the status of order ORD-12345?",
+ "expected_tool_call": {
+ "tool_name": "lookup_order",
+ "parameters": { "order_id": "ORD-12345" }
+ }
+}
```
-Before deploying, run a dry-run first: `elevenlabs-cli deploy my-agent --dry-run` to review changes.
+**API simulation:**
-For conversation simulation, create a JSON test scenario based on `assets/simulation-template.json`.
+```typescript
+const simulation = await client.agents.simulate({
+ agent_id: 'agent_123',
+ scenario: 'Customer requests refund',
+ user_messages: [
+ "I want a refund for order #12345",
+ "It arrived broken",
+ "Yes, process the refund"
+ ],
+ success_criteria: [
+ "Agent shows empathy",
+ "Agent verifies order",
+ "Agent provides timeline"
+ ]
+});
+console.log('Passed:', simulation.passed);
+```
+
+**CI/CD integration:**
+
+```yaml
+name: Test Agent
+on: [push, pull_request]
+jobs:
+ test:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - run: npm install -g @elevenlabs/cli
+ - run: elevenlabs tests push
+ env:
+ ELEVENLABS_API_KEY: ${{ secrets.ELEVENLABS_API_KEY }}
+ - run: elevenlabs agents test "Support Agent"
+ env:
+ ELEVENLABS_API_KEY: ${{ secrets.ELEVENLABS_API_KEY }}
+```
+
+### Step 7: Deploy
+
+```bash
+# Dry run first (always)
+elevenlabs agents push --env prod --dry-run
+
+# Deploy to production
+elevenlabs agents push --env prod
+```
+
+Multi-environment workflow:
+```bash
+elevenlabs agents push --env dev # Development
+elevenlabs agents push --env staging # Staging
+elevenlabs agents test "Agent Name" # Test in staging
+elevenlabs agents push --env prod # Production
+```
---
@@ -118,13 +343,15 @@ For conversation simulation, create a JSON test scenario based on `assets/simula
Never expose API keys in client code. Use a server endpoint:
```typescript
-// Server endpoint
app.get('/api/elevenlabs/auth', async (req, res) => {
- const response = await fetch('https://api.elevenlabs.io/v1/convai/conversation/get-signed-url', {
- headers: { 'xi-api-key': process.env.ELEVENLABS_API_KEY },
- body: JSON.stringify({ agent_id: 'your-agent-id' }),
- method: 'POST'
- });
+ const response = await fetch(
+ 'https://api.elevenlabs.io/v1/convai/conversation/get-signed-url',
+ {
+ headers: { 'xi-api-key': process.env.ELEVENLABS_API_KEY },
+ body: JSON.stringify({ agent_id: 'your-agent-id' }),
+ method: 'POST'
+ }
+ );
const { signed_url } = await response.json();
res.json({ signed_url });
});
@@ -132,47 +359,89 @@ app.get('/api/elevenlabs/auth', async (req, res) => {
### Agent Versioning (A/B Testing)
-Create version branches for testing different configurations:
-- Dashboard: Agent → Versions → Create Branch
-- Compare metrics between versions
-- Promote winning version to production
+Dashboard: Agent -> Versions -> Create Branch. Compare metrics, promote winner.
-### Dynamic Variables
+### Post-Call Webhook
-Pass user context to the agent's system prompt:
+```json
+{
+ "type": "post_call_transcription",
+ "data": {
+ "conversation_id": "conv_xyz789",
+ "transcript": "...",
+ "duration_seconds": 120,
+ "analysis": { "sentiment": "positive", "resolution": true }
+ }
+}
+```
+Verify with HMAC SHA-256:
```typescript
-const { startConversation } = useConversation({
- agentId: 'your-agent-id',
- dynamicVariables: {
- user_name: 'John',
- account_type: 'premium',
- }
-});
+const hmac = crypto.createHmac('sha256', process.env.WEBHOOK_SECRET)
+ .update(JSON.stringify(request.body)).digest('hex');
+if (signature !== hmac) { /* reject */ }
+```
+
+---
+
+## Cost Optimisation
+
+| Model | Cost/1M tokens | Speed | Best For |
+|-------|---------------|-------|----------|
+| GPT-4o | $5 | Medium | Complex reasoning |
+| GPT-4o-mini | $0.15 | Fast | Most use cases |
+| Claude Sonnet 4.5 | $3 | Medium | Long context |
+| Gemini 2.5 Flash | $0.075 | Fastest | Simple tasks |
+
+**Start with gpt-4o-mini** for all agents. Upgrade only if quality requires it.
+
+Key savings:
+- **LLM caching**: up to 90% on repeated prompts (enable in config)
+- **Prompt length**: 150 tokens > 500 tokens for same instructions
+- **RAG over context**: use knowledge base instead of stuffing system prompt
+- **Duration limits**: set `max_duration_seconds` to prevent runaway conversations
+- **Turn mode**: "patient" mode = fewer LLM calls = lower cost
+
+---
+
+## CLI Quick Reference
+
+```bash
+elevenlabs auth login # Authenticate
+elevenlabs agents init # Init project
+elevenlabs agents add "Name" --template default # Add agent
+elevenlabs agents push --env dev # Deploy to dev
+elevenlabs agents push --env prod --dry-run # Preview prod deploy
+elevenlabs agents push --env prod # Deploy to prod
+elevenlabs agents pull # Pull from platform
+elevenlabs agents test "Name" # Run tests
+elevenlabs agents list # List agents
+elevenlabs agents status # Check sync status
+elevenlabs agents widget "Name" # Generate widget
+elevenlabs tools add-webhook "Name" --config-path tool.json # Add tool
+elevenlabs tests add "Name" --template basic-llm # Add test
```
-System prompt references them as `{{user_name}}`.
+Environment: `ELEVENLABS_API_KEY` for CI/CD.
+
+---
+
+## Optional References
+
+For specialised use cases, see:
+- `references/api-reference.md` -- full REST API for programmatic agent management
+- `references/compliance-guide.md` -- GDPR, HIPAA, PCI DSS, data residency
+- `references/workflow-examples.md` -- multi-agent routing, escalation, multi-language
---
## Asset Files
-- `assets/react-sdk-boilerplate.tsx` — React integration template
-- `assets/react-native-boilerplate.tsx` — React Native template
-- `assets/swift-sdk-boilerplate.swift` — Swift/iOS template
-- `assets/javascript-sdk-boilerplate.js` — Vanilla JS template
-- `assets/widget-embed-template.html` — Embeddable widget
-- `assets/system-prompt-template.md` — System prompt guide
-- `assets/agent-config-schema.json` — Config schema reference
-- `assets/ci-cd-example.yml` — CI/CD pipeline template
-
-## Reference Files
-
-- `references/api-reference.md` — Full API endpoints
-- `references/tool-examples.md` — Client and server tool patterns
-- `references/system-prompt-guide.md` — Prompt engineering for agents
-- `references/cli-commands.md` — CLI reference
-- `references/workflow-examples.md` — End-to-end workflow examples
-- `references/testing-guide.md` — Testing and simulation
-- `references/cost-optimization.md` — Pricing and optimisation
-- `references/compliance-guide.md` — Data residency and compliance
+- `assets/react-sdk-boilerplate.tsx` -- React integration template
+- `assets/react-native-boilerplate.tsx` -- React Native template
+- `assets/swift-sdk-boilerplate.swift` -- Swift/iOS template
+- `assets/javascript-sdk-boilerplate.js` -- Vanilla JS template
+- `assets/widget-embed-template.html` -- Embeddable widget
+- `assets/system-prompt-template.md` -- System prompt guide
+- `assets/agent-config-schema.json` -- Config schema reference
+- `assets/ci-cd-example.yml` -- CI/CD pipeline template
diff --git a/plugins/integrations/skills/elevenlabs-agents/references/cli-commands.md b/plugins/integrations/skills/elevenlabs-agents/references/cli-commands.md
deleted file mode 100644
index c26e8c76..00000000
--- a/plugins/integrations/skills/elevenlabs-agents/references/cli-commands.md
+++ /dev/null
@@ -1,274 +0,0 @@
-# CLI Commands Reference
-
-## Installation
-
-```bash
-npm install -g @elevenlabs/cli
-# or
-pnpm install -g @elevenlabs/cli
-```
-
----
-
-## Authentication
-
-### Login
-```bash
-elevenlabs auth login
-```
-
-### Check Current User
-```bash
-elevenlabs auth whoami
-```
-
-### Set Residency
-```bash
-elevenlabs auth residency eu-residency
-# Options: global | eu-residency | in-residency
-```
-
-### Logout
-```bash
-elevenlabs auth logout
-```
-
----
-
-## Project Initialization
-
-### Initialize New Project
-```bash
-elevenlabs agents init
-```
-
-### Recreate Project Structure
-```bash
-elevenlabs agents init --override
-```
-
----
-
-## Agent Management
-
-### Add Agent
-```bash
-elevenlabs agents add "Agent Name" --template TEMPLATE
-```
-
-**Templates**: default | minimal | voice-only | text-only | customer-service | assistant
-
-### Push to Platform
-```bash
-# Push all agents
-elevenlabs agents push
-
-# Push specific agent
-elevenlabs agents push --agent "Agent Name"
-
-# Push to environment
-elevenlabs agents push --env prod
-
-# Dry run (preview changes)
-elevenlabs agents push --dry-run
-```
-
-### Pull from Platform
-```bash
-# Pull all agents
-elevenlabs agents pull
-
-# Pull specific agent
-elevenlabs agents pull --agent "Agent Name"
-```
-
-### List Agents
-```bash
-elevenlabs agents list
-```
-
-### Check Sync Status
-```bash
-elevenlabs agents status
-```
-
-### Delete Agent
-```bash
-elevenlabs agents delete AGENT_ID
-```
-
-### Generate Widget
-```bash
-elevenlabs agents widget "Agent Name"
-```
-
----
-
-## Tool Management
-
-### Add Webhook Tool
-```bash
-elevenlabs tools add-webhook "Tool Name" --config-path tool_configs/tool.json
-```
-
-### Add Client Tool
-```bash
-elevenlabs tools add-client "Tool Name" --config-path tool_configs/tool.json
-```
-
-### Push Tools
-```bash
-elevenlabs tools push
-```
-
-### Pull Tools
-```bash
-elevenlabs tools pull
-```
-
-### Delete Tool
-```bash
-elevenlabs tools delete TOOL_ID
-
-# Delete all tools
-elevenlabs tools delete --all
-```
-
----
-
-## Testing
-
-### Add Test
-```bash
-elevenlabs tests add "Test Name" --template basic-llm
-```
-
-### Push Tests
-```bash
-elevenlabs tests push
-```
-
-### Pull Tests
-```bash
-elevenlabs tests pull
-```
-
-### Run Test
-```bash
-elevenlabs agents test "Agent Name"
-```
-
----
-
-## Multi-Environment Workflow
-
-```bash
-# Development
-elevenlabs agents push --env dev
-
-# Staging
-elevenlabs agents push --env staging
-
-# Production
-elevenlabs agents push --env prod --dry-run
-# Review changes...
-elevenlabs agents push --env prod
-```
-
----
-
-## Common Workflows
-
-### Create and Deploy Agent
-```bash
-elevenlabs auth login
-elevenlabs agents init
-elevenlabs agents add "Support Bot" --template customer-service
-# Edit agent_configs/support-bot.json
-elevenlabs agents push --env dev
-elevenlabs agents test "Support Bot"
-elevenlabs agents push --env prod
-```
-
-### Update Existing Agent
-```bash
-elevenlabs agents pull
-# Edit agent_configs/agent-name.json
-elevenlabs agents push --dry-run
-elevenlabs agents push
-```
-
-### Promote Agent to Production
-```bash
-# Test in staging first
-elevenlabs agents push --env staging
-elevenlabs agents test "Agent Name"
-
-# If tests pass, promote to prod
-elevenlabs agents push --env prod
-```
-
----
-
-## Environment Variables
-
-```bash
-# For CI/CD
-export ELEVENLABS_API_KEY=your-api-key
-
-# Run commands
-elevenlabs agents push --env prod
-```
-
----
-
-## Troubleshooting
-
-### Reset Project
-```bash
-elevenlabs agents init --override
-elevenlabs agents pull
-```
-
-### Check Version
-```bash
-elevenlabs --version
-```
-
-### Get Help
-```bash
-elevenlabs --help
-elevenlabs agents --help
-elevenlabs tools --help
-```
-
----
-
-## File Locations
-
-### Config Files
-```
-~/.elevenlabs/api_key # API key (if not using keychain)
-```
-
-### Project Files
-```
-./agents.json # Agent registry
-./tools.json # Tool registry
-./tests.json # Test registry
-./agent_configs/*.json # Individual agent configs
-./tool_configs/*.json # Individual tool configs
-./test_configs/*.json # Individual test configs
-```
-
----
-
-## Best Practices
-
-1. **Always use --dry-run** before pushing to production
-2. **Commit configs to Git** for version control
-3. **Use environment-specific configs** (dev/staging/prod)
-4. **Test agents** before deploying
-5. **Pull before editing** to avoid conflicts
-6. **Use templates** for consistency
-7. **Document changes** in commit messages
diff --git a/plugins/integrations/skills/elevenlabs-agents/references/cost-optimization.md b/plugins/integrations/skills/elevenlabs-agents/references/cost-optimization.md
deleted file mode 100644
index a64d0851..00000000
--- a/plugins/integrations/skills/elevenlabs-agents/references/cost-optimization.md
+++ /dev/null
@@ -1,275 +0,0 @@
-# Cost Optimization Guide
-
-## 1. LLM Caching
-
-### How It Works
-- **First request**: Full cost (`input_cache_write`)
-- **Subsequent requests**: 10% cost (`input_cache_read`)
-- **Cache TTL**: 5 minutes to 1 hour (configurable)
-
-### Configuration
-```json
-{
- "llm_config": {
- "caching": {
- "enabled": true,
- "ttl_seconds": 3600
- }
- }
-}
-```
-
-### What Gets Cached
-✅ System prompts
-✅ Tool definitions
-✅ Knowledge base context
-✅ Recent conversation history
-
-❌ User messages (always fresh)
-❌ Dynamic variables
-❌ Tool responses
-
-### Savings
-**Up to 90%** on cached inputs
-
-**Example**:
-- System prompt: 500 tokens
-- Without caching: 500 tokens × 100 conversations = 50,000 tokens
-- With caching: 500 tokens (first) + 50 tokens × 99 (cached) = 5,450 tokens
-- **Savings**: 89%
-
----
-
-## 2. Model Swapping
-
-### Model Comparison
-
-| Model | Cost (per 1M tokens) | Speed | Quality | Best For |
-|-------|---------------------|-------|---------|----------|
-| GPT-4o | $5 | Medium | Highest | Complex reasoning |
-| GPT-4o-mini | $0.15 | Fast | High | Most use cases |
-| Claude Sonnet 4.5 | $3 | Medium | Highest | Long context |
-| Gemini 2.5 Flash | $0.075 | Fastest | Medium | Simple tasks |
-
-### Configuration
-```json
-{
- "llm_config": {
- "model": "gpt-4o-mini"
- }
-}
-```
-
-### Optimization Strategy
-1. **Start with gpt-4o-mini** for all agents
-2. **Upgrade to gpt-4o** only if:
- - Complex reasoning required
- - High accuracy critical
- - User feedback indicates quality issues
-3. **Use Gemini 2.5 Flash** for:
- - Simple routing/classification
- - FAQ responses
- - Order status lookups
-
-### Savings
-**Up to 97%** (gpt-4o → Gemini 2.5 Flash)
-
----
-
-## 3. Burst Pricing
-
-### How It Works
-- **Normal**: Your subscription concurrency limit (e.g., 10 calls)
-- **Burst**: Up to 3× your limit (e.g., 30 calls)
-- **Cost**: 2× per-minute rate for burst calls
-
-### Configuration
-```json
-{
- "call_limits": {
- "burst_pricing_enabled": true
- }
-}
-```
-
-### When to Use
-✅ Black Friday traffic spikes
-✅ Product launches
-✅ Seasonal demand (holidays)
-✅ Marketing campaigns
-
-❌ Sustained high traffic (upgrade plan instead)
-❌ Unpredictable usage patterns
-
-### Cost Calculation
-**Example**:
-- Subscription: 10 concurrent calls ($0.10/min per call)
-- Traffic spike: 25 concurrent calls
-- Burst calls: 25 - 10 = 15 calls
-- Burst cost: 15 × $0.20/min = $3/min
-- Regular cost: 10 × $0.10/min = $1/min
-- **Total**: $4/min during spike
-
----
-
-## 4. Prompt Optimization
-
-### Reduce Token Count
-
-**Before** (500 tokens):
-```
-You are a highly experienced and knowledgeable customer support specialist with extensive training in technical troubleshooting, customer service best practices, and empathetic communication. You should always maintain a professional yet friendly demeanor while helping customers resolve their issues efficiently and effectively.
-```
-
-**After** (150 tokens):
-```
-You are an experienced support specialist. Be professional, friendly, and efficient.
-```
-
-**Savings**: 70% token reduction
-
-### Use Tools Instead of Context
-
-**Before**: Include FAQ in system prompt (2,000 tokens)
-**After**: Use RAG/knowledge base (100 tokens + retrieval)
-
-**Savings**: 95% for large knowledge bases
-
----
-
-## 5. Turn-Taking Optimization
-
-### Impact on Cost
-
-| Mode | Latency | LLM Calls | Cost Impact |
-|------|---------|-----------|-------------|
-| Eager | Low | More | Higher (more interruptions) |
-| Normal | Medium | Medium | Balanced |
-| Patient | High | Fewer | Lower (fewer interruptions) |
-
-### Recommendation
-Use **Patient** mode for cost-sensitive applications where speed is less critical.
-
----
-
-## 6. Voice Settings
-
-### Speed vs Cost
-
-| Speed | TTS Cost | User Experience |
-|-------|----------|-----------------|
-| 0.7x | Higher (longer audio) | Slow |
-| 1.0x | Baseline | Natural |
-| 1.2x | Lower (shorter audio) | Fast |
-
-### Recommendation
-Use **1.1x speed** for slight cost savings without compromising experience.
-
----
-
-## 7. Conversation Duration Limits
-
-### Configuration
-```json
-{
- "conversation": {
- "max_duration_seconds": 300 // 5 minutes
- }
-}
-```
-
-### Use Cases
-- FAQ bots (limit: 2-3 minutes)
-- Order status (limit: 1 minute)
-- Full support (limit: 10-15 minutes)
-
-### Savings
-Prevents unexpectedly long conversations.
-
----
-
-## 8. Analytics-Driven Optimization
-
-### Monitor Metrics
-1. **Average conversation duration**
-2. **LLM tokens per conversation**
-3. **Tool call frequency**
-4. **Resolution rate**
-
-### Identify Issues
-- Long conversations → improve prompts or add escalation
-- High token count → enable caching or shorten prompts
-- Low resolution rate → upgrade model or improve knowledge base
-
----
-
-## 9. Cost Monitoring
-
-### API Usage Tracking
-```typescript
-const usage = await client.analytics.getLLMUsage({
- agent_id: 'agent_123',
- from_date: '2025-11-01',
- to_date: '2025-11-30'
-});
-
-console.log('Total tokens:', usage.total_tokens);
-console.log('Cached tokens:', usage.cached_tokens);
-console.log('Cost:', usage.total_cost);
-```
-
-### Set Budgets
-```json
-{
- "cost_limits": {
- "daily_budget_usd": 100,
- "monthly_budget_usd": 2000
- }
-}
-```
-
----
-
-## 10. Cost Optimization Checklist
-
-### Before Launch
-- [ ] Enable LLM caching
-- [ ] Use gpt-4o-mini (not gpt-4o)
-- [ ] Optimize prompt length
-- [ ] Set conversation duration limits
-- [ ] Use RAG instead of large system prompts
-- [ ] Configure burst pricing if needed
-
-### During Operation
-- [ ] Monitor LLM token usage weekly
-- [ ] Review conversation analytics monthly
-- [ ] Test cheaper models quarterly
-- [ ] Optimize prompts based on analytics
-- [ ] Review and remove unused tools
-
-### Continuous Improvement
-- [ ] A/B test cheaper models
-- [ ] Analyze long conversations
-- [ ] Improve resolution rates
-- [ ] Reduce average conversation duration
-- [ ] Increase cache hit rates
-
----
-
-## Expected Savings
-
-**Baseline Configuration**:
-- Model: gpt-4o
-- No caching
-- Average prompt: 1,000 tokens
-- Average conversation: 5 minutes
-- Cost: ~$0.50/conversation
-
-**Optimized Configuration**:
-- Model: gpt-4o-mini
-- Caching enabled
-- Average prompt: 300 tokens
-- Average conversation: 3 minutes
-- Cost: ~$0.05/conversation
-
-**Total Savings**: **90%** 🎉
diff --git a/plugins/integrations/skills/elevenlabs-agents/references/system-prompt-guide.md b/plugins/integrations/skills/elevenlabs-agents/references/system-prompt-guide.md
deleted file mode 100644
index f86a33af..00000000
--- a/plugins/integrations/skills/elevenlabs-agents/references/system-prompt-guide.md
+++ /dev/null
@@ -1,276 +0,0 @@
-# System Prompt Engineering Guide
-
-## 6-Component Framework
-
-### 1. Personality
-Define who the agent is.
-
-**Template**:
-```
-You are [NAME], a [ROLE/PROFESSION] at [COMPANY].
-You have [EXPERIENCE/BACKGROUND].
-Your traits: [LIST PERSONALITY TRAITS].
-```
-
-**Example**:
-```
-You are Sarah, a patient and knowledgeable technical support specialist at TechCorp.
-You have 7 years of experience helping customers troubleshoot software issues.
-Your traits: patient, empathetic, detail-oriented, solution-focused.
-```
-
-### 2. Environment
-Describe the communication context.
-
-**Template**:
-```
-You're communicating via [CHANNEL: phone/chat/video].
-Consider [ENVIRONMENTAL FACTORS].
-Adapt your communication style to [CONTEXT].
-```
-
-**Example**:
-```
-You're speaking with customers over the phone.
-Background noise and poor connections are common.
-Speak clearly, use short sentences, and occasionally pause for emphasis.
-```
-
-### 3. Tone
-Specify speech patterns and formality.
-
-**Template**:
-```
-Tone: [FORMALITY LEVEL].
-Language: [CONTRACTIONS/JARGON GUIDELINES].
-Verbosity: [SENTENCE LENGTH, RESPONSE LENGTH].
-Emotional Expression: [GUIDELINES].
-```
-
-**Example**:
-```
-Tone: Professional yet warm and approachable.
-Language: Use contractions ("I'm", "let's") for natural conversation. Avoid technical jargon unless the customer uses it first.
-Verbosity: Keep responses to 2-3 sentences. Ask one question at a time.
-Emotional Expression: Express empathy with phrases like "I understand how frustrating that must be."
-```
-
-### 4. Goal
-Define objectives and success criteria.
-
-**Template**:
-```
-Primary Goal: [MAIN OBJECTIVE]
-
-Secondary Goals:
-- [SUPPORTING OBJECTIVE 1]
-- [SUPPORTING OBJECTIVE 2]
-
-Success Criteria:
-- [MEASURABLE OUTCOME 1]
-- [MEASURABLE OUTCOME 2]
-```
-
-**Example**:
-```
-Primary Goal: Resolve customer technical issues on the first call.
-
-Secondary Goals:
-- Verify customer identity securely
-- Document issue details accurately
-- Provide proactive tips to prevent future issues
-
-Success Criteria:
-- Customer verbally confirms their issue is resolved
-- Issue documented in CRM system
-- Customer satisfaction score ≥ 4/5
-```
-
-### 5. Guardrails
-Set boundaries and ethical constraints.
-
-**Template**:
-```
-Never:
-- [PROHIBITED ACTION 1]
-- [PROHIBITED ACTION 2]
-
-Always:
-- [REQUIRED ACTION 1]
-- [REQUIRED ACTION 2]
-
-Escalation Triggers:
-- [CONDITION REQUIRING HUMAN INTERVENTION]
-```
-
-**Example**:
-```
-Never:
-- Provide medical, legal, or financial advice
-- Share confidential company information
-- Make promises about refunds without verification
-- Continue conversation if customer becomes abusive
-
-Always:
-- Verify customer identity before accessing account details
-- Document all interactions in CRM
-- Offer alternative solutions if first approach doesn't work
-
-Escalation Triggers:
-- Customer requests manager
-- Issue requires account credit/refund approval
-- Technical issue beyond your knowledge base
-- Customer exhibits abusive behavior
-```
-
-### 6. Tools
-Describe available functions and when to use them.
-
-**Template**:
-```
-Available Tools:
-
-1. tool_name(parameters)
- Purpose: [WHAT IT DOES]
- Use When: [TRIGGER CONDITION]
- Example: [SAMPLE USAGE]
-
-2. ...
-
-Guidelines:
-- [GENERAL TOOL USAGE RULES]
-```
-
-**Example**:
-```
-Available Tools:
-
-1. lookup_order(order_id: string)
- Purpose: Fetch order details from database
- Use When: Customer mentions an order number or asks about order status
- Example: "Let me look that up for you. [Call lookup_order(order_id='ORD-12345')]"
-
-2. send_password_reset(email: string)
- Purpose: Trigger password reset email
- Use When: Customer can't access account and identity is verified
- Example: "I'll send you a password reset email. [Call send_password_reset(email='[email protected]')]"
-
-3. transfer_to_supervisor()
- Purpose: Escalate to human agent
- Use When: Issue requires manager approval or customer explicitly requests
- Example: "Let me connect you with a supervisor. [Call transfer_to_supervisor()]"
-
-Guidelines:
-- Always explain to the customer what you're doing before calling a tool
-- Wait for tool response before continuing
-- If tool fails, acknowledge and offer alternative
-```
-
----
-
-## Complete Example Templates
-
-### Customer Support Agent
-```
-Personality:
-You are Alex, a friendly and knowledgeable customer support specialist at TechCorp. You have 5 years of experience helping customers solve technical issues. You're patient, empathetic, and always maintain a positive attitude.
-
-Environment:
-You're speaking with customers over the phone. Communication is voice-only. Customers may have background noise or poor connection quality. Speak clearly and use thoughtful pauses for emphasis.
-
-Tone:
-Professional yet warm. Use contractions ("I'm", "let's") to sound natural. Avoid jargon unless the customer uses it first. Keep responses concise (2-3 sentences max). Use encouraging phrases like "I'll be happy to help with that."
-
-Goal:
-Primary: Resolve customer technical issues on the first call.
-Secondary: Verify customer identity, document issues accurately, provide proactive solutions.
-Success: Customer verbally confirms issue is resolved.
-
-Guardrails:
-- Never provide medical/legal/financial advice
-- Don't share confidential company information
-- Escalate if customer becomes abusive
-- Never make promises about refunds without verification
-
-Tools:
-1. lookup_order(order_id) - Fetch order details when customer mentions order number
-2. transfer_to_supervisor() - Escalate when issue requires manager approval
-3. send_password_reset(email) - Trigger reset when customer can't access account
-Always explain what you're doing before calling tools.
-```
-
-### Educational Tutor
-```
-Personality:
-You are Maya, a patient and encouraging math tutor. You have 10 years of experience teaching middle school students. You're enthusiastic about learning and celebrate every small victory.
-
-Environment:
-You're tutoring students via voice chat. Students may feel anxious or frustrated about math. Create a safe, judgment-free environment where mistakes are learning opportunities.
-
-Tone:
-Warm, encouraging, and patient. Never sound frustrated or disappointed. Use positive reinforcement frequently ("Great thinking!", "You're on the right track!"). Adjust complexity based on student's responses.
-
-Goal:
-Primary: Help students understand math concepts, not just get answers.
-Secondary: Build confidence and reduce math anxiety.
-Success: Student can explain the concept in their own words and solve similar problems independently.
-
-Guardrails:
-- Never give answers directly—guide students to discover solutions
-- Don't move to next topic until current concept is mastered
-- If student becomes frustrated, take a break or switch to easier problem
-- Never compare students or use negative language
-
-Tools:
-1. show_visual_aid(concept) - Display diagram or graph to illustrate concept
-2. generate_practice_problem(difficulty) - Create custom practice problem
-3. celebrate_achievement() - Play positive feedback animation
-Always make learning feel like an achievement, not a chore.
-```
-
----
-
-## Prompt Engineering Tips
-
-### Do's:
-✅ Use specific examples in guidelines
-✅ Define success criteria clearly
-✅ Include escalation conditions
-✅ Explain tool usage thoroughly
-✅ Test prompts with real conversations
-✅ Iterate based on analytics
-
-### Don'ts:
-❌ Use overly long prompts (increases cost)
-❌ Be vague about goals or boundaries
-❌ Include conflicting instructions
-❌ Forget to test edge cases
-❌ Use negative language excessively
-❌ Overcomplicate simple tasks
-
----
-
-## Testing Your Prompts
-
-1. **Scenario Testing**: Run automated tests with success criteria
-2. **Edge Case Testing**: Test boundary conditions and unusual inputs
-3. **Tone Testing**: Evaluate conversation tone and empathy
-4. **Tool Testing**: Verify tools are called correctly
-5. **Analytics Review**: Monitor real conversations for issues
-
----
-
-## Prompt Iteration Workflow
-
-```
-1. Write initial prompt using 6-component framework
-2. Deploy to dev environment
-3. Run 5-10 test conversations
-4. Analyze transcripts for issues
-5. Refine prompt based on findings
-6. Deploy to staging
-7. Run automated tests
-8. Review analytics dashboard
-9. Deploy to production
-10. Monitor and iterate
-```
diff --git a/plugins/integrations/skills/elevenlabs-agents/references/testing-guide.md b/plugins/integrations/skills/elevenlabs-agents/references/testing-guide.md
deleted file mode 100644
index 99a7b740..00000000
--- a/plugins/integrations/skills/elevenlabs-agents/references/testing-guide.md
+++ /dev/null
@@ -1,188 +0,0 @@
-# Testing Guide
-
-## 1. Scenario Testing (LLM-Based)
-
-### Create Test
-```bash
-elevenlabs tests add "Refund Request" --template basic-llm
-```
-
-### Test Configuration
-```json
-{
- "name": "Refund Request Test",
- "scenario": "Customer requests refund for defective product",
- "user_input": "I want a refund for order #12345. The product arrived broken.",
- "success_criteria": [
- "Agent acknowledges the issue empathetically",
- "Agent asks for order number or uses provided number",
- "Agent verifies order details",
- "Agent provides clear next steps or refund timeline"
- ],
- "evaluation_type": "llm"
-}
-```
-
-### Run Test
-```bash
-elevenlabs agents test "Support Agent"
-```
-
-## 2. Tool Call Testing
-
-### Test Configuration
-```json
-{
- "name": "Order Lookup Test",
- "scenario": "Customer asks about order status",
- "user_input": "What's the status of order ORD-12345?",
- "expected_tool_call": {
- "tool_name": "lookup_order",
- "parameters": {
- "order_id": "ORD-12345"
- }
- }
-}
-```
-
-## 3. Load Testing
-
-### Basic Load Test
-```bash
-# 100 concurrent users, spawn 10/second, run for 5 minutes
-elevenlabs test load \
- --users 100 \
- --spawn-rate 10 \
- --duration 300
-```
-
-### With Burst Pricing
-```json
-{
- "call_limits": {
- "burst_pricing_enabled": true
- }
-}
-```
-
-## 4. Simulation API
-
-### Programmatic Testing
-```typescript
-const simulation = await client.agents.simulate({
- agent_id: 'agent_123',
- scenario: 'Customer requests refund',
- user_messages: [
- "I want a refund for order #12345",
- "It arrived broken",
- "Yes, process the refund"
- ],
- success_criteria: [
- "Agent shows empathy",
- "Agent verifies order",
- "Agent provides timeline"
- ]
-});
-
-console.log('Passed:', simulation.passed);
-console.log('Criteria met:', simulation.evaluation.criteria_met, '/', simulation.evaluation.criteria_total);
-```
-
-## 5. Convert Real Conversations to Tests
-
-### From Dashboard
-1. Navigate to Conversations
-2. Select conversation
-3. Click "Convert to Test"
-4. Add success criteria
-5. Save
-
-### From API
-```typescript
-const test = await client.tests.createFromConversation({
- conversation_id: 'conv_123',
- success_criteria: [
- "Issue was resolved",
- "Customer satisfaction >= 4/5"
- ]
-});
-```
-
-## 6. CI/CD Integration
-
-### GitHub Actions
-```yaml
-name: Test Agent
-on: [push, pull_request]
-
-jobs:
- test:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v3
-
- - name: Install CLI
- run: npm install -g @elevenlabs/cli
-
- - name: Push Tests
- run: elevenlabs tests push
- env:
- ELEVENLABS_API_KEY: ${{ secrets.ELEVENLABS_API_KEY }}
-
- - name: Run Tests
- run: elevenlabs agents test "Support Agent"
- env:
- ELEVENLABS_API_KEY: ${{ secrets.ELEVENLABS_API_KEY }}
-```
-
-## 7. Test Organization
-
-### Directory Structure
-```
-test_configs/
-├── refund-tests/
-│ ├── basic-refund.json
-│ ├── duplicate-refund.json
-│ └── expired-refund.json
-├── order-lookup-tests/
-│ ├── valid-order.json
-│ └── invalid-order.json
-└── escalation-tests/
- ├── angry-customer.json
- └── complex-issue.json
-```
-
-## 8. Best Practices
-
-### Do's:
-✅ Test all conversation paths
-✅ Include edge cases
-✅ Test tool calls thoroughly
-✅ Run tests before deployment
-✅ Convert failed conversations to tests
-✅ Monitor test trends over time
-
-### Don'ts:
-❌ Only test happy paths
-❌ Ignore failing tests
-❌ Skip load testing
-❌ Test only in production
-❌ Write vague success criteria
-
-## 9. Metrics to Track
-
-- **Pass Rate**: % of tests passing
-- **Tool Accuracy**: % of correct tool calls
-- **Response Time**: Average time to resolution
-- **Load Capacity**: Max concurrent users before degradation
-- **Error Rate**: % of conversations with errors
-
-## 10. Debugging Failed Tests
-
-1. Review conversation transcript
-2. Check tool calls and parameters
-3. Verify dynamic variables provided
-4. Test prompt clarity
-5. Check knowledge base content
-6. Review guardrails and constraints
-7. Iterate and retest
diff --git a/plugins/integrations/skills/elevenlabs-agents/references/tool-examples.md b/plugins/integrations/skills/elevenlabs-agents/references/tool-examples.md
deleted file mode 100644
index 1e4fcd4b..00000000
--- a/plugins/integrations/skills/elevenlabs-agents/references/tool-examples.md
+++ /dev/null
@@ -1,266 +0,0 @@
-# Tool Examples
-
-## Client Tools (Browser-Side)
-
-### Update Shopping Cart
-```typescript
-import { useConversation } from '@elevenlabs/react';
-import { z } from 'zod';
-
-clientTools: {
- updateCart: {
- description: "Add or remove items from the shopping cart",
- parameters: z.object({
- action: z.enum(['add', 'remove']),
- item: z.string(),
- quantity: z.number().min(1)
- }),
- handler: async ({ action, item, quantity }) => {
- const cart = getCart();
- if (action === 'add') {
- cart.add(item, quantity);
- } else {
- cart.remove(item, quantity);
- }
- return { success: true, total: cart.total, items: cart.items.length };
- }
- }
-}
-```
-
-### Navigate to Page
-```typescript
-navigate: {
- description: "Navigate user to a different page",
- parameters: z.object({
- url: z.string().url()
- }),
- handler: async ({ url }) => {
- window.location.href = url;
- return { success: true };
- }
-}
-```
-
-## Server Tools (Webhooks)
-
-### Get Weather
-```json
-{
- "name": "get_weather",
- "description": "Fetch current weather for a city",
- "url": "https://api.weather.com/v1/current",
- "method": "GET",
- "parameters": {
- "type": "object",
- "properties": {
- "city": { "type": "string", "description": "City name (e.g., 'London')" }
- },
- "required": ["city"]
- },
- "headers": {
- "Authorization": "Bearer {{secret__weather_api_key}}"
- }
-}
-```
-
-### Stripe Payment
-```json
-{
- "name": "create_payment_intent",
- "description": "Create a Stripe payment intent for order",
- "url": "https://api.stripe.com/v1/payment_intents",
- "method": "POST",
- "parameters": {
- "type": "object",
- "properties": {
- "amount": { "type": "number", "description": "Amount in cents" },
- "currency": { "type": "string", "description": "Currency code (e.g., 'usd')" }
- },
- "required": ["amount", "currency"]
- },
- "headers": {
- "Authorization": "Bearer {{secret__stripe_api_key}}"
- }
-}
-```
-
-### CRM Integration
-```json
-{
- "name": "update_crm",
- "description": "Update customer record in CRM",
- "url": "https://api.salesforce.com/services/data/v57.0/sobjects/Contact/{{contact_id}}",
- "method": "PATCH",
- "parameters": {
- "type": "object",
- "properties": {
- "notes": { "type": "string" },
- "status": { "type": "string", "enum": ["active", "resolved", "pending"] }
- }
- },
- "headers": {
- "Authorization": "Bearer {{secret__salesforce_token}}",
- "Content-Type": "application/json"
- }
-}
-```
-
-## MCP Tools
-
-### Critical: ElevenLabs MCP Server Compatibility
-
-ElevenLabs labels their MCP integration as "Streamable HTTP" but **does NOT support** the actual MCP 2025-03-26 Streamable HTTP spec (SSE responses). Instead, ElevenLabs expects:
-
-- **Plain JSON responses** (`application/json`), NOT SSE (`text/event-stream`)
-- **Protocol version `2024-11-05`**, NOT the newer `2025-03-26`
-- **Simple JSON-RPC over HTTP** with direct JSON responses
-
-**What DOES NOT work:**
-- Official MCP SDK's `createMcpHandler` (returns SSE format)
-- Cloudflare Agents SDK `McpServer.serve()` (returns SSE format)
-- Any server returning `Content-Type: text/event-stream`
-
-**What WORKS:**
-- Raw Hono + JSON-RPC pattern with `c.json()` responses
-- Protocol version `2024-11-05` in initialize response
-- Plain `application/json` Content-Type
-
-### Working MCP Server Pattern for ElevenLabs
-
-```typescript
-import { Hono } from 'hono';
-import { cors } from 'hono/cors';
-
-const tools = [{
- name: "my_tool",
- description: "Tool description",
- inputSchema: {
- type: "object",
- properties: {
- param1: { type: "string", description: "Description" }
- },
- required: ["param1"]
- }
-}];
-
-async function handleMCPRequest(request, env) {
- const { id, method, params } = request;
-
- switch (method) {
- case 'initialize':
- return {
- jsonrpc: '2.0', id,
- result: {
- protocolVersion: '2024-11-05', // MUST be 2024-11-05, NOT 2025-03-26
- serverInfo: { name: 'my-mcp-server', version: '1.0.0' },
- capabilities: { tools: {} }
- }
- };
-
- case 'tools/list':
- return { jsonrpc: '2.0', id, result: { tools } };
-
- case 'tools/call':
- const result = await handleTool(params.name, params.arguments, env);
- return { jsonrpc: '2.0', id, result };
-
- default:
- return { jsonrpc: '2.0', id, error: { code: -32601, message: `Method not found: ${method}` } };
- }
-}
-
-const app = new Hono();
-
-app.use('/*', cors({ origin: '*', allowMethods: ['GET', 'POST', 'OPTIONS'], allowHeaders: ['Content-Type', 'Authorization'] }));
-
-app.post('/mcp', async (c) => {
- const body = await c.req.json();
- const response = await handleMCPRequest(body, c.env);
- return c.json(response); // Plain JSON, NOT SSE
-});
-
-export default app;
-```
-
-### Connect MCP Server in ElevenLabs
-
-In ElevenLabs agent settings → Tools → Custom MCP Server:
-
-```json
-{
- "name": "My MCP Server",
- "server_url": "https://my-mcp.workers.dev/mcp",
- "transport": "streamable_http"
-}
-```
-
-Note: Despite selecting "Streamable HTTP", ElevenLabs actually sends plain JSON-RPC requests and expects plain JSON responses.
-
-### Connect PostgreSQL MCP Server
-```json
-{
- "name": "PostgreSQL Database",
- "server_url": "https://mcp.example.com/postgres",
- "transport": "sse",
- "secret_token": "{{secret__mcp_auth_token}}",
- "approval_mode": "fine_grained"
-}
-```
-
-### Connect File System MCP Server
-```json
-{
- "name": "File System Access",
- "server_url": "https://mcp.example.com/filesystem",
- "transport": "http",
- "approval_mode": "always_ask"
-}
-```
-
-## System Tools
-
-### Update Conversation State
-```json
-{
- "name": "update_state",
- "description": "Update conversation context",
- "parameters": {
- "key": { "type": "string" },
- "value": { "type": "string" }
- }
-}
-```
-
-### Transfer to Human
-```json
-{
- "name": "transfer_to_human",
- "description": "Transfer call to human agent",
- "parameters": {
- "reason": { "type": "string", "description": "Reason for transfer" }
- }
-}
-```
-
-## Best Practices
-
-**Client Tools**:
-- Keep handler logic simple
-- Always return meaningful values
-- Handle errors gracefully
-
-**Server Tools**:
-- Use secret variables for API keys
-- Provide clear parameter descriptions
-- Include format examples in descriptions
-
-**MCP Tools**:
-- Test connectivity before production
-- Use appropriate approval modes
-- Monitor tool usage and errors
-
-**System Tools**:
-- Use for workflow state management
-- Document state schema
-- Clean up state when conversation ends