Secure Model Context Protocol - Security layers for MCP servers
Project description
SMCP - Secure Model Context Protocol
A security-focused wrapper library for MCP (Model Context Protocol) servers, providing multiple layers of protection through conditional guards that activate only when needed.
Features
- Conditional Security Guards: Each security layer activates only when its required configuration is present
- Mutual TLS Support: Automatic certificate-based authentication
- Host Allowlisting: Outbound connection validation
- Input Sanitization: Prompt and parameter filtering
- Destructive Action Confirmation: Queue-based approval system for dangerous operations
- Tamper-proof Logging: SHA-chained append-only audit logs
- Universal Coverage: Same decorator factory works for tools, prompts, and retrieval
Quick Start
from smcp import FastSMCP as FastMCP
from smcp import tool, prompt
# Configure security features (all optional)
cfg = {
"ca_path": "ca.pem",
"cert_path": "server.pem",
"key_path": "server.key",
"ALLOWED_HOSTS": ["api.internal.local", "10.0.0.5"],
"SAFE_RE": r"^[\w\s.,:;!?-]{1,2048}$",
"LOG_PATH": "/var/log/smcp.log"
}
app = FastMCP("myserver", smcp_cfg=cfg)
@tool(confirm=True) # Requires approval
def delete_user(uid: str):
...
@prompt() # Auto-filtered if SAFE_RE present
def chat(prompt: str):
...
Security Guards
| Feature | Activation Trigger | Purpose |
|---|---|---|
| Mutual TLS | ca_path, cert_path, key_path in config |
Certificate-based authentication |
| Host Allowlist | Non-empty ALLOWED_HOSTS |
Outbound connection validation |
| Input Filtering | SAFE_RE or MAX_LEN defined |
Sanitize prompts and parameters |
| Action Confirmation | confirm=True on decorator |
Queue destructive operations for approval |
| Audit Logging | LOG_PATH set |
Tamper-proof operation logging |
CLI Tools
# Generate certificates
smcp-mkcert --ca-name "MyCA" --server-name "myserver.local"
# Approve queued actions
smcp-approve <action-id>
Installation
From PyPI.org (Public)
pip install bizteam-smcp
From Private PyPI Server
# Using private PyPI server
pip install --extra-index-url https://bizteamai.com/pypi/simple/ bizteam-smcp
Upgrading to Business Edition
For additional features and enterprise support, a business edition is available:
pip install --extra-index-url https://bizteamai.com/pypi/simple/ bizteam-smcp-biz
Contact: business@bizteamai.com for more information.
License
MIT License
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 bizteamai_smcp-1.23.1.tar.gz.
File metadata
- Download URL: bizteamai_smcp-1.23.1.tar.gz
- Upload date:
- Size: 26.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e9b7915cea217dc5378d32970d69fd512947992e9b0d8faa835d0cb28124114
|
|
| MD5 |
f813954772afcf39c0ca279b4849749c
|
|
| BLAKE2b-256 |
431c766d20b8c1cd175e6eb7c1cebaab68a00138d02cefdc12f1308513e4e296
|
File details
Details for the file bizteamai_smcp-1.23.1-py3-none-any.whl.
File metadata
- Download URL: bizteamai_smcp-1.23.1-py3-none-any.whl
- Upload date:
- Size: 27.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df68fad7fce82fd46278ec4e19f2d2d1a0b4f6b53459958a12e8a7373eefd44c
|
|
| MD5 |
680ed1b6011cd18dbd990917c66c431f
|
|
| BLAKE2b-256 |
e28fcfeba330c714e8e29888f8e499ff564abe126b665476171fec5a4291c0c1
|