Skip to main content

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


Download files

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

Source Distribution

bizteamai_smcp-1.21.0.tar.gz (26.1 kB view details)

Uploaded Source

Built Distribution

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

bizteamai_smcp-1.21.0-py3-none-any.whl (27.2 kB view details)

Uploaded Python 3

File details

Details for the file bizteamai_smcp-1.21.0.tar.gz.

File metadata

  • Download URL: bizteamai_smcp-1.21.0.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

Hashes for bizteamai_smcp-1.21.0.tar.gz
Algorithm Hash digest
SHA256 7b67561589ebab1a9d89f92ad7a3a5d7e7161b50669e5c064a3d117eaf23774f
MD5 e91db2c6bbea68e5ef77c07ac8e8eedf
BLAKE2b-256 3e5921a6484a6f0921bbecefff3e3326bb7abd1c7c44699350cbab333343fefe

See more details on using hashes here.

File details

Details for the file bizteamai_smcp-1.21.0-py3-none-any.whl.

File metadata

File hashes

Hashes for bizteamai_smcp-1.21.0-py3-none-any.whl
Algorithm Hash digest
SHA256 550906f0125d8fbc69dda86b5ff345fd9b6f8a1c39a19ad32be9eb9a0da2d501
MD5 ff198c75ae1d4222728f8617c55703b6
BLAKE2b-256 f18cfb0637b067c99c85911e7091542667d25b78863ea440db646d4741501257

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