Metadata-Version: 2.4
Name: mcp-dynamic-proxy
Version: 0.1.2
Summary: Dynamic MCP proxy server with progressive discovery and lazy loading
Author: Nicolas Mallet
Maintainer: Nicolas Mallet
License: MIT License
        
        Copyright (c) 2025 Nicolas Mallet
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: ai,lazy-loading,llm,mcp,model-context-protocol,progressive-discovery,proxy
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Internet :: Proxy Servers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.12
Requires-Dist: fastmcp~=2.13.0
Requires-Dist: jsonschema~=4.20.0
Requires-Dist: mcp~=1.19.0
Requires-Dist: psutil~=5.9.0
Requires-Dist: pydantic>=2.5.0
Requires-Dist: structlog~=24.4.0
Requires-Dist: tenacity~=8.2.0
Provides-Extra: dev
Requires-Dist: mypy~=1.8.0; extra == 'dev'
Requires-Dist: pytest-asyncio~=0.23.0; extra == 'dev'
Requires-Dist: pytest-cov~=4.1.0; extra == 'dev'
Requires-Dist: pytest-timeout~=2.2.0; extra == 'dev'
Requires-Dist: pytest~=8.0.0; extra == 'dev'
Requires-Dist: ruff~=0.1.0; extra == 'dev'
Description-Content-Type: text/markdown

# MCP Dynamic Proxy

A dynamic MCP (Model Context Protocol) proxy server that provides progressive discovery and lazy loading of MCP servers, dramatically reducing initial context size from 20-300 tools to just 3 core tools.

## Features

- **Progressive Discovery**: Discover MCP servers by tags, category, or search term without loading them
- **Lazy Loading**: Load MCP servers only when needed
- **Minimal Context**: Only 3 core discovery/execution tools exposed initially instead of hundreds
- **Full MCP Protocol**: Uses official MCP SDK for end-to-end protocol support

## Architecture

```
Assistant (Cursor) -MCP-> MCP Dynamic Proxy -MCP-> MCP Servers (AWS, PostgreSQL, etc.)
```

The proxy exposes only 3 core tools:
1. `mcp_discover_servers` - Discover available MCP servers
2. `mcp_list_tools` - List tools from a specific MCP server
3. `mcp_execute_tool` - Execute a tool on an MCP server

## Installation

### Prerequisites

- Python 3.12+

### Setup

Install dependencies (requires Python 3.12 available on PATH):

```bash
python3.12 -m pip install -e .
```

For development:

```bash
python3.12 -m pip install -e ".[dev]"
```

## Configuration

Create a `config/mcp.json` file with your MCP server configurations:

```json
{
  "version": "1.0",
  "mcpServers": {
    "aws-knowledge-mcp-server": {
      "description": "AWS knowledge base with documentation, best practices, and service information",
      "tags": ["aws", "documentation", "cloud", "knowledge"],
      "category": "documentation",
      "command": "uvx",
      "args": ["fastmcp", "run", "https://knowledge-mcp.global.api.aws"]
    },
    "microsoft.docs.mcp": {
      "description": "Microsoft Learn documentation and Azure documentation access",
      "tags": ["microsoft", "azure", "documentation", "learn"],
      "category": "documentation",
      "command": "uvx",
      "args": ["fastmcp", "run", "https://learn.microsoft.com/api/mcp"]
    }
  }
}
```

### Configuration Fields

- `description`: Human-readable description of the server
- `tags`: List of tags for filtering (e.g., `["aws", "database"]`)
- `category`: Server category (e.g., `"database"`, `"documentation"`)
- `command`: Command to start the MCP server
- `args`: Arguments for the command
- `env`: Optional environment variables (supports `${VAR_NAME}` expansion)

## Usage

### Running the Server

Run the MCP proxy server:

```bash
uvx mcp-dynamic-proxy
```

Or with custom config path:

```bash
MCP_CONFIG_PATH=/path/to/config.json uvx mcp-dynamic-proxy
```

### Configuration for Cursor

Add to your Cursor MCP configuration:

```json
{
  "mcpServers": {
    "mcp-dynamic-proxy": {
      "command": "uvx",
      "args": ["mcp-dynamic-proxy"],
      "env": {
        "MCP_CONFIG_PATH": "/path/to/config/mcp.json"
      }
    }
  }
}
```

### Example Workflow

1. **Discover servers**:
   ```
   User: "Show me database servers"
   
   Assistant calls: mcp_discover_servers(tags=["database"])
   
   Response: List of database MCP servers
   ```

2. **List tools**:
   ```
   Assistant calls: mcp_list_tools(server_id="aws-dynamodb")
   
   Response: List of available tools (query, scan, put_item, etc.)
   ```

3. **Execute tool**:
   ```
   Assistant calls: mcp_execute_tool(
     server_id="aws-dynamodb",
     tool_name="query",
     arguments={"table": "users", "key": {"id": "123"}}
   )
   
   Response: Tool execution result
   ```

## License

MIT