Skip to main content
Glama

Polyagent

Multi-provider AI agent bridge for Claude Desktop. Connect Claude to external AI agents (GLM, OpenAI, Anthropic, Bedrock, Gemini) for specialized tasks like security scanning, code review, and more.

Features

  • Multi-Provider Support: Google Gemini and Ollama Cloud through an OpenAI-compatible endpoint

  • Dynamic Agent Registration: Register agents at runtime via MCP tools

  • Flexible Pipeline Modes: Sequential, Iterative, and Parallel execution

  • Loop Prevention: Max iterations, confidence thresholds, human approval

  • Streaming Support: Stream responses in real-time

  • Production Ready: Comprehensive error handling, logging, and metrics

Related MCP server: Claude Swarm MCP Server

Architecture

[Claude Desktop] ←→ [AI Agent MCP Server] ←→ [External AI Agents]
                           │
        ┌──────────────────┼──────────────────┐
        │                  │                  │
   Agent Registry    Pipeline Engine    Loop Prevention
   (dynamic reg)     (seq/iter/parallel) (max iter/confidence/approval)

Installation

Prerequisites

  • Python 3.10 or higher

  • uv package manager (recommended)

Setup

# Clone or navigate to the project
cd ai-agent-mcp-server

# Install dependencies
uv sync

# Set up environment variables. The server also loads a local .env file.
export GOOGLE_API_KEY="your-key"          # For Gemini
export OLLAMA_API_KEY="your-key"          # For Ollama Cloud
export OLLAMA_BASE_URL="https://ollama.com/v1"

Usage

1. Configure Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "ai-agent-bridge": {
      "command": "uv",
      "args": [
        "--directory",
        "/path/to/ai-agent-mcp-server",
        "run",
        "main.py"
      ],
      "env": {
        "GOOGLE_API_KEY": "your-key",
        "OLLAMA_API_KEY": "your-key",
        "OLLAMA_BASE_URL": "https://ollama.com/v1"
      }
    }
  }
}

Config file locations:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

  • Linux: ~/.config/Claude/claude_desktop_config.json

  • Windows: %APPDATA%\Claude\claude_desktop_config.json

2. Restart Claude Desktop

Fully quit Claude Desktop (Cmd+Q on macOS) and restart.

3. Register an Agent

In Claude Desktop, use the register_agent tool:

Register a security scanner agent using GLM-4

Claude will call:

{
  "name": "register_agent",
  "arguments": {
    "name": "security-scanner",
    "provider": "openai_compat",
    "model": "glm-4",
    "system_prompt": "You are an expert security auditor...",
    "description": "Scans code for security vulnerabilities",
    "api_key_env": "GLM_API_KEY",
    "base_url": "https://open.bigmodel.cn/api/paas/v4",
    "capabilities": ["security", "vulnerability-detection"]
  }
}

4. Execute an Agent

Scan this code for vulnerabilities: [paste code]

Claude will call:

{
  "name": "execute_agent",
  "arguments": {
    "agent_name": "security-scanner",
    "input_content": "[your code]"
  }
}

Available Tools

Agent Management

  • register_agent: Register a new AI agent

  • list_agents: List all registered agents

  • update_agent: Update agent configuration

  • remove_agent: Remove an agent

Pipeline Execution

  • execute_agent: Execute a single agent

  • execute_pipeline: Execute multi-agent pipeline

Configuration

  • set_safety_config: Configure loop prevention

  • get_safety_config: Get current safety settings

Example: Security Scanner Pipeline

Step 1: Register Security Agent

# In Claude Desktop
register_agent(
    name="security-scanner",
    provider="openai_compat",
    model="glm-4",
    system_prompt="You are an expert security auditor. Find vulnerabilities in the following code.",
    description="Scans code for security vulnerabilities using GLM-4",
    api_key_env="GLM_API_KEY",
    base_url="https://open.bigmodel.cn/api/paas/v4",
    capabilities=["security", "vulnerability-detection"],
    temperature=0.3
)

Step 2: Execute Security Scan

# In Claude Desktop
execute_agent(
    agent_name="security-scanner",
    input_content="def process_user_input(user_input):\n    eval(user_input)"
)

Step 3: Claude Processes Results

Claude receives the security findings and can:

  • Explain vulnerabilities to the user

  • Suggest fixes

  • Re-run scans on fixed code

Pipeline Modes

Sequential (Default)

Single pass: Claude → Agent → Claude

execute_pipeline(
    agents=["security-scanner"],
    input_content="[code]",
    mode="sequential"
)

Iterative

Multiple rounds: Claude ↔ Agent (with loop prevention)

execute_pipeline(
    agents=["security-scanner"],
    input_content="[code]",
    mode="iterative",
    max_iterations=3,
    confidence_threshold=0.9
)

Parallel

Multiple agents analyze simultaneously:

execute_pipeline(
    agents=["security-scanner", "code-reviewer", "performance-analyzer"],
    input_content="[code]",
    mode="parallel"
)

Supported Providers

OpenAI-Compatible (GLM, DeepSeek, etc.)

register_agent(
    name="glm-agent",
    provider="openai_compat",
    model="glm-4",
    base_url="https://open.bigmodel.cn/api/paas/v4",
    api_key_env="GLM_API_KEY"
)

Anthropic Claude

register_agent(
    name="claude-agent",
    provider="anthropic",
    model="claude-3-5-sonnet-20241022",
    api_key_env="ANTHROPIC_API_KEY"
)

Google Gemini

register_agent(
    name="gemini-agent",
    provider="gemini",
    model="gemini-1.5-pro",
    api_key_env="GOOGLE_API_KEY"
)

AWS Bedrock

register_agent(
    name="bedrock-agent",
    provider="bedrock",
    model="anthropic.claude-3-5-sonnet-20241022-v2:0",
    api_key_env="AWS_BEDROCK_API_KEY",
    region="us-east-1"
)

Loop Prevention

Configure safety settings:

set_safety_config(
    max_iterations=3,              # Stop after 3 iterations
    confidence_threshold=0.9,      # Stop when confidence > 90%
    require_approval_after=2,      # Ask for approval after 2 iterations
    timeout_seconds=300            # Global timeout
)

Development

Run in Development Mode

# Test with MCP Inspector
uv run mcp dev main.py

Run Tests

uv run pytest tests/

Project Structure

ai-agent-mcp-server/
├── src/
│   ├── server.py           # MCP server entry point
│   ├── providers/          # AI provider adapters
│   │   ├── base.py         # Abstract base provider
│   │   ├── openai_compat.py # OpenAI-compatible (GLM, DeepSeek)
│   │   ├── anthropic.py    # Anthropic Claude
│   │   ├── bedrock.py      # AWS Bedrock
│   │   └── gemini.py       # Google Gemini
│   ├── agents/             # Agent management
│   │   ├── profiles.py     # Agent profile definitions
│   │   └── registry.py     # Dynamic agent registry
│   ├── pipeline/           # Communication pipeline
│   │   └── engine.py       # Pipeline execution engine
│   ├── safety/             # Loop prevention
│   │   └── limits.py       # Safety mechanisms
│   └── config.py           # Configuration management
├── tests/
├── main.py                 # Entry point
├── pyproject.toml
└── README.md

Troubleshooting

Server not showing up in Claude

  1. Check claude_desktop_config.json syntax

  2. Use absolute paths

  3. Fully quit and restart Claude Desktop

Tool calls failing

  1. Check Claude's logs: ~/Library/Logs/Claude/mcp*.log

  2. Verify API keys are set

  3. Test with MCP Inspector: uv run mcp dev main.py

API errors

  1. Verify API keys are correct

  2. Check rate limits

  3. Ensure model names are valid

License

MIT

Contributing

Contributions welcome! Please read CONTRIBUTING.md for guidelines.

Support

  • GitHub Issues: [Report bugs or request features]

  • Documentation: [Full API documentation]

  • MCP Discord: #python-sdk-dev

Available Tools

9 tools
execute_agentC

Execute a single agent.

Args: agent_name: Name of the agent to execute input_content: Input content to process context: Optional context from Claude

Returns: Execution result

Inputs: agent_name (required), input_content (required), context.

execute_pipelineB

Execute a pipeline with multiple agents.

Args: agents: List of agent names input_content: Input content to process mode: Pipeline mode (sequential, iterative, parallel) context: Optional context from Claude max_iterations: Maximum iterations for iterative mode confidence_threshold: Confidence threshold for stopping require_approval_after: Pause iterative mode for human approval after N iterations. Defaults to None (disabled) so max_iterations is the real bound; pass an int to opt into an approval checkpoint.

Returns: Pipeline execution results

Inputs: agents (required), input_content (required), mode, context, +3 more.

get_available_modelsA

Get list of all available models and their capabilities.

This tool should be called by Claude to discover which models are available and what tasks they're best suited for.

Returns: Dictionary with model registry including capabilities

Inputs: no named parameters.

get_safety_configA

Get current safety configuration.

Returns: Current safety configuration

Inputs: no named parameters.

list_agentsB

List all registered agents.

Args: capability: Optional capability filter

Returns: List of agent profiles

Inputs: capability.

register_agentA

Register a new AI agent.

Args: name: Unique name for the agent provider: Provider type (openai_compat, anthropic, bedrock, gemini) model: Model identifier (e.g., 'glm-4', 'claude-3-5-sonnet') system_prompt: System prompt for the agent description: Human-readable description api_key_env: Environment variable name for API key temperature: Sampling temperature (0.0-2.0) max_tokens: Maximum tokens to generate capabilities: List of agent capabilities base_url: Base URL for OpenAI-compatible providers region: AWS region for Bedrock

Returns: Registered agent profile

Inputs: name (required), model (required), provider (required), api_key_env (required), +7 more.

remove_agentC

Remove an agent.

Args: name: Agent name

Returns: Removed agent profile

Inputs: name (required).

set_safety_configA

Configure loop prevention and safety settings.

Args: max_iterations: Maximum iterations before stopping confidence_threshold: Stop when confidence exceeds threshold require_approval_after: Require approval after N iterations timeout_seconds: Global timeout in seconds

Returns: Updated safety configuration

Inputs: max_iterations, timeout_seconds, confidence_threshold, require_approval_after.

update_agentC

Update an existing agent.

Args: name: Agent name **kwargs: Fields to update

Returns: Updated agent profile

Inputs: name (required), kwargs (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 9 tools

    Disambiguation5/5

    Every tool targets a distinct concern: agent lifecycle, agent execution, pipeline execution, safety configuration, and model discovery. The only potentially similar pair (execute_agent vs execute_pipeline) is clearly differentiated by scope: single agent vs multi-agent pipeline.

    Naming Consistency5/5

    Tool names follow a consistent verb_noun pattern: list_, register_, update_, remove_, execute_, get_, set_. Naming clearly indicates both the action and the resource, with no mixed conventions or vague verbs.

    Tool Count5/5

    Nine tools is well-scoped for an agent management and orchestration server. Each tool covers a necessary aspect of the domain without redundancy or bloat.

    Completeness5/5

    The tool surface provides complete agent lifecycle coverage (list, register, update, remove), execution paths for both individual and multi-agent workflows, safety controls, and model discovery. There are no obvious dead ends or missing operations for the stated purpose.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Integrates 100+ specialized AI agents with Claude Desktop, providing automated agent discovery, multi-agent coordination, and ready-to-use task templates for complex development and business workflows. Enables users to leverage enterprise-level AI capabilities through actionable resources and intelligent agent matching.
      35 npm
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables multi-agent orchestration and coordination using specialized, persistent Claude agents for complex workflows like financial analysis and research. It supports intelligent agent handoffs, local storage, and pre-built team templates through Claude Desktop.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables Claude Code and Claude Desktop to delegate coding tasks to any model available in OpenCode while Claude remains the orchestrator, planning work, reviewing diffs, and running tests. Supports synchronous and async delegation, model selection, session continuation, and permission-aware execution.
      6
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Enables Claude Code and Claude Desktop to delegate bounded, disposable tasks to local or cheap cloud models, with model scoring, guardrails, and cost-saved tracking.
      53
      MIT