Skip to main content

Enterprise-grade MCP framework built on FastMCP

Project description

SMF - Enterprise MCP Framework

SMF is a production-ready Python framework built on top of FastMCP that makes it significantly simpler and more professional to create, structure, and deploy MCP (Model Context Protocol) servers in enterprise production environments.

Features

  • ๐Ÿ—๏ธ High-level abstractions: ServerFactory and AppBuilder for minimal boilerplate
  • ๐Ÿ”ง Modular registration: Filesystem conventions, explicit registries, and plugin discovery
  • โš™๏ธ Production runtime: Configuration system, structured logging, health endpoints, lifecycle management
  • ๐Ÿ” Enterprise auth: Pluggable authentication (JWT, OAuth, OIDC) and authorization policies
  • ๐Ÿ”„ Middleware pipeline: Chain of Responsibility pattern for logging, metrics, rate limiting, error handling
  • ๐Ÿ”Œ Plugin system: Extensible architecture with stable interfaces
  • ๐Ÿ“Š Observability: Prometheus metrics, OpenTelemetry tracing, structured logging
  • ๐Ÿš€ CLI & Templates: Project scaffolding and code generation

Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   CLI & Templates           โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Integrations (AuthZ, AI SDK) โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Extensions & Middleware    โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚    Core SMF Layer          โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚    FastMCP (Upstream)        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

SMF wraps FastMCP without modifying it, ensuring compatibility with FastMCP updates while adding enterprise features.

Quick Start

Installation

uv add smf fastmcp

Simple Server

from smf import create_server

# Create server
mcp = create_server("My Server")

# Register a tool
@mcp.tool
def greet(name: str) -> str:
    """Greet someone by name."""
    return f"Hello, {name}!"

if __name__ == "__main__":
    mcp.run()

Advanced Server with AppBuilder

from smf import AppBuilder, Settings

# Custom settings
settings = Settings(
    server_name="My Server",
    structured_logging=True,
    metrics_enabled=True,
    rate_limit_enabled=True,
)

# Use AppBuilder
with AppBuilder(settings=settings) as builder:
    @builder.tool(tags=["math"])
    def add(a: float, b: float) -> float:
        """Add two numbers."""
        return a + b
    
    mcp = builder.build()

if __name__ == "__main__":
    mcp.run(transport="http", port=8000)

Configuration

SMF uses Pydantic-based settings that can be loaded from:

  • Environment variables (prefix: SMF_)
  • .env files
  • YAML/JSON configuration files
# smf.yaml
server_name: "My Server"
server_version: "1.0.0"
transport: "http"
host: "0.0.0.0"
port: 8000
structured_logging: true
metrics_enabled: true
rate_limit_enabled: true
rate_limit_per_minute: 100
auth_provider: "jwt"
auth_config:
  secret: "${JWT_SECRET}"

CLI

# Initialize new project
smf init my-server

# Initialize project with Elasticsearch plugin
smf init my-server --elasticsearch --es-index "products"

# Add a tool
smf add-tool my-tool --description "Tool description"

# Validate configuration (syntax and values)
smf validate --config smf.yaml

# Validate with comprehensive tests
smf validate --config smf.yaml --tests

# Run server
smf run server.py --transport http --port 8000

# Inspect server (Official Web Inspector)
smf inspector server.py

Core Components

ServerFactory

Creates configured FastMCP servers with defaults applied:

from smf import ServerFactory, Settings

factory = ServerFactory(settings=Settings())
mcp = factory.create(name="My Server")

AppBuilder

Fluent interface for registering components:

from smf import AppBuilder

builder = AppBuilder()
builder.tool(my_function)
builder.resource(my_resource)
mcp = builder.build()

Settings

Centralized configuration management:

from smf import Settings

settings = Settings(
    server_name="My Server",
    structured_logging=True,
    metrics_enabled=True,
)

Middleware

SMF provides built-in middleware:

  • StructuredLoggingMiddleware: JSON-structured logging
  • TracingMiddleware: OpenTelemetry distributed tracing
  • RateLimitingMiddleware: Token bucket rate limiting
  • ErrorHandlingMiddleware: Normalized error responses
  • MetricsMiddleware: Prometheus metrics collection

Authentication

Pluggable authentication providers:

from smf import Settings, AuthProvider

settings = Settings(
    auth_provider=AuthProvider.JWT,
    auth_config={
        "secret": "your-secret-key",
        "algorithm": "HS256",
    }
)

Supported providers:

  • JWT
  • OAuth
  • OIDC (via TokenVerifier)
  • Custom providers

Plugins

Elasticsearch Plugin

Create Elasticsearch-powered MCP servers:

# Create server with CLI
smf init my-server --elasticsearch --es-index "products"

# Or use in code
from smf.plugins.elasticsearch import ElasticsearchClient, create_elasticsearch_tools

es_client = ElasticsearchClient(hosts="http://localhost:9200")
mcp = create_server("My Server")
tools = create_elasticsearch_tools(es_client, index="products")
for tool in tools:
    mcp.tool(tool)

Install: pip install smf-mcp[elasticsearch]

See Elasticsearch Plugin Documentation for details.

Examples

See src/examples/ for:

  • simple_server/: Basic server setup
  • advanced_server/: Advanced patterns with custom settings

Documentation

Requirements

  • Python 3.11+
  • FastMCP >= 2.11

Development

# Install dependencies
uv sync --dev

# Run tests
pytest

# Format code
black src/

# Type check
mypy src/

License

MIT

Credits

Built on FastMCP by Prefect.

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

smf_mcp-0.1.7.tar.gz (52.7 kB view details)

Uploaded Source

Built Distribution

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

smf_mcp-0.1.7-py3-none-any.whl (78.5 kB view details)

Uploaded Python 3

File details

Details for the file smf_mcp-0.1.7.tar.gz.

File metadata

  • Download URL: smf_mcp-0.1.7.tar.gz
  • Upload date:
  • Size: 52.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for smf_mcp-0.1.7.tar.gz
Algorithm Hash digest
SHA256 16f517ad7ea59b50dec9e64c210ac446815ebfc13ec9b0a9a928a9afd8e49446
MD5 46ab2ae570adb72a6534a893c3b2e60d
BLAKE2b-256 2fdb3f92399f7f3a64c24d7f2c3fe7b57edebf93fb0298f06a5c497fa5fe01c7

See more details on using hashes here.

File details

Details for the file smf_mcp-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: smf_mcp-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 78.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for smf_mcp-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 cea5600938135d049f289214dd16d90e346be57d1735f151f9e69eebe7ec925b
MD5 347eb1a731d499f96f7ff707260d1375
BLAKE2b-256 f0f96072ae910e515d00691ef1cf7395e36f5cae85471a2485c2f9e9ebd177e5

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