mcp-factory


Namemcp-factory JSON
Version 1.1.1 PyPI version JSON
download
home_pageNone
SummaryA lightweight factory framework for creating and managing MCP (Model Context Protocol) servers with simplified configuration and project building capabilities.
upload_time2025-07-25 08:24:52
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
keywords ai factory management mcp model-context-protocol server
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # MCP Factory

<div align="center">

![MCP Factory](https://img.shields.io/badge/MCP-Factory-blue?style=for-the-badge)
![Python](https://img.shields.io/badge/Python-3.10+-green?style=for-the-badge)
![License](https://img.shields.io/badge/License-Apache--2.0-red?style=for-the-badge)

**A factory framework focused on MCP server creation and management**

</div>

## 🎯 Overview

MCP Factory is a lightweight MCP (Model Context Protocol) server creation factory. It focuses on simplifying the building, configuration and management process of MCP servers, enabling developers to quickly create and deploy MCP servers.

### 🌟 Key Features

- **🏭 Server Factory** - Quickly create and configure MCP server instances
- **📁 Project Building** - Automatically generate complete MCP project structure
- **🔧 Configuration Management** - Flexible YAML configuration system
- **🔗 Server Mounting** - Support multi-server mounting and management
- **🛠️ CLI Tools** - Simple and easy-to-use command line interface
- **🔐 Permission Control** - Scope-based access control with 4-level permission system
- **⚙️ Management Tools** - FastMCP native methods exposed as server tools (20+ tools)
- **🛡️ Production Security** - Automatic security validation and flexible authentication

## 🚀 Quick Start

### Installation

```bash
pip install mcp-factory
```

### Basic Usage

#### 📋 Programmatic Mode
```python
from mcp_factory import MCPFactory

factory = MCPFactory(workspace_root="./workspace")
config = {
    "server": {"name": "api-server", "description": "Dynamic API server"},
    "components": {
        "tools": [{"module": "greeting_tools", "enabled": True}]
    }
}
server_id = factory.create_server("api-server", config)
```

#### 📄 Configuration File Mode
```yaml
# config.yaml
server:
  name: file-server
  description: "Server from configuration file"

management:
  expose_management_tools: true
  enable_permission_check: true

auth:
  provider: "none"  # or "oauth" for OAuth2 flow

components:
  tools:
    - module: "file_tools"
      enabled: true
```

```python
factory = MCPFactory(workspace_root="./workspace")
server_id = factory.create_server("file-server", "config.yaml")
```

#### 🏗️ Project Mode
```bash
mcp-factory project create my-server
```

#### 🚀 Direct Server Creation
```python
from mcp_factory import ManagedServer

server = ManagedServer(name="direct-server")

@server.tool()
def calculate(x: float, y: float, operation: str) -> float:
    """Perform mathematical calculations"""
    return x + y if operation == "add" else x * y

server.run()
```

## 🎛️ Operation Modes

| Mode | Best For | Key Features |
|------|----------|-------------|
| **📋 Dictionary** | Enterprise Integration, Testing | Programmatic control, dynamic configuration |
| **📄 Config File** | DevOps, Team Collaboration | Environment-specific deployment, standardized templates |
| **🏗️ Project** | Professional Development | Complex applications, full security features |

## 🛠️ CLI Usage

```bash
# Create new project
mcp-factory project create my-project

# Create shared component
mcp-factory config component create --type tools --name "auth_tools"

# Quick start temporary server
mcp-factory server quick

# Run server from config file or project name
mcp-factory server run config.yaml
mcp-factory server run my-project

# Run with custom transport
mcp-factory server run config.yaml --transport http --host 0.0.0.0 --port 8080

# Publish project to GitHub
mcp-factory project publish my-project

# List all servers
mcp-factory server list
```

### 🔐 Authentication Setup

**JWT Authentication (via environment variables)**
```bash
export FASTMCP_AUTH_BEARER_PUBLIC_KEY="-----BEGIN PUBLIC KEY-----..."
export FASTMCP_AUTH_BEARER_ISSUER="https://your-auth-server.com"
export FASTMCP_AUTH_BEARER_AUDIENCE="your-app-name"
```

**OAuth2 Authentication (via configuration)**
```yaml
auth:
  provider: "oauth"
  oauth:
    issuer_url: "https://your-auth-server.com"
    client_id: "your-client-id"
    scopes: ["openid", "mcp:read", "mcp:write", "mcp:admin"]
```

**Required Token Scopes:**
- `mcp:read` - readonly management tools
- `mcp:write` - modify management tools  
- `mcp:admin` - destructive management tools
- `mcp:external` - external system tools

## 🏗️ Architecture

### Core Components

- **MCPFactory** - Main factory class supporting all operation modes
- **ManagedServer** - Server class with decorator-based tool registration
- **Configuration System** - Flexible YAML configuration management
- **Project Builder** - Automatic project structure generation

### 🔧 Management Tools System

Our servers automatically register **20+ management tools** from FastMCP native methods with 4-level permission control:

**Permission Levels:** readonly → modify → destructive → external

**Key Tools:** `manage_get_tools`, `manage_add_tool`, `manage_remove_tool`, `manage_mount`, `manage_import_server`, etc.

## 📚 Examples & Testing

Check the [examples/](examples/) directory for complete usage examples:
- [Basic Server](examples/basic_server.py) - Simple MCP server
- [Factory Complete](examples/factory_complete.py) - Complete workflow
- [Server Mounting](examples/mounting_servers.py) - Multi-server mounting
- [Management Tools Demo](examples/demo/) - Interactive management tools

```bash
# Run tests
pytest

# Generate coverage report
pytest --cov=mcp_factory
```

## 📖 Documentation

- [Configuration Guide](docs/configuration.md)
- [CLI Usage Guide](docs/cli-guide.md)
- [Architecture Documentation](docs/architecture/)

## 📄 License

This project is licensed under the Apache-2.0 License - see the [LICENSE](LICENSE) file for details. 
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "mcp-factory",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "ai, factory, management, mcp, model-context-protocol, server",
    "author": null,
    "author_email": "ACNet-AI <agencollabnet@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/4a/83/cc9b0277d831ac4ee64e1976a3a0ae60f4a1a29b03cf52b7fcc4e63814ca/mcp_factory-1.1.1.tar.gz",
    "platform": null,
    "description": "# MCP Factory\n\n<div align=\"center\">\n\n![MCP Factory](https://img.shields.io/badge/MCP-Factory-blue?style=for-the-badge)\n![Python](https://img.shields.io/badge/Python-3.10+-green?style=for-the-badge)\n![License](https://img.shields.io/badge/License-Apache--2.0-red?style=for-the-badge)\n\n**A factory framework focused on MCP server creation and management**\n\n</div>\n\n## \ud83c\udfaf Overview\n\nMCP Factory is a lightweight MCP (Model Context Protocol) server creation factory. It focuses on simplifying the building, configuration and management process of MCP servers, enabling developers to quickly create and deploy MCP servers.\n\n### \ud83c\udf1f Key Features\n\n- **\ud83c\udfed Server Factory** - Quickly create and configure MCP server instances\n- **\ud83d\udcc1 Project Building** - Automatically generate complete MCP project structure\n- **\ud83d\udd27 Configuration Management** - Flexible YAML configuration system\n- **\ud83d\udd17 Server Mounting** - Support multi-server mounting and management\n- **\ud83d\udee0\ufe0f CLI Tools** - Simple and easy-to-use command line interface\n- **\ud83d\udd10 Permission Control** - Scope-based access control with 4-level permission system\n- **\u2699\ufe0f Management Tools** - FastMCP native methods exposed as server tools (20+ tools)\n- **\ud83d\udee1\ufe0f Production Security** - Automatic security validation and flexible authentication\n\n## \ud83d\ude80 Quick Start\n\n### Installation\n\n```bash\npip install mcp-factory\n```\n\n### Basic Usage\n\n#### \ud83d\udccb Programmatic Mode\n```python\nfrom mcp_factory import MCPFactory\n\nfactory = MCPFactory(workspace_root=\"./workspace\")\nconfig = {\n    \"server\": {\"name\": \"api-server\", \"description\": \"Dynamic API server\"},\n    \"components\": {\n        \"tools\": [{\"module\": \"greeting_tools\", \"enabled\": True}]\n    }\n}\nserver_id = factory.create_server(\"api-server\", config)\n```\n\n#### \ud83d\udcc4 Configuration File Mode\n```yaml\n# config.yaml\nserver:\n  name: file-server\n  description: \"Server from configuration file\"\n\nmanagement:\n  expose_management_tools: true\n  enable_permission_check: true\n\nauth:\n  provider: \"none\"  # or \"oauth\" for OAuth2 flow\n\ncomponents:\n  tools:\n    - module: \"file_tools\"\n      enabled: true\n```\n\n```python\nfactory = MCPFactory(workspace_root=\"./workspace\")\nserver_id = factory.create_server(\"file-server\", \"config.yaml\")\n```\n\n#### \ud83c\udfd7\ufe0f Project Mode\n```bash\nmcp-factory project create my-server\n```\n\n#### \ud83d\ude80 Direct Server Creation\n```python\nfrom mcp_factory import ManagedServer\n\nserver = ManagedServer(name=\"direct-server\")\n\n@server.tool()\ndef calculate(x: float, y: float, operation: str) -> float:\n    \"\"\"Perform mathematical calculations\"\"\"\n    return x + y if operation == \"add\" else x * y\n\nserver.run()\n```\n\n## \ud83c\udf9b\ufe0f Operation Modes\n\n| Mode | Best For | Key Features |\n|------|----------|-------------|\n| **\ud83d\udccb Dictionary** | Enterprise Integration, Testing | Programmatic control, dynamic configuration |\n| **\ud83d\udcc4 Config File** | DevOps, Team Collaboration | Environment-specific deployment, standardized templates |\n| **\ud83c\udfd7\ufe0f Project** | Professional Development | Complex applications, full security features |\n\n## \ud83d\udee0\ufe0f CLI Usage\n\n```bash\n# Create new project\nmcp-factory project create my-project\n\n# Create shared component\nmcp-factory config component create --type tools --name \"auth_tools\"\n\n# Quick start temporary server\nmcp-factory server quick\n\n# Run server from config file or project name\nmcp-factory server run config.yaml\nmcp-factory server run my-project\n\n# Run with custom transport\nmcp-factory server run config.yaml --transport http --host 0.0.0.0 --port 8080\n\n# Publish project to GitHub\nmcp-factory project publish my-project\n\n# List all servers\nmcp-factory server list\n```\n\n### \ud83d\udd10 Authentication Setup\n\n**JWT Authentication (via environment variables)**\n```bash\nexport FASTMCP_AUTH_BEARER_PUBLIC_KEY=\"-----BEGIN PUBLIC KEY-----...\"\nexport FASTMCP_AUTH_BEARER_ISSUER=\"https://your-auth-server.com\"\nexport FASTMCP_AUTH_BEARER_AUDIENCE=\"your-app-name\"\n```\n\n**OAuth2 Authentication (via configuration)**\n```yaml\nauth:\n  provider: \"oauth\"\n  oauth:\n    issuer_url: \"https://your-auth-server.com\"\n    client_id: \"your-client-id\"\n    scopes: [\"openid\", \"mcp:read\", \"mcp:write\", \"mcp:admin\"]\n```\n\n**Required Token Scopes:**\n- `mcp:read` - readonly management tools\n- `mcp:write` - modify management tools  \n- `mcp:admin` - destructive management tools\n- `mcp:external` - external system tools\n\n## \ud83c\udfd7\ufe0f Architecture\n\n### Core Components\n\n- **MCPFactory** - Main factory class supporting all operation modes\n- **ManagedServer** - Server class with decorator-based tool registration\n- **Configuration System** - Flexible YAML configuration management\n- **Project Builder** - Automatic project structure generation\n\n### \ud83d\udd27 Management Tools System\n\nOur servers automatically register **20+ management tools** from FastMCP native methods with 4-level permission control:\n\n**Permission Levels:** readonly \u2192 modify \u2192 destructive \u2192 external\n\n**Key Tools:** `manage_get_tools`, `manage_add_tool`, `manage_remove_tool`, `manage_mount`, `manage_import_server`, etc.\n\n## \ud83d\udcda Examples & Testing\n\nCheck the [examples/](examples/) directory for complete usage examples:\n- [Basic Server](examples/basic_server.py) - Simple MCP server\n- [Factory Complete](examples/factory_complete.py) - Complete workflow\n- [Server Mounting](examples/mounting_servers.py) - Multi-server mounting\n- [Management Tools Demo](examples/demo/) - Interactive management tools\n\n```bash\n# Run tests\npytest\n\n# Generate coverage report\npytest --cov=mcp_factory\n```\n\n## \ud83d\udcd6 Documentation\n\n- [Configuration Guide](docs/configuration.md)\n- [CLI Usage Guide](docs/cli-guide.md)\n- [Architecture Documentation](docs/architecture/)\n\n## \ud83d\udcc4 License\n\nThis project is licensed under the Apache-2.0 License - see the [LICENSE](LICENSE) file for details. ",
    "bugtrack_url": null,
    "license": null,
    "summary": "A lightweight factory framework for creating and managing MCP (Model Context Protocol) servers with simplified configuration and project building capabilities.",
    "version": "1.1.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/ACNet-AI/mcp-factory/issues",
        "Homepage": "https://github.com/ACNet-AI/mcp-factory",
        "Repository": "https://github.com/ACNet-AI/mcp-factory"
    },
    "split_keywords": [
        "ai",
        " factory",
        " management",
        " mcp",
        " model-context-protocol",
        " server"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "701e6a7a0493d7256a4ce3eb7f2d3f774ea34b100bbb813e4336ea1fc8bd89a2",
                "md5": "7a53cb41c9786e5c9e7b90a04eaa71de",
                "sha256": "fa650b1b158972d68380c57f3017b3f4faffbba103861b61056028e55cdce82e"
            },
            "downloads": -1,
            "filename": "mcp_factory-1.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7a53cb41c9786e5c9e7b90a04eaa71de",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 108728,
            "upload_time": "2025-07-25T08:24:51",
            "upload_time_iso_8601": "2025-07-25T08:24:51.682825Z",
            "url": "https://files.pythonhosted.org/packages/70/1e/6a7a0493d7256a4ce3eb7f2d3f774ea34b100bbb813e4336ea1fc8bd89a2/mcp_factory-1.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4a83cc9b0277d831ac4ee64e1976a3a0ae60f4a1a29b03cf52b7fcc4e63814ca",
                "md5": "4c64549d56c752f911c94e11f2dd1041",
                "sha256": "b64159e11d50c8617f920f27d97cce899f1b72ef5585e58b4f76021c55502347"
            },
            "downloads": -1,
            "filename": "mcp_factory-1.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "4c64549d56c752f911c94e11f2dd1041",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 99736,
            "upload_time": "2025-07-25T08:24:52",
            "upload_time_iso_8601": "2025-07-25T08:24:52.913645Z",
            "url": "https://files.pythonhosted.org/packages/4a/83/cc9b0277d831ac4ee64e1976a3a0ae60f4a1a29b03cf52b7fcc4e63814ca/mcp_factory-1.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-25 08:24:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ACNet-AI",
    "github_project": "mcp-factory",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "mcp-factory"
}
        
Elapsed time: 0.58770s