Skip to main content

Secure execution layer for LLM/MCP agents

Project description

๐Ÿ›ก๏ธ Secure-MCP

English ํ•œ๊ตญ์–ด ๆ—ฅๆœฌ่ชž ไธญๆ–‡ Espaรฑol

Secure execution layer for LLM/MCP agents โ€” safely integrate agents without exposing .env, secrets, or sensitive system files.


๐Ÿ” What is Secure-MCP?

Secure-MCP is a security-focused middleware framework that wraps around your MCP (Multi-Component Prompting) or LLM Agent systems to ensure that:

  • ๐Ÿšซ .env, API keys, system files, and private configs are not accessible by agent logic.
  • โœ… MCP/agent systems can still safely perform operations, such as calling APIs or retrieving tokens, via a secure proxy.
  • ๐Ÿง  It supports LLM workflows, agent frameworks (like LangChain, AutoGen, CrewAI), and context-based tools โ€” without compromising security.

๐Ÿงฑ Key Features

Feature Description
๐Ÿ” SecureEnvBridge Only whitelisted env variables can be accessed; .env is not directly exposed
๐Ÿ“‚ File Access Control Blocks file reads like .env, secret.pem, key.json, config.yaml etc.
๐Ÿ“ฆ Secure Function Proxy Sensitive operations are abstracted into secured callable functions
๐Ÿ“œ Audit Logging Logs all attempts to access sensitive resources
๐Ÿงช Sandboxed Execution Optionally runs MCP code in an isolated environment (e.g., Docker, WASM)
โš™๏ธ Framework Agnostic Easy to plug into any agent system or LLM pipeline

๐Ÿงฐ Example Use Case

from secure_mcp.secure_env_bridge import secure_get, secure_open

# Only whitelisted environment variables are allowed
api_key = secure_get("SERVICE_AUTH_TOKEN")  # โœ… allowed
db_pw = secure_get("DB_PASSWORD")           # โŒ blocked

# Safe file open (blocks sensitive files)
with secure_open("safe_data.csv") as f:
    content = f.read()

Use SecureEnvBridge instead of os.getenv() and open() to ensure safety.


๐Ÿ”ง Installation

git clone https://github.com/yourname/secure-mcp.git
cd secure-mcp
pip install -e .

You may also package it via setup.py or pyproject.toml for internal PyPI deployment.


๐Ÿ› ๏ธ Architecture

[ User Input / Agent Task ]
           โ†“
[ SecureContextExecutor ]
           โ†“
[ SecureEnvBridge / FileGuard ]
           โ†“
[ External API, File, or Memory Access ]
           โ†“
[ LLM Agent Response ]
  • MCP doesn't need to know the secrets.
  • SecureEnvBridge acts like a vault-aware delegate.
  • Every access is controlled, logged, and filtered.

๐Ÿ“„ Example Structure

secure-mcp/
โ”œโ”€โ”€ secure_env_bridge/
โ”‚   โ”œโ”€โ”€ secure_get.py
โ”‚   โ”œโ”€โ”€ secure_open.py
โ”‚   โ”œโ”€โ”€ whitelist_loader.py
โ”‚   โ””โ”€โ”€ audit_logger.py
โ”œโ”€โ”€ examples/
โ”‚   โ”œโ”€โ”€ fastapi_demo.py
โ”‚   โ””โ”€โ”€ sandbox_runner.py
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ test_env_guard.py
โ”œโ”€โ”€ .env.example
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ setup.py

๐Ÿšง Roadmap

  • SecureEnvBridge with whitelist loader
  • File access guard (open() patch)
  • WASM-based execution wrapper
  • Dockerized secure MCP runner
  • OpenAPI proxy adapter
  • Agent plugin system for LangChain / CrewAI

๐Ÿ” License

This project is licensed under the Apache License 2.0. See the LICENSE file for more details.


๐Ÿค Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Check CONTRIBUTING.md for detailed instructions.


๐Ÿ“ฌ Contact

Questions, ideas, or feedback? Feel free to open an issue or start a discussion.

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

secure_mcp-0.1.0.tar.gz (23.0 kB view details)

Uploaded Source

Built Distribution

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

secure_mcp-0.1.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file secure_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: secure_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 23.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for secure_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b931c102d557b333096cfd76ec7a7da9c4cc3cef9a29326cb99cc89e9719248d
MD5 8bfc0c6404dbcc4bbacd82c76b217f9a
BLAKE2b-256 9e0124eaca6c50cb898993152350d643ff5164ecca8e9579971ea864cf8a84fe

See more details on using hashes here.

File details

Details for the file secure_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: secure_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for secure_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 39f6a535f63ce6e6b0b7eba005d1bbcb5c5c8c267152ae557cb4c02ddaa8514a
MD5 73e6cec2dbd9440be6aa8a4444148960
BLAKE2b-256 28cf8562a0278173c910f2fd1fb1cb7b67930ccfbf127fb96d727cd2f11bf55f

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