Skip to main content
The Swarms API supports Model Context Protocol (MCP) integration, allowing agents to connect to external servers and access additional tools, data sources, and capabilities beyond the base API.
MCP integration enables agents to access external databases, APIs, and tools through standardized server connections.

Quick Start

MCP Server Setup

Local MCP Server

Running the MCP Server

Advanced MCP Configuration

Multiple MCP Connections

Single MCP with Advanced Config

Use Cases

Database Integration

Financial Data Access

API Integration

Best Practices

  1. Server Reliability: Ensure your MCP server is stable and handles errors gracefully
  2. Authentication: Implement proper authentication for MCP server access
  3. Timeout Handling: Set appropriate timeouts for long-running operations
  4. Error Handling: Handle MCP connection failures and retry logic
  5. Resource Management: Monitor resource usage and implement rate limiting
  6. Documentation: Document available MCP tools and their capabilities

Cost Considerations

  • MCP Calls: $0.10 per request that sets mcp_url (charged once per request, not per tool call)
  • Token Usage: Additional tokens for MCP tool interactions
  • Server Costs: Costs associated with running your MCP server

Error Handling

Troubleshooting

Common Issues

  1. Connection Refused: Ensure MCP server is running and accessible
  2. Authentication Failed: Check API keys and authentication headers
  3. Timeout Errors: Increase timeout values for complex operations
  4. Tool Not Found: Verify tool names match server implementation
  5. Rate Limiting: Implement backoff strategies for rate-limited endpoints

Debug Mode

Enable debug logging on your client to troubleshoot MCP issues: