MCP Tool Calling

Model Context Protocol integration for custom tools

1 min read6 sections

MCP Tool Calling

The Model Context Protocol (MCP) integration allows rtrvr.ai agents to use custom tools and external APIs during task execution. This extends the agent's capabilities beyond web browsing to include database queries, API calls, file operations, and more.

MCP Tool Calling enables agents to dynamically choose and execute the right tools for complex workflows.

Supported Tools

rtrvr.ai supports a wide range of MCP tools out of the box:

  • Database connectors (PostgreSQL, MySQL, MongoDB)
  • Cloud storage (AWS S3, Google Drive, Dropbox)
  • Communication tools (Slack, Discord, Email)
  • CRM integrations (Salesforce, HubSpot, Pipedrive)
  • Analytics platforms (Google Analytics, Mixpanel)
  • Custom HTTP APIs and webhooks

Configuration

Configure MCP tools in your rtrvr.ai dashboard or via API:

json
{
    "tools": [
      {
        "name": "database_query",
        "type": "mcp",
        "config": {
          "connection_string": "postgresql://user:pass@host:5432/db",
          "allowed_operations": ["SELECT", "INSERT"]
        }
      },
      {
        "name": "slack_notify",
        "type": "mcp", 
        "config": {
          "webhook_url": "https://hooks.slack.com/...",
          "default_channel": "#alerts"
        }
      }
    ]
  }

Usage in Prompts

Reference tools naturally in your prompts, and the agent will use them when appropriate:

text
"Scrape the product data from this e-commerce site, then save it to our PostgreSQL database and send a Slack notification to the team"

The agent will automatically:

  • Scrape the website data
  • Use the database_query tool to insert records
  • Use the slack_notify tool to send updates
  • Handle errors and retries across all tools

Custom Tool Development

Create custom MCP tools for your specific needs:

python
from mcp import Tool, Parameter
  
  class CustomAPITool(Tool):
      name = "custom_api"
      description = "Calls our internal API"
      
      parameters = [
          Parameter("endpoint", "string", "API endpoint to call"),
          Parameter("data", "object", "Data to send")
      ]
      
      def execute(self, endpoint: str, data: dict):
          # Your custom logic here
          response = requests.post(f"https://api.yourcompany.com/{endpoint}", json=data)
          return response.json()

Error Handling

MCP tools include robust error handling and retry mechanisms:

  • Automatic retries for transient failures
  • Graceful degradation when tools are unavailable
  • Detailed error logging and reporting
  • Fallback strategies for critical workflows
Tools are executed in isolated environments for security and reliability.