Secure MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Secure MCP Serverread the file at /tmp/notes.txt"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Secure MCP Server
A Python MCP server with bearer token authentication, rate limiting, and allowlisted file/HTTP tools.
What This Is
Bearer auth + token-bucket rate limiting + path/domain allowlists for MCP tools. Fails closed: won't start without MCP_BEARER_TOKEN.
Related MCP server: FlexFS MCP
What This Is NOT
Not a sandbox. This runs in your process space with your privileges. It will:
✅ Block requests without valid bearer token (fail-closed at startup)
✅ Rate-limit requests per session (token bucket)
✅ Enforce path and domain allowlists
✅ Block path traversal and symlink escapes
✅ Enforce file size limits
✅ Redact secrets from logs
But it will not:
❌ Provide process isolation or syscall filtering
❌ Prevent execution of malicious code in tool paths
❌ Protect against kernel exploits
❌ Stop filesystem access outside Python (if attacker gets code exec)
❌ Prevent memory corruption attacks
Threat model: A misbehaving MCP client that follows the protocol but tries to read/write wrong paths or hit wrong domains. Not a defense against arbitrary code execution or kernel-level attacks.
Installation
Using uv (recommended)
git clone https://github.com/RanaPriyansh/secure-mcp-server.git
cd secure-mcp-server
uv pip install -e ".[dev]"Using pip
git clone https://github.com/RanaPriyansh/secure-mcp-server.git
cd secure-mcp-server
pip install -e ".[dev]"Usage
Running the Server
export MCP_BEARER_TOKEN="your-secret-token"
export MCP_ALLOWED_PATHS="/tmp:/var/log"
export MCP_ALLOWED_DOMAINS="example.com:api.github.com"
python -m secure_mcp_serverConfiguration
All configuration is via environment variables:
Variable | Required | Default | Description |
| Yes | - | Bearer token for authentication (fail-closed) |
| No |
| Colon-separated list of allowed filesystem paths |
| No |
| Colon-separated list of allowed HTTP domains |
| No |
| Maximum file size (10 MB default) |
| No |
| Rate limit bucket capacity |
| No |
| Rate limit refill period |
Tools
read_file
Read file contents from allowed paths.
{
"path": "/tmp/example.txt"
}list_directory
List directory contents from allowed paths.
{
"path": "/tmp"
}fetch_url
Fetch HTTPS URLs from allowed domains.
{
"url": "https://api.github.com/repos/owner/repo"
}Testing
Run the test suite:
pytestRun with coverage:
pytest --cov=secure_mcp_server --cov-report=htmlTests run in-process with fixtures. No GPU, no network, no production secrets needed.
Development
Install development dependencies:
pip install -e ".[dev]"License
MIT License - see LICENSE file for details.
Author
Priyansh Rana
This server cannot be deployed
Maintenance
Related MCP Connectors
Manage websites, help documents and customer-support conversations with safe, scoped tools.
Artifact store for AI agents — read, write, and search files by path; share by rendered URL.
Sandbox workspace tools: search, file read, DB queries, integrations. Returns synthetic data.
Prompt-injection scanning and safe webpage fetching for AI agents reading untrusted content.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceProvides sandboxed access to local filesystem operations including directory and file management, content search with glob and regex patterns, and binary file support with configurable safety limits.-
- FlicenseCqualityDmaintenanceProvides secure file system, web fetching, and Google Cloud Storage access for AI IDEs.6-
- AlicenseNot gradedqualityDmaintenanceProvides secure access to local files from specified directories. Enables listing files, reading contents, and configurable file size and extension filtering.1MIT
- AlicenseNot gradedqualityDmaintenanceProvides secure, read-only database queries, HTTP GET requests with anti-SSRF protection, and file reading within a restricted directory.MIT