Skip to main content
Glama
Agent Aggregator
by rnd-pro

Agent Aggregator

MCP Server that aggregates tools from multiple MCP servers, acting as a proxy to provide unified access to various AI agents and tools.

šŸŽÆ Features

  • Multi-Agent Aggregation: Connects to multiple MCP servers simultaneously

  • Unified Tool Interface: Exposes all tools through a single MCP interface

  • AI Model Integration: Each agent can have an associated AI model via OpenRouter

  • Dynamic Configuration: Supports runtime configuration of connected agents

  • Error Handling: Robust error handling and connection management

  • Modern Node.js: Built with ES modules and modern JavaScript features

  • OpenRouter Support: Integrated support for AI models through OpenRouter API

Related MCP server: MetaMCP

šŸ“ Project Structure

agent-aggregator/
ā”œā”€ā”€ src/
│   ā”œā”€ā”€ index.js                 # Main MCP server entry point
│   ā”œā”€ā”€ aggregator/
│   │   ā”œā”€ā”€ AgentAggregator.js   # Core aggregation logic
│   │   ā”œā”€ā”€ MCPConnection.js     # Individual MCP server connection
│   │   └── OpenRouterClient.js  # OpenRouter API integration
│   ā”œā”€ā”€ config/
│   │   └── ConfigLoader.js      # Configuration management
│   └── mcp-servers/            # Custom MCP server implementations
│       ā”œā”€ā”€ README.md           # MCP servers documentation
│       └── qwen_mcp_server.py  # Qwen AI MCP server
ā”œā”€ā”€ config/
│   └── agents.json             # Agent configuration file
ā”œā”€ā”€ tests/
│   └── integration.test.js     # Integration tests with real services
ā”œā”€ā”€ scripts/
│   └── test-server.js          # Manual server testing script
└── docs/                       # Documentation

šŸš€ Quick Start

Installation

# Install globally from npm
npm install -g agent-aggregator

# Or clone the repository for development
git clone https://github.com/rnd-pro/agent-aggregator.git
cd agent-aggregator

# Install dependencies
npm install

Quick Start with Cursor

  1. Add to Cursor MCP configuration (~/.cursor/mcp.json):

{
  "mcpServers": {
    "agent-aggregator": {
      "command": "npx",
      "args": ["agent-aggregator"],
      "env": {
        "OPENROUTER_API_KEY": "your-openrouter-api-key",
        "NODE_ENV": "production"
      }
    }
  }
}
  1. Set your OpenRouter API key:

  2. Restart Cursor and you'll have access to 14+ tools from connected MCP servers:

    • Filesystem operations

    • Code analysis tools

    • AI assistance tools

    • And more based on your configuration

Configuration

Edit config/agents.json to configure which MCP servers to connect to:

{
  "agents": [
    {
      "name": "filesystem",
      "type": "mcp",
      "enabled": true,
      "description": "File system operations server",
      "connection": {
        "command": "npx",
        "args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
        "env": {}
      },
      "model": {
        "provider": "openrouter",
        "name": "qwen/qwen3-coder:free",
        "apiKey": "${OPENROUTER_API_KEY}"
      }
    }
  ],
  "aggregator": {
    "timeout": 30000,
    "retryAttempts": 3,
    "retryDelay": 1000
  },
  "defaults": {
    "model": {
      "provider": "openrouter",
      "name": "qwen/qwen3-coder:free",
      "apiKey": "${OPENROUTER_API_KEY}",
      "baseUrl": "https://openrouter.ai/api/v1"
    }
  }
}

Environment Variables

Set up your OpenRouter API key:

# For current session
export OPENROUTER_API_KEY="sk-or-v1-your-actual-key-here"

# Or create .env file in project root:
echo "OPENROUTER_API_KEY=sk-or-v1-your-actual-key-here" > .env

# For permanent setup (add to ~/.bashrc or ~/.zshrc):
echo 'export OPENROUTER_API_KEY="sk-or-v1-your-actual-key-here"' >> ~/.zshrc

Important: Never commit your actual API key to version control!

Running

# Start the MCP server
npm start

# Test the server
npm run test:server

# Run integration tests
npm test

# Development mode with auto-reload
npm run dev

šŸ”§ Usage

As MCP Server

Add to your MCP client configuration (e.g., Cursor):

{
  "mcpServers": {
    "agent-aggregator": {
      "command": "npx",
      "args": ["agent-aggregator"]
    }
  }
}

Supported MCP Servers

Currently configured to work with:

  • Filesystem: @modelcontextprotocol/server-filesystem - File system operations

  • Claude Code MCP: @kunihiros/claude-code-mcp - Claude Code wrapper

You can add any MCP server that supports the standard MCP protocol. Popular options include:

  • @modelcontextprotocol/server-github - GitHub API operations

  • @modelcontextprotocol/server-memory - Memory management

  • @modelcontextprotocol/server-fetch - HTTP requests and web fetching

šŸ“Š Architecture

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”    ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”    ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│   MCP Client    │────│ Agent Aggregator │────│  Filesystem     │
│   (Cursor)      │    │   (This Server)  │    │   MCP Server    │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜    │                  │    ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
                       │                  │    ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
                       │                  │────│  Qwen AI        │
                       │                  │    │   MCP Server    │
                       │                  │    ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
                       │                  │    ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
                       │                  │────│  Claude Code    │
                       │                  │    │   MCP Server    │
                       │                  │    ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
                       │                  │    ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
                       │                  │────│  OpenRouter     │
                       │                  │    │  AI Models      │
                       ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜    ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

The Agent Aggregator:

  1. Connects to multiple downstream MCP servers

  2. Aggregates their tools into a unified list

  3. Routes tool calls to the appropriate server

  4. Provides AI model access via OpenRouter for each agent

  5. Returns results back to the client

šŸ¤– AI Model Integration

Each MCP server can have an associated AI model that runs via OpenRouter. The default model is qwen/qwen3-coder:free.

Custom Methods

The aggregator provides custom MCP methods for AI interactions:

  • custom/agents/list - List all available agents and their capabilities

  • custom/model/generate - Generate text using an agent's model

  • custom/model/chat - Send chat completion requests

  • custom/models/info - Get information about all models

  • custom/status - Get detailed status of all connections

šŸ” Debugging

If you encounter issues, you can inspect the MCP server:

# Debug with MCP inspector
npx @modelcontextprotocol/inspector node src/index.js

šŸ› ļø Development

For developers who want to extend or contribute:

Adding New MCP Servers

  1. Add server configuration to config/agents.json

  2. Install the MCP server package

  3. Test the connection

Contributing

  1. Fork the repository

  2. Create a feature branch

  3. Test your changes

  4. Submit a pull request

šŸ“ Configuration Options

Agent Configuration

{
  "name": "unique-agent-name",
  "type": "mcp",
  "enabled": true,
  "description": "Agent description",
  "connection": {
    "command": "command-to-run",
    "args": ["--arg1", "--arg2"],
    "env": {
      "ENV_VAR": "value"
    }
  },
  "model": {
    "provider": "openrouter",
    "name": "qwen/qwen3-coder:free",
    "apiKey": "${OPENROUTER_API_KEY}"
  }
}

Aggregator Configuration

{
  "aggregator": {
    "timeout": 30000,        // Connection timeout in ms
    "retryAttempts": 3,      // Number of retry attempts
    "retryDelay": 1000,      // Delay between retries in ms
    "concurrentConnections": 2  // Max concurrent connections
  },
  "defaults": {
    "model": {
      "provider": "openrouter",
      "name": "qwen/qwen3-coder:free",
      "apiKey": "${OPENROUTER_API_KEY}",
      "baseUrl": "https://openrouter.ai/api/v1"
    }
  }
}

Available Models

The system uses OpenRouter API which supports many models:

  • qwen/qwen3-coder:free (default) - Free Qwen 3 Coder model

  • openai/gpt-4o-mini - OpenAI GPT-4o Mini

  • anthropic/claude-3.5-sonnet - Claude 3.5 Sonnet

  • meta-llama/llama-3.1-8b-instruct:free - Free Llama model

  • And many more - see OpenRouter Models


## šŸ” Troubleshooting

### Common Issues

1. **"Could not attach to MCP server"**
   - Check that the MCP server package is installed
   - Verify the command and arguments in configuration
   - Ensure the server supports the MCP protocol

2. **"Connection timeout"**
   - Increase timeout in aggregator configuration
   - Check that the MCP server starts properly
   - Verify network connectivity

3. **"Tool not found"**
   - Ensure the downstream MCP server is connected
   - Check tool name prefixing (format: `agent-name__tool-name`)
   - Verify the tool exists in the downstream server

4. **"OpenRouter API error"**
   - Verify your OPENROUTER_API_KEY is set correctly
   - Check that you have credits/access to the specified model
   - Ensure the model name is correct (e.g., `qwen/qwen3-coder:free`)

5. **"No AI model configured"**
   - Add a `model` section to your agent configuration
   - Ensure the model configuration includes provider, name, and apiKey
   - Check that environment variables are properly expanded

### Debug Mode

Enable debug logging by setting environment variables:

```bash
DEBUG=1 npm start

šŸ¤ Contributing

  1. Follow the established code style

  2. Add tests for new functionality

  3. Update documentation

  4. Test with real MCP servers

šŸ“„ License

MIT License

Available Tools

10 tools
ai-tools__analyze_projectB

[AI Code Analysis] Analyzes project structure and provides insights

Inputs: project_description (required), focus.

ai-tools__edit_codeC

[AI Code Analysis] Edits the given code based on instructions

Inputs: code (required), instructions (required).

ai-tools__explain_codeB

[AI Code Analysis] Provides detailed explanation of the given code

Inputs: code (required), context.

ai-tools__fix_codeC

[AI Code Analysis] Fixes bugs or issues in the given code

Inputs: code (required), issue_description (required).

ai-tools__review_codeA

[AI Code Analysis] Reviews the given code for quality and best practices

Inputs: code (required), focus_areas.

ai-tools__simulate_commandC

[AI Code Analysis] Simulates the execution of a given command

Inputs: command (required), input.

ai-tools__test_codeB

[AI Code Analysis] Generates tests for the given code

Inputs: code (required), test_framework.

filter__getA

[Filter Management] Get current tool filter configuration

Inputs: no named parameters.

filter__resetA

[Filter Management] Reset tool filter to show all available tools

Inputs: no named parameters.

filter__updateC

[Filter Management] Update tool visibility filter - control which tools are visible to AI

Inputs: excludeServers, excludePatterns, includePatterns.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 10 tools

    Disambiguation4/5

    The three filter tools are clearly distinct, and the AI code tools have distinct actions (explain, review, fix, edit, test, simulate, analyze). Some overlap exists between fix_code and edit_code, but descriptions clarify the difference.

    Naming Consistency4/5

    All tools follow a consistent domain__action pattern using double underscores, but the action part is not uniformly verb_noun (e.g. filter__get vs ai-tools__explain_code). This is a minor inconsistency that does not impede readability.

    Tool Count5/5

    Ten tools is well-scoped for an aggregator with two functional areas: filter management and AI code analysis. Each tool seems to serve a distinct purpose without redundancy.

    Completeness5/5

    Filter management covers get/update/reset completely, and AI code analysis covers explain, review, fix, edit, test, simulate, and project analysis. There are no obvious dead ends or missing core operations for the stated domains.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Aggregates multiple MCP servers and custom Python tools behind a single endpoint, with intelligent context and tool discovery for AI agents.
      -
    • A
      license
      A
      quality
      B
      maintenance
      Aggregates multiple MCP servers into a single interface, reducing token overhead and simplifying tool management for LLMs.
      6
      80 npm
      18
      Apache 2.0
    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables LLMs to manage and proxy multiple MCP servers, dynamically extending capabilities by adding, configuring, enabling, disabling, and aggregating their tools through a unified interface.
      -