anygpt-discovery

anygpt-discovery

Exposes 5 meta-tools that allow AI agents to autonomously discover and execute tools from 100+ MCP servers, reducing token usage by 99%.

Category
访问服务器

README

AnyGPT Ecosystem

⚠️ WORK IN PROGRESS: This project is under active development. APIs, components, and configurations may change significantly. Use at your own risk in production environments.

A comprehensive TypeScript ecosystem for building AI-powered applications with support for multiple providers, MCP protocol, and flexible configuration management.

Why?

Problem: Building AI applications requires dealing with different provider APIs, complex configuration management, and protocol translations for MCP clients. Solution: This monorepo provides a modular ecosystem with clean separation of concerns:

  • Type System: Pure type definitions with zero runtime overhead
  • Router Layer: Provider abstraction and routing with connector pattern
  • Configuration: Dynamic connector loading and flexible configuration management
  • CLI Interface: Command-line tool for AI interactions and conversation management
  • MCP Server: Protocol translator for MCP clients (Docker Desktop, Windsurf, etc.)

Architecture

┌─────────────────────────────────────────────────────────────────┐
│ MCP Clients (Claude Desktop, Windsurf, Cursor)                 │
└─────────────────────────────────────────────────────────────────┘
                    ↓                           ↓
    ┌───────────────────────────┐   ┌─────────────────────────┐
    │ @anygpt/mcp-discovery-server │   │ @anygpt/mcp           │
    │ (5 meta-tools, 99% token    │   │ (MCP protocol server) │
    │  reduction)                  │   └─────────────────────────┘
    └───────────────────────────┘               ↓
                    ↓                   ┌─────────────────┐
        ┌───────────────────────┐       │ @anygpt/config  │
        │ @anygpt/mcp-discovery │       │ (Configuration) │
        │ (Discovery engine)    │       └─────────────────┘
        └───────────────────────┘               ↓
                                        ┌─────────────────┐
┌─────────────────────────┐             │ @anygpt/router  │
│ @anygpt/cli             │────────────→│ (Provider       │
│ (Command-line tool)     │             │  abstraction)   │
└─────────────────────────┘             └─────────────────┘
                                                ↓
                                    ┌───────────────────────┐
                                    │ @anygpt/ai-provider   │
                                    │ (Function calling)    │
                                    └───────────────────────┘
                                                ↓
                        ┌───────────────────────────────────────┐
                        │ Connectors (@anygpt/openai,           │
                        │  @anygpt/anthropic, @anygpt/cody,     │
                        │  @anygpt/claude, @anygpt/mock)        │
                        └───────────────────────────────────────┘
                                                ↓
                        ┌───────────────────────────────────────┐
                        │ AI Provider APIs (OpenAI, Anthropic,  │
                        │  Ollama, LocalAI, etc.)               │
                        └───────────────────────────────────────┘

Supporting Packages:
  • @anygpt/types - Pure type definitions (0 runtime deps)
  • @anygpt/rules - Type-safe rule engine for configuration
  • @anygpt/mcp-logger - File-based logging for MCP servers
  • @anygpt/plugins - Plugin system (docker-mcp-plugin, etc.)

Core Packages

Package Purpose Dependencies
@anygpt/types Pure type definitions None (0 runtime deps)
@anygpt/config Configuration management @anygpt/types
@anygpt/router Core routing and connector registry None
@anygpt/ai-provider AI provider wrapper with function calling @anygpt/router
@anygpt/rules Type-safe rule engine None
@anygpt/mcp-logger File-based logging for MCP servers None
@anygpt/plugins Plugin system for dynamic configuration @anygpt/types
@anygpt/mcp-discovery MCP tool discovery engine (core logic) @anygpt/types
@anygpt/mcp-discovery-server MCP Discovery Server (PRIMARY interface) @anygpt/mcp-discovery
@anygpt/cli Command-line interface @anygpt/config
@anygpt/mcp MCP server implementation @anygpt/config

Connector Packages

Package Provider Dependencies
@anygpt/openai OpenAI & compatible APIs @anygpt/router, openai
@anygpt/anthropic Anthropic Claude (native) @anygpt/router, @anthropic-ai/sdk
@anygpt/claude Claude via MCP @anygpt/router
@anygpt/cody Sourcegraph Cody @anygpt/router
@anygpt/mock Testing & development @anygpt/types

Supported Providers

  • OpenAI: GPT-4o, GPT-4, GPT-3.5, o1 models
  • OpenAI-Compatible: Ollama, LocalAI, Together AI, Anyscale
  • Anthropic: Claude Sonnet, Opus, Haiku (native API)
  • Mock Provider: For testing and development

Quick Start

Install CLI Tool

npm install -g @anygpt/cli

Install Individual Packages

# For building applications
npm install @anygpt/router @anygpt/openai @anygpt/anthropic

# For configuration management
npm install @anygpt/config

# For type definitions only
npm install @anygpt/types

MCP Discovery Server (99% Token Reduction!)

Zero-configuration MCP server that enables AI agents to discover and execute tools from 100+ MCP servers without loading everything into context.

# No installation needed - use with npx
npx -y @anygpt/mcp-discovery-server

Add to Claude Desktop / Windsurf / Cursor:

{
  "mcpServers": {
    "anygpt-discovery": {
      "command": "npx",
      "args": ["-y", "@anygpt/mcp-discovery-server"]
    }
  }
}

What it does:

  • Exposes 5 meta-tools instead of 150+ individual tools
  • AI agents autonomously discover tools using search_tools
  • Reduces token usage from 100,000+ to ~600 tokens (99% reduction)
  • Gateway capability: discover AND execute tools through single connection

Example workflow:

User: "Read README.md and create a GitHub issue if there are TODOs"

AI Agent:
1. search_tools({ query: "read file" }) → finds filesystem:read_file
2. execute_tool({ server: "filesystem", tool: "read_file", ... })
3. search_tools({ query: "create github issue" }) → finds github:create_issue
4. execute_tool({ server: "github", tool: "create_issue", ... })

Result: ~1,000 tokens vs 500,000+ tokens (99.8% savings)

MCP Server

# Install and run MCP server
npm install -g @anygpt/mcp
anygpt-mcp

Usage Examples

1. CLI Usage

AI Chat Commands

# Discover available models and tags
anygpt list-tags

# Quick chat with tags (stateless)
anygpt chat --tag sonnet "Explain TypeScript generics"
anygpt chat --tag opus "Write a complex algorithm"

# Specify provider explicitly
anygpt chat --provider cody --tag sonnet "Hello"
anygpt chat --provider provider1 --tag gemini "Hello"

# Use direct model name (no tag resolution)
anygpt chat --model "ml-asset:static-model/claude-sonnet-4-5" "Hello"

# Start a conversation (stateful)
anygpt conversation start --tag sonnet --name "coding-session"
anygpt conversation message "How do I implement a binary tree in TypeScript?"
anygpt conversation message "Show me the insertion method"

# List conversations
anygpt conversation list

# Fork a conversation with different tag
anygpt conversation fork --tag opus --name "binary-tree-v2"

MCP Management Commands

# List all MCP servers
anygpt mcp list
anygpt mcp list --enabled    # Only enabled servers
anygpt mcp list --disabled   # Only disabled servers

# Search for tools across all servers
anygpt mcp search "github"
anygpt mcp search "create" --server github-official

# Inspect tool details (auto-resolves server)
anygpt mcp inspect search
anygpt mcp inspect create_issue --server github-official

# Execute tools with natural syntax
anygpt mcp execute search "how to cook paella"
anygpt mcp execute search "query" 5  # Multiple parameters

# List tools from specific server
anygpt mcp tools github-official
anygpt mcp tools github-official --all  # Include disabled tools

2. Router as Library

import { GenAIRouter } from '@anygpt/router';
import { OpenAIConnectorFactory } from '@anygpt/openai';

// Create router and register connector
const router = new GenAIRouter();
router.registerConnector(new OpenAIConnectorFactory());

// Create connector instance
const connector = router.createConnector('openai', {
  apiKey: process.env.OPENAI_API_KEY,
  baseURL: 'https://api.openai.com/v1',
});

// Make requests
const response = await connector.chatCompletion({
  model: 'gpt-4o',
  messages: [{ role: 'user', content: 'Hello!' }],
});

3. Docker MCP Plugin

Auto-discover and configure Docker MCP servers:

// anygpt.config.ts
import { defineConfig } from '@anygpt/config';
import DockerMCP from '@anygpt/docker-mcp-plugin';

export default defineConfig({
  plugins: [
    DockerMCP({
      serverRules: [
        // Disable specific servers
        {
          when: { name: 'sequentialthinking' },
          set: { enabled: false },
        },
      ],
    }),
  ],
});

What it does:

  • Discovers all Docker MCP servers automatically
  • Creates separate MCP server instance for each
  • Supports server-level enable/disable rules
  • Disabled servers still visible for discovery

Generated configuration:

{
  mcpServers: {
    'github-official': {
      command: 'docker',
      args: ['mcp', 'gateway', 'run', '--servers', 'github-official'],
      source: 'docker-mcp-plugin',
      metadata: { toolCount: 49 }
    },
    'duckduckgo': {
      command: 'docker',
      args: ['mcp', 'gateway', 'run', '--servers', 'duckduckgo'],
      source: 'docker-mcp-plugin',
      metadata: { toolCount: 2 }
    }
  }
}

4. Configuration-Driven Setup

import { setupRouter } from '@anygpt/config';

// Automatically loads config and sets up router
const { router, config } = await setupRouter();

// Use with any registered connector
const response = await router.chatCompletion({
  provider: 'openai-main',
  model: 'gpt-4o',
  messages: [{ role: 'user', content: 'Hello!' }],
});

Factory config example (.anygpt/anygpt.config.ts):

import { config } from '@anygpt/config';
import { openai } from '@anygpt/openai';
import { anthropic } from '@anygpt/anthropic';

export default config({
  defaults: {
    provider: 'openai-main',
    model: 'gpt-4o',
  },
  providers: {
    'openai-main': {
      name: 'OpenAI GPT Models',
      connector: openai({
        apiKey: process.env.OPENAI_API_KEY,
        baseURL: 'https://api.openai.com/v1',
      }),
    },
    claude: {
      name: 'Anthropic Claude',
      connector: anthropic({
        apiKey: process.env.ANTHROPIC_API_KEY,
        baseURL: 'https://api.anthropic.com', // Optional: for corporate gateways
      }),
    },
    'ollama-local': {
      name: 'Local Ollama',
      connector: openai({
        baseURL: 'http://localhost:11434/v1',
      }),
    },
  },
});

Alternative standard config format:

import type { AnyGPTConfig } from '@anygpt/config';

const config: AnyGPTConfig = {
  version: '1.0',
  providers: {
    'openai-main': {
      name: 'OpenAI GPT Models',
      connector: {
        connector: '@anygpt/openai',
        config: {
          apiKey: process.env.OPENAI_API_KEY,
          baseURL: 'https://api.openai.com/v1',
        },
      },
    },
  },
  settings: {
    defaultProvider: 'openai-main',
    timeout: 30000,
  },
};

export default config;

5. MCP Server Usage

# Run MCP server
anygpt-mcp

# Test with MCP Inspector
npx @modelcontextprotocol/inspector anygpt-mcp

Claude Desktop Integration:

{
  "mcpServers": {
    "anygpt": {
      "command": "anygpt-mcp",
      "env": {
        "OPENAI_API_KEY": "your-openai-api-key"
      }
    }
  }
}

Development

This project uses NX monorepo for managing multiple packages:

# Install dependencies (automatically installs Husky git hooks)
npm install

# Note: package-lock.json is created locally but never committed
# - Nx requires it for builds
# - Husky pre-commit hook auto-unstages it
# - You can use any npm registry (public or internal)

# Build all packages (NX handles dependencies automatically)
npx nx run-many -t build

# Build specific package (dependencies built automatically)
npx nx build cli

# Run tests
npx nx run-many -t test

# Run E2E tests
npx nx e2e e2e-cli

# Lint all packages
npx nx run-many -t lint

Package Dependency Graph

@anygpt/types (no deps)
    ↓
@anygpt/config, @anygpt/mock
    ↓
@anygpt/router → @anygpt/openai
    ↓
@anygpt/cli, @anygpt/mcp

Key Features

🎯 Modular Architecture

  • Clean separation: Each package has a single responsibility
  • Zero runtime overhead: Type-only packages with import type
  • Dependency inversion: Connectors depend on router, not vice versa

🔧 Dynamic Configuration

  • Runtime connector loading: No hardcoded dependencies
  • Multiple config sources: TypeScript, JavaScript, JSON files
  • Environment support: User home, system-wide, project-local configs
  • Plugin system: Auto-discovery and configuration generation

🔍 MCP Discovery & Management

  • Auto-discovery: Automatically finds and configures Docker MCP servers
  • Tool-focused CLI: Execute tools without knowing which server provides them
  • Server rules: Enable/disable servers while maintaining visibility
  • Variadic arguments: Natural command-line syntax for tool execution
  • On-demand loading: Load only what you need, when you need it

🚀 Developer Experience

  • Full TypeScript support: Complete type safety across all packages
  • Comprehensive CLI: Stateful conversations, forking, summarization, MCP management
  • Testing utilities: Mock connector for development and testing
  • Progress indicators: Visual feedback for long-running operations

🔌 Extensible Design

  • Connector pattern: Easy to add new AI providers
  • Plugin architecture: Extensible command system with auto-discovery
  • MCP compliance: Full protocol implementation
  • Separate server instances: Each MCP server runs independently

Comprehensive Testing

  • 30 E2E tests: Complete CLI workflow validation with 0 skipped tests
  • Mock connector: Deterministic responses for reliable testing
  • Full coverage: Chat, conversations, config management, and error handling
  • CI/CD ready: Fast, reliable tests that run in < 15 seconds

Documentation

Getting Started

Integration Examples

Development Guidelines

CLI Commands

Package Documentation

Core Packages:

MCP & Discovery:

Connectors:

CLI:

Architecture Documentation

CLI Documentation

Security

⚠️ Important: This project handles sensitive credentials. Please review SECURITY.md before contributing.

Key security practices:

  • Never commit API keys or tokens
  • Use environment variables for credentials
  • Run security checks before committing (see .windsurf/workflows/security-check.md)
  • Use generic examples (e.g., example.com) instead of internal URLs

License

MIT License - see LICENSE file for details.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选