Skip to main content

Overview

The Swarms TypeScript MCP Server bridges MCP-compatible agents (Claude Desktop, Cursor IDE, OpenAI Agents, and other MCP clients) with the Swarms AI agent platform. Built with Stainless and following the Model Context Protocol standard, this server exposes Swarms’ API endpoints as discoverable tools that agents can invoke directly—enabling agents to execute single agents, orchestrate multi-agent swarms, run reasoning workflows, and process batch operations without custom API integration code.

Key Capabilities

  • Single Agent Execution: Run individual Swarms agents with custom tasks, model selection, and configuration parameters
  • Multi-Agent Orchestration: Coordinate swarms using architectural patterns including sequential workflows, concurrent execution, hierarchical structures, graph-based routing, and majority voting
  • Reasoning Agents: Execute chain-of-thought reasoning agents for step-by-step problem analysis and complex decision-making
  • Batch Processing: Process multiple agent tasks or swarm operations in parallel using thread pools for high-throughput workloads
  • Dynamic Discovery: Use runtime endpoint discovery to explore available API operations, or configure static tool exposure for better performance and type safety
  • Client Optimization: Automatically adapts tool schemas and capabilities to match your MCP client (Claude Desktop, Cursor IDE, OpenAI Agents, Claude Code, and custom clients)

Why Use This Server?

The Swarms MCP Server eliminates the need to write custom API integration code when building agent-powered applications. Instead of manually constructing HTTP requests, handling authentication, and parsing responses, agents can directly invoke Swarms operations through standardized MCP tools. The server provides production-ready error handling, rate limit monitoring, health checks, and flexible configuration options—allowing you to expose only the tools your agents need while maintaining full compatibility with the MCP ecosystem.

Installation

Prerequisites

  • Node.js (version 14 or higher recommended)
  • A valid Swarms API key
  • An MCP-compatible client application

Method 1: Direct Invocation via npx

For quick testing or one-time usage, you can run the MCP server directly without installation:

Method 2: Installation via npm

For persistent usage or integration into projects:

Method 3: MCP Client Configuration

Most MCP clients support configuration through a JSON file. Add the following configuration to your client’s MCP server settings:
Replace your_api_key_here with your actual Swarms API key.

Configuration

Environment Variables

The server requires the following environment variable:
  • SWARMS_API_KEY: Your Swarms platform API key (required)

Command-Line Arguments

The MCP server supports extensive command-line configuration:

Tool Selection

  • --tools=all: Expose all available tools
  • --tools=dynamic: Enable dynamic tool discovery mode
  • --tool=<name>: Include a specific tool by name
  • --no-tool=<name>: Exclude a specific tool by name

Resource Filtering

  • --resource=<name>: Include all tools under a specific resource
  • --resource=<pattern>*: Include resources matching a wildcard pattern
  • --no-resource=<name>: Exclude a specific resource

Operation Filtering

  • --operation=read: Include only read operations (GET/LIST)
  • --operation=write: Include only write operations (POST/PUT/DELETE)

Client Configuration

  • --client=<type>: Configure for a specific MCP client
    • Valid values: openai-agents, claude, claude-code, cursor

Capability Settings

  • --capability=<name>: Enable specific client capabilities
    • top-level-unions: Support for top-level union types
    • valid-json: JSON string parsing for arguments
    • refs: Support for $ref pointers in schemas
    • unions: Support for union types (anyOf)
    • formats: Support for format validations
    • tool-name-length=N: Maximum tool name length

Utility Commands

  • --list: Display all available tools
  • --help: Show help information

Configuration Examples

Filter for read-only operations on a specific resource:
Exclude specific tools while including others:
Configure for Cursor with custom capabilities:
Complex multi-criteria filtering:

Tool Exposure Strategies

The Swarms MCP server offers two primary strategies for exposing API endpoints as tools:

Static Tool Exposure

In this mode, each API endpoint is exposed as a dedicated tool with a fully-defined schema. This approach provides:
  • Better autocomplete and type safety in client applications
  • More accurate parameter validation
  • Clearer documentation for each endpoint
  • Optimal performance for smaller API surfaces
Recommendation: Use static exposure when working with a focused subset of the API or when the client has sufficient context window capacity.

Dynamic Tool Discovery

When configured with --tools=dynamic, the server exposes three meta-tools that enable runtime endpoint discovery:

list_api_endpoints

Discovers available endpoints with optional search filtering. Parameters:
  • search (optional): Query string to filter endpoints
Use case: Finding relevant endpoints without loading all schemas into context.

get_api_endpoint_schema

Retrieves detailed schema information for a specific endpoint. Parameters:
  • endpoint: The name or identifier of the endpoint
Use case: Obtaining parameter requirements before invoking an endpoint.

invoke_api_endpoint

Executes any endpoint with appropriate parameters. Parameters:
  • endpoint: The endpoint to invoke
  • parameters: JSON object containing endpoint-specific parameters
Use case: Making API calls after discovering and understanding the schema. Recommendation: Use dynamic tools when:
  • Working with a large API surface
  • Context window limitations are a concern
  • Runtime endpoint discovery is required
  • The full API schema exceeds available context

Hybrid Approach

You can combine both strategies by specifying explicit tools alongside dynamic tools:
This provides immediate access to frequently-used tools while maintaining the flexibility of dynamic discovery.

Client Compatibility

Different MCP clients have varying capabilities for handling tool schemas and complex types. The Swarms MCP server automatically adapts its output based on the specified client.

Supported Clients

Claude (--client=claude)

Optimized for Claude AI assistant with full schema support.

Claude Code (--client=claude-code)

Configured for the Claude Code command-line environment.

Cursor (--client=cursor)

Adapted for the Cursor IDE with appropriate schema simplifications.

OpenAI Agents (--client=openai-agents)

Compatible with OpenAI’s agent framework.

Manual Capability Configuration

For clients not listed above or to override defaults:
Available capabilities:
  • top-level-unions: Enables union types at the schema root
  • valid-json: Enables JSON string parsing for complex arguments
  • refs: Enables JSON Schema $ref pointers
  • unions: Enables anyOf union types
  • formats: Enables format validators (date-time, email, etc.)
  • tool-name-length=N: Sets maximum tool name length

Available Tools and Resources

The Swarms MCP server exposes 12 tools by default when using --tools=all. These tools are organized by resource and operation type, providing comprehensive access to the Swarms API functionality.

Complete Tools Reference Table

Dynamic Discovery Tools

When using --tools=dynamic, these additional meta-tools become available:

Resource: $client

get_root_client (read)
  • Description: Root client information
  • Use case: Health checks and API connectivity verification

Resource: health

check_health (read)
  • Description: Health status of the Swarms API
  • Returns: API health metrics and status
  • Use case: Monitoring and uptime verification

Resource: agent

run_agent (write)
  • Description: Execute a single agent with a specified task
  • Parameters:
    • task: The task description for the agent
    • Additional agent configuration parameters
  • Returns: Agent execution results
  • Use case: Running individual AI agents for specific tasks

Resource: agent.batch

run_agent_batch (write)
  • Description: Execute multiple agents concurrently using a thread pool
  • Parameters:
    • tasks: Array of task descriptions
    • Batch configuration options
  • Returns: Aggregated results from all agents
  • Use case: Parallel processing of multiple independent tasks

Resource: models

list_available_models (read)
  • Description: Retrieve all available AI models
  • Returns: List of model identifiers and capabilities
  • Use case: Model discovery and selection

Resource: swarms

check_available_swarms (read)
  • Description: Query available swarm types and configurations
  • Returns: List of swarm architectures and their capabilities
  • Use case: Determining which swarm pattern to use
get_logs_swarms (read)
  • Description: Retrieve API request logs for all associated API keys
  • Returns: Log entries (excluding client IP information)
  • Use case: Auditing, debugging, and usage analysis
run_swarms (write)
  • Description: Execute a swarm with a specified task
  • Parameters:
    • task: The task for the swarm to execute
    • swarm_type: The type of swarm architecture
    • Additional swarm configuration
  • Returns: Swarm execution results
  • Use case: Orchestrating multiple agents in coordinated patterns

Resource: swarms.batch

run_swarms_batch (write)
  • Description: Execute multiple swarms concurrently using a thread pool
  • Parameters:
    • tasks: Array of swarm tasks
    • Batch and swarm configuration
  • Returns: Aggregated swarm results
  • Use case: Large-scale parallel swarm processing

Resource: reasoning_agents

create_completion_reasoning_agents (write)
  • Description: Execute a reasoning agent with chain-of-thought capabilities
  • Parameters:
    • task: The reasoning task
    • Reasoning configuration options
  • Returns: Reasoning output with intermediate steps
  • Use case: Complex problem-solving requiring step-by-step analysis
list_types_reasoning_agents (read)
  • Description: List available reasoning agent types
  • Returns: Reasoning agent architectures and their characteristics
  • Use case: Selecting appropriate reasoning strategies

Resource: client.rate

get_limits_client_rate (read)
  • Description: Query rate limits and current usage
  • Returns: Rate limit information and usage statistics
  • Use case: Monitoring API quota and preventing rate limit violations

Tools by Operation Type

The 12 default tools are divided into read and write operations:

Read Operations (7 tools)

Read operations are safe, idempotent operations that retrieve information without modifying state:
  • get_root_client
  • check_health
  • list_available_models
  • check_available_swarms
  • get_logs_swarms
  • list_types_reasoning_agents
  • get_limits_client_rate
Plus dynamic tools (when enabled):
  • list_api_endpoints
  • get_api_endpoint_schema

Write Operations (5 tools)

Write operations execute actions and may modify state or consume resources:
  • run_agent
  • run_agent_batch
  • run_swarms
  • run_swarms_batch
  • create_completion_reasoning_agents
Plus dynamic tool (when enabled):
  • invoke_api_endpoint
Total: 12 static tools (7 read + 5 write)

Advanced Usage

Programmatic Integration

For custom integrations, you can import and configure the server programmatically:

Importing Specific Tools

Creating Custom Endpoints

Error Handling

When integrating with the Swarms MCP server, implement appropriate error handling:

Common Error Scenarios

  1. Authentication Errors: Invalid or missing API key
  2. Rate Limiting: Exceeded API quota
  3. Invalid Parameters: Malformed requests or missing required fields
  4. Network Issues: Connectivity problems or timeouts
  5. Resource Unavailability: Requested models or swarm types not available

Best Practices for Error Management

  • Always validate the presence of the SWARMS_API_KEY environment variable
  • Implement retry logic with exponential backoff for transient failures
  • Monitor rate limits using get_limits_client_rate before heavy operations
  • Log errors with sufficient context for debugging
  • Provide meaningful error messages to end users

Best Practices

Client Setup Examples

Claude Code

Claude Code is a command-line tool that enables Claude to interact with your codebase and execute operations. Here’s how to configure the Swarms MCP server for Claude Code.

Configuration

Add the Swarms MCP server to your Claude Code configuration file (typically located at ~/.config/claude-code/mcp.json or similar):
For optimal performance with Claude Code, consider using a focused set of tools:

Usage Example: Running an Agent

Once configured, you can ask Claude Code to execute Swarms agents directly:
Claude Code will automatically invoke the run_agent tool:

Usage Example: Batch Processing

For processing multiple files or tasks:
Claude Code will use the batch endpoint:

Usage Example: Multi-Agent Swarm

For complex tasks requiring multiple agents:

Usage Example: Reasoning Agent

For complex problem-solving tasks:

Dynamic Tool Discovery

If you prefer runtime discovery, configure with dynamic tools:
Then use the discovery tools:

Claude Chat (Claude Desktop)

Claude Chat (Claude Desktop) provides a conversational interface where Claude can use MCP tools to interact with the Swarms API.

Configuration

Add the Swarms MCP server to your Claude Desktop configuration file. On macOS, this is typically located at ~/Library/Application Support/Claude/claude_desktop_config.json:
For Claude Chat, you may want to expose all tools for maximum flexibility:

Usage Example: Health Check

Start by verifying the connection:
Claude will automatically use the health check tool:

Usage Example: Agent Execution

Execute agents through natural conversation:
Claude will invoke the agent:

Usage Example: Model Discovery

Discover available models before running agents:

Usage Example: Swarm Orchestration

Use multi-agent swarms for complex workflows:

Usage Example: Rate Limit Monitoring

Check your API usage:

Filtered Configuration Example

If you want to limit Claude Chat to read-only operations:
This configuration exposes only read operations like check_health, list_available_models, check_available_swarms, and get_limits_client_rate, preventing accidental execution of agents or swarms.

Resources

Version Information

  • Current Version: 0.1.0-alpha.10
  • Status: Alpha release
  • Last Updated: 6 months ago

Support

For issues, feature requests, or contributions:
  • Open an issue on the GitHub repository
  • Review existing documentation and examples
  • Check the Model Context Protocol specification for general MCP questions