Skip to main content

A lightweight factory framework for creating and managing MCP (Model Context Protocol) servers with simplified configuration and project building capabilities.

Project description

MCP Factory

MCP Factory Python License

A factory framework focused on MCP server creation and management

🎯 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

pip install mcp-factory

Basic Usage

📋 Programmatic Mode

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

# config.yaml
server:
  name: file-server
  description: "Server from configuration file"

management:
  expose_management_tools: true
  authorization: true

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

components:
  tools:
    - module: "file_tools"
      enabled: true
factory = MCPFactory(workspace_root="./workspace")
server_id = factory.create_server("file-server", "config.yaml")

🏗️ Project Mode

mcp-factory project create my-server

🚀 Direct Server Creation

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

# 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)

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)

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/ directory for complete usage examples:

# Run tests
pytest

# Generate coverage report
pytest --cov=mcp_factory

📖 Documentation

📄 License

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_factory-1.6.1.tar.gz (194.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_factory-1.6.1-py3-none-any.whl (219.2 kB view details)

Uploaded Python 3

File details

Details for the file mcp_factory-1.6.1.tar.gz.

File metadata

  • Download URL: mcp_factory-1.6.1.tar.gz
  • Upload date:
  • Size: 194.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mcp_factory-1.6.1.tar.gz
Algorithm Hash digest
SHA256 102d0db3da68fbb8eac72e440559933937a47a1bcc0a432086a2915ac6571e31
MD5 be76d87eb0ba351d57aa95385157c454
BLAKE2b-256 ef2c5668ec63a09b56b4f7cdd3ded4aeee3bd8f79d32d47c20a70d4237f214ea

See more details on using hashes here.

File details

Details for the file mcp_factory-1.6.1-py3-none-any.whl.

File metadata

  • Download URL: mcp_factory-1.6.1-py3-none-any.whl
  • Upload date:
  • Size: 219.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mcp_factory-1.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 69a0c6df4eb6a949b3d892c03d876be3fa9c6c8ec0d7f6206276fbf1e9ee7aee
MD5 0eae36f307c8d29e029ebdd6bca2811f
BLAKE2b-256 89529b69b5b8236f6b8f013f6fce0cd900a8e4ab364d1deea2f7bbdbc0a39fe0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page