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:
ServerFactoryandAppBuilderfor 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_) .envfiles- 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
# Activate a plugin (e.g., Elasticsearch)
smf activate-plugin elasticsearch
# Add a tool
smf add-tool my-tool --description "Tool description"
# Validate configuration
smf validate --config smf.yaml
# Run server
smf run server.py --transport http --port 8000
# Inspect server (Official Web Inspector)
smf-inspector server.py
# Inspect server (Legacy Text Mode)
smf-inspector server.py --text
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-elasticsearch my-server --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[elasticsearch]
See Elasticsearch Plugin Documentation for details.
Examples
See src/examples/ for:
simple_server/: Basic server setupadvanced_server/: Advanced patterns with custom settings
Documentation
- FastMCP Research: FastMCP API mapping
- Architecture: Detailed architecture 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file smf_mcp-0.1.0.tar.gz.
File metadata
- Download URL: smf_mcp-0.1.0.tar.gz
- Upload date:
- Size: 36.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c29f8cdbfb1fc6e2e96c2e4009c4d480ae1652e9ddd5e7df16918841abb85ded
|
|
| MD5 |
1c01b321d203313815d081d1797d4d37
|
|
| BLAKE2b-256 |
779d1977c1459085b3d3918c95f46c196ee9528148c3919e7e0629a68dfc302f
|
File details
Details for the file smf_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: smf_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 46.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
afd2f8095a19475f806bc7a86134224750f2cdac6b0daf9f45671d58a2f7c242
|
|
| MD5 |
6d22ed4bc910cf06205ab6b5fc7d2cf3
|
|
| BLAKE2b-256 |
f43e21101a84320a088d7ef5a890fac3c6fd302c9ed0bcd5e577a9068e436c04
|