A factory framework focused on MCP server creation and management
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.
- π 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
pip install mcp-factory
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)
# 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")
mcp-factory project create my-server
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()
| 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 |
# 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
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 toolsmcp:write- modify management toolsmcp:admin- destructive management toolsmcp:external- external system tools
- 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
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.
Check the examples/ directory for complete usage examples:
- Basic Server - Simple MCP server
- Factory Complete - Complete workflow
- Server Mounting - Multi-server mounting
- Management Tools Demo - Interactive management tools
# Run tests pytest # Generate coverage report pytest --cov=mcp_factory
- Getting Started Guide - Quick setup and basic usage
- Configuration Guide - Detailed configuration options
- CLI Usage Guide - Command-line interface documentation
- Authorization System - Permission management and security
- Architecture Documentation - System architecture and design
This project is licensed under the Apache-2.0 License - see the LICENSE file for details.