MCP & Integrations

Connect your agents to external tools and services

MCP (Model Context Protocol) Integration Guide

MCP enables your VOISA AI agents to interact with external tools and services, transforming them from conversational agents into powerful automation systems.

🎯 What is MCP?

Overview

Model Context Protocol (MCP) is a standardized way for AI agents to:

  • Connect to external services
  • Execute actions beyond conversation
  • Access real-time data
  • Integrate with existing systems

Key Capabilities

  • Calendar Integration: Book appointments directly
  • Database Access: Query and update records
  • API Connectivity: Interact with any REST API
  • CRM Integration: Manage customer data
  • Payment Processing: Handle transactions
  • Email/SMS: Send notifications

πŸ—οΈ MCP Architecture

Components

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   VOISA Agent   │────▢│   MCP Server    │────▢│  External Tool  β”‚
β”‚                 │◀────│                 │◀────│                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
      Request              Process                   Execute
      Response             Validate                  Return

How It Works

  1. Agent receives user request
  2. Identifies required tool
  3. Sends request to MCP server
  4. MCP server executes action
  5. Returns result to agent
  6. Agent communicates result to user

πŸš€ Setting Up MCP

Step 1: Access MCP Tools

  1. Log in to voisa.ai/admin
  2. Navigate to "MCP Tools" in sidebar
  3. View available MCP servers

Step 2: Add MCP Server

Server Configuration

Click "+ Add MCP Server" and configure:

Basic Information:

Name: "Calendar Integration Server"
Description: "Manages appointment bookings and calendar operations"
URL: https://api.yourservice.com/mcp

Transport Type:

  • SSE (Server-Sent Events): Real-time updates
  • HTTP: Standard request/response

Approval Policy:

  • Auto-approve all: Tools immediately available
  • Require approval: Manual review needed

Authentication Setup

No Authentication:

{
  "transport": "http",
  "url": "https://api.example.com/mcp"
}

API Key Authentication:

{
  "transport": "http",
  "url": "https://api.example.com/mcp",
  "headers": {
    "Authorization": "Bearer YOUR_API_KEY"
  }
}

OAuth Authentication:

{
  "transport": "http",
  "url": "https://api.example.com/mcp",
  "auth": {
    "type": "oauth2",
    "client_id": "YOUR_CLIENT_ID",
    "client_secret": "YOUR_CLIENT_SECRET"
  }
}

Step 3: Discover Tools

Once connected, the system discovers available tools:

  1. Click on your MCP server
  2. View "Available Tools"
  3. Each tool shows:
    • Name and description
    • Required parameters
    • Return values

πŸ“š Common MCP Integrations

Calendar Integration

Google Calendar Setup

MCP Server Configuration:

{
  "name": "Google Calendar MCP",
  "transport": "http",
  "url": "https://mcp-google-calendar.voisa.ai",
  "auth": {
    "type": "oauth2",
    "scopes": ["calendar.events"]
  }
}

Available Tools:

  • createEvent: Book appointments
  • checkAvailability: Check free slots
  • updateEvent: Modify bookings
  • cancelEvent: Cancel appointments
  • listEvents: View schedule

Usage Example:

User: "I want to book an appointment for next Tuesday at 2 PM"
Agent: [Uses createEvent tool]
Agent: "I've booked your appointment for Tuesday at 2 PM.
        You'll receive a confirmation email shortly."

CRM Integration

Salesforce Setup

MCP Server Configuration:

{
  "name": "Salesforce MCP",
  "transport": "http",
  "url": "https://mcp-salesforce.voisa.ai",
  "auth": {
    "type": "oauth2",
    "instance_url": "https://yourinstance.salesforce.com"
  }
}

Available Tools:

  • createLead: Add new leads
  • updateContact: Modify contact info
  • getAccountInfo: Retrieve account details
  • createCase: Log support tickets
  • addNote: Add conversation notes

Database Integration

PostgreSQL Setup

MCP Server Configuration:

{
  "name": "Database MCP",
  "transport": "http",
  "url": "https://mcp-database.yourcompany.com",
  "config": {
    "connection_string": "postgresql://user:pass@host/db",
    "ssl": true
  }
}

Available Tools:

  • queryInventory: Check stock levels
  • updateOrder: Modify order status
  • getCustomerHistory: Retrieve past orders
  • checkPricing: Get current prices

Payment Processing

Stripe Integration

MCP Server Configuration:

{
  "name": "Stripe MCP",
  "transport": "http",
  "url": "https://mcp-stripe.voisa.ai",
  "auth": {
    "api_key": "sk_live_..."
  }
}

Available Tools:

  • createPaymentIntent: Initialize payment
  • confirmPayment: Process payment
  • refundPayment: Issue refunds
  • getPaymentStatus: Check status

πŸ”§ Creating Custom MCP Tools

Tool Definition

Structure:

{
  "name": "bookAppointment",
  "description": "Books an appointment in the calendar system",
  "parameters": {
    "date": {
      "type": "string",
      "description": "Date in YYYY-MM-DD format",
      "required": true
    },
    "time": {
      "type": "string",
      "description": "Time in HH:MM format",
      "required": true
    },
    "duration": {
      "type": "integer",
      "description": "Duration in minutes",
      "default": 30
    },
    "customer_name": {
      "type": "string",
      "required": true
    },
    "service": {
      "type": "string",
      "enum": ["consultation", "treatment", "follow-up"]
    }
  },
  "returns": {
    "type": "object",
    "properties": {
      "booking_id": "string",
      "confirmation_url": "string",
      "status": "string"
    }
  }
}

Implementation Example

Node.js MCP Server:

const express = require('express');
const app = express();

// MCP endpoint
app.post('/mcp/tools/bookAppointment', async (req, res) => {
  const { date, time, duration, customer_name, service } = req.body;

  try {
    // Your booking logic here
    const booking = await calendarAPI.createBooking({
      date,
      time,
      duration,
      customer_name,
      service
    });

    res.json({
      success: true,
      booking_id: booking.id,
      confirmation_url: booking.url,
      status: "confirmed"
    });
  } catch (error) {
    res.json({
      success: false,
      error: error.message
    });
  }
});

// Tool discovery endpoint
app.get('/mcp/tools', (req, res) => {
  res.json({
    tools: [{
      name: "bookAppointment",
      description: "Books appointments",
      // ... full tool definition
    }]
  });
});

πŸ”Œ Assigning Tools to Agents

Step 1: Navigate to Agent

  1. Go to "Agents" tab
  2. Select your agent
  3. Click "Edit" or "Manage Tools"

Step 2: Assign Tools

  1. Navigate to "Tools" section
  2. View available tools from all MCP servers
  3. Select tools to enable:
    βœ… bookAppointment
    βœ… checkAvailability
    βœ… cancelAppointment
    ☐ processPayment (not needed for this agent)
    

Step 3: Configure Tool Settings

Per-Tool Configuration:

{
  "bookAppointment": {
    "enabled": true,
    "permissions": {
      "max_bookings_per_call": 1,
      "allowed_services": ["consultation", "follow-up"],
      "advance_booking_days": 30
    },
    "defaults": {
      "duration": 30,
      "send_confirmation": true
    }
  }
}

Step 4: Update System Prompt

Include tool awareness in your agent's prompt:

You have access to the following tools:

1. bookAppointment: Use this to schedule appointments
   - Ask for preferred date and time
   - Confirm customer details
   - Specify service type

2. checkAvailability: Check available time slots
   - Use before suggesting times
   - Offer multiple options

3. cancelAppointment: Cancel existing bookings
   - Require booking ID or customer details
   - Confirm cancellation

Always confirm important details before using tools.
After tool execution, clearly communicate the result.

πŸ§ͺ Testing MCP Tools

Test Scenarios

Basic Tool Execution:

User: "I want to book an appointment"
Agent: "I'd be happy to help. What date works for you?"
User: "Next Monday"
Agent: "What time would you prefer?"
User: "2 PM"
Agent: [Executes bookAppointment tool]
Agent: "Perfect! I've booked your appointment for Monday at 2 PM."

Error Handling:

User: "Book me for tomorrow at 3 PM"
Agent: [Tool returns error: slot unavailable]
Agent: "I apologize, but 3 PM tomorrow is not available.
        Would 2 PM or 4 PM work instead?"

Testing Checklist

  • Tool discovery works
  • Authentication successful
  • Parameters validated
  • Successful execution
  • Error handling works
  • Results communicated clearly
  • Timeouts handled
  • Fallbacks available

πŸ“Š Monitoring MCP Performance

Key Metrics

Availability:

  • Server uptime: > 99.9%
  • Tool availability: > 99.5%
  • Response time: < 2 seconds

Usage:

  • Calls per tool
  • Success rate
  • Error frequency
  • Average execution time

Quality:

  • Task completion rate
  • User satisfaction
  • Error recovery rate

Analytics Dashboard

Monitor in real-time:

  1. Go to "Analytics"
  2. Select "MCP Performance"
  3. View metrics by:
    • Tool
    • Server
    • Time period
    • Agent

πŸ”’ Security Considerations

Best Practices

Authentication:

  • Use secure tokens
  • Rotate API keys regularly
  • Implement OAuth when possible
  • Use HTTPS only

Authorization:

  • Limit tool permissions
  • Implement rate limiting
  • Validate all inputs
  • Audit tool usage

Data Protection:

  • Encrypt sensitive data
  • Minimize data exposure
  • Follow GDPR guidelines
  • Implement retention policies

Security Checklist

  • Secure authentication configured
  • SSL/TLS enabled
  • Input validation implemented
  • Rate limiting active
  • Audit logging enabled
  • Error messages sanitized
  • Sensitive data protected
  • Regular security reviews

🚨 Troubleshooting MCP

Common Issues

Tool Discovery Fails:

Problem: Tools not appearing
Solution:
1. Check server URL
2. Verify authentication
3. Test discovery endpoint
4. Check network connectivity

Authentication Errors:

Problem: 401/403 errors
Solution:
1. Verify credentials
2. Check token expiration
3. Confirm permissions
4. Review auth headers

Tool Execution Fails:

Problem: Tool returns errors
Solution:
1. Validate parameters
2. Check server logs
3. Test manually
4. Review error messages

Timeout Issues:

Problem: Tools timing out
Solution:
1. Increase timeout settings
2. Optimize server performance
3. Implement async handling
4. Add retry logic

πŸ“š Advanced MCP Features

Batch Operations

Execute multiple tools in sequence:

{
  "batch": [
    {
      "tool": "checkAvailability",
      "params": { "date": "2025-01-20" }
    },
    {
      "tool": "bookAppointment",
      "params": { "slot": "${result[0].available_slots[0]}" }
    },
    {
      "tool": "sendConfirmation",
      "params": { "booking_id": "${result[1].id}" }
    }
  ]
}

Conditional Execution

Tools with logic:

{
  "tool": "processBooking",
  "conditions": {
    "if": "availability.exists",
    "then": "bookAppointment",
    "else": "addToWaitlist"
  }
}

Event Webhooks

Real-time updates:

{
  "webhooks": {
    "onToolSuccess": "https://your-app.com/webhook/success",
    "onToolError": "https://your-app.com/webhook/error",
    "onTimeout": "https://your-app.com/webhook/timeout"
  }
}

🎯 MCP Best Practices

Design Principles

  1. Keep Tools Focused: Single responsibility
  2. Clear Naming: Descriptive, action-oriented
  3. Comprehensive Docs: Full parameter descriptions
  4. Error Messages: Helpful, actionable
  5. Idempotency: Safe to retry

Implementation Tips

  1. Start Simple: Basic tools first
  2. Test Thoroughly: All scenarios
  3. Monitor Closely: Track performance
  4. Document Well: Clear instructions
  5. Version Control: Track changes

Optimization Strategies

  1. Cache Results: Reduce redundant calls
  2. Batch Operations: Combine related actions
  3. Async Processing: Non-blocking execution
  4. Retry Logic: Handle transient failures
  5. Circuit Breakers: Prevent cascade failures

πŸ“– Resources

Documentation

Examples

Support

⏭️ Next Steps

  1. Test Your Integration
  2. Monitor Performance
  3. Optimize Tools

MCP transforms your agents from conversational to transactional! πŸš€