Secure MCP Server
Provides read-only system and security-related tools for a Kali Linux host, including Kali/server information, system status, disk status, memory status, network status, network interfaces, and reading permitted text files, without exposing a generic shell or arbitrary command execution.
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 Servercheck the network interfaces on the Kali host"
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
An MCP server for Kali Linux that deliberately has no shell access. Read-only, allowlisted tools behind OAuth 2.0 + PKCE, TLS, rate limiting, and audit logging.
Current release: v1.0.0
Why this project exists
Many MCP servers give an AI client a generic shell or exec endpoint. That makes a single prompt-injection or a leaked token potentially equivalent to broad control of the host.
secure-mcp-server takes the opposite approach: the client can only call a small set of explicitly registered, read-oriented tools. There is no shell, no command execution endpoint, and no arbitrary code execution interface.
Access is authenticated with OAuth 2.0 + PKCE and scoped to mcp:read.
Related MCP server: Kali Factory MCP Server
Features
OAuth 2.0 Authorization Code and Refresh Token flows with PKCE (S256)
Single MCP scope:
mcp:readDynamic public-client registration
Token revocation
SQLite-backed OAuth state
Interactive consent step
JWT signing with EdDSA (Ed25519)
HTTPS with minimum TLS 1.2
ECDSA P-256 certificate generation and validation
DNS rebinding protection and explicit host allowlisting
Rate limiting on
/register,/authorize,/token,/revoke, and/mcpAudit logging with recursive redaction of sensitive arguments
Refuses to run as root
Read-only, explicitly registered MCP tools
Test coverage for OAuth, transport security, TLS, rate limiting, validation, and tools
Architecture
MCP Client (e.g. Termux)
|
| HTTPS + OAuth 2.0 + PKCE
v
Kali Linux MCP Server
|
+-- Streamable HTTP
+-- Host validation
+-- Rate limiting
+-- OAuth authorization
+-- Audit logging
|
v
Allowlisted read-only MCP toolsThe client connects over the local network to:
https://<MCP_PUBLIC_HOST>:<MCP_PORT>/mcpAvailable Tools
Tool | Purpose |
| Returns Kali/server information |
| Reports general system status |
| Reports disk/storage information |
| Reports memory information |
| Reports network status |
| Lists network interface information |
| Reads permitted text-file content |
read_text_file restrictions
read_text_file is deliberately restricted:
Files must remain within the project workspace.
Absolute paths are rejected.
Path traversal is rejected.
Symlink escapes outside the permitted workspace are rejected.
Maximum readable file size is 1 MiB.
New capabilities should be added as dedicated tools. Do not add generic command execution.
Security Model
Authentication and authorization
OAuth 2.0 Authorization Code flow
Refresh Token flow
Public-client registration
PKCE with S256
Single supported MCP scope:
mcp:readResource validation
Short-lived authorization requests and authorization codes
Authorization codes are single-use
Refresh tokens are stored hashed
Token revocation is enabled
Dynamic registration is limited to the supported scope
PKCE
PKCE protects the authorization-code exchange for the public-client model used by this project.
The integration test verifies the S256 flow, including rejection of an incorrect code verifier.
Token lifetimes
Item | Default |
Authorization request | 300 s |
Authorization code | 300 s |
Access token | 900 s (15 min) |
Refresh token | 2,592,000 s (30 days) |
Transport security
HTTPS only
Minimum TLS 1.2
Restricted ECDSA cipher suites
DNS rebinding protection
Explicit host allowlisting
ECDSA P-256 certificates
Certificate SAN validation
Certificate/private-key matching checks
Rate limiting
Rate limiting is applied to:
/register
/authorize
/token
/revoke
/mcpDefault:
10 requests / 60 secondsBoth values are configurable.
Audit logging
Audit records are written to:
logs/audit.logRecords include:
Timestamp
Tool name
Sanitized arguments
Execution status
Result or error information
Sensitive keys are recursively redacted, including:
api_key
authorization
client_secret
password
refresh_token
secret
tokenThe sanitizer handles nested dictionaries and sequences without modifying the original input.
Threat Model and Limitations
This project reduces the blast radius of giving an AI client access to a Kali host. It does not make the host safe to expose to the public internet.
Designed to protect against
Arbitrary command execution through the MCP interface
Unauthenticated access to protected tools
Authorization-code interception risks addressed by PKCE
DNS rebinding against the local server
Brute-force and flooding of protected endpoints through rate limiting
Sensitive values leaking into audit logs
Not covered / known limitations
Intended for use on a trusted local network
Public internet exposure is not a supported deployment scenario
The project has not been independently audited
Dynamic client registration is available to clients that can reach the server; authorization still requires the configured consent flow
The default certificate is self-signed
Anything an authorized read-oriented tool can return can be viewed by the authorized client
The rate limiter is process-local and does not provide distributed/shared rate-limit state
Review every tool before adding it to the allowlist.
Configuration Reference
Configuration is controlled through environment variables defined in config.py.
Variable | Default | Description |
|
| Bind address |
|
| Listening port |
|
| Address clients use; change for your network |
|
| OAuth issuer URL |
|
| Protected resource URL |
|
| JWT signing algorithm |
|
| JWT public key |
|
| JWT private key |
|
| SQLite OAuth database |
|
| TLS certificate |
|
| TLS private key |
|
| Authorization request lifetime |
|
| Authorization code lifetime |
|
| Access token lifetime |
|
| Refresh token lifetime |
|
| Requests allowed per window |
|
| Rate-limit window |
Keep private keys, OAuth state, and audit logs out of version control.
Quick Start
Prerequisites
Kali Linux or another Linux host with Python 3 and
opensslA non-root user
A client that supports MCP over Streamable HTTP with OAuth
1. Install
git clone https://github.com/Zer-security/secure-mcp-server.git
cd secure-mcp-server
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
mkdir -p logs data secrets/tls2. Generate JWT signing keys
openssl genpkey -algorithm ED25519 -out secrets/jwt-ed25519-private.pem
openssl pkey -in secrets/jwt-ed25519-private.pem -pubout -out secrets/jwt-ed25519-public.pem
chmod 600 secrets/jwt-ed25519-private.pem3. Generate the TLS certificate
PYTHONPATH=. python scripts/generate_tls.pyThe generated certificate uses ECDSA P-256. Certificate handling includes certificate/key compatibility checks, SAN validation, backup, and rollback on promotion failure.
The default certificate is self-signed, so an MCP client must be configured to trust it.
4. Configure
Set the server's LAN address:
export MCP_PUBLIC_HOST=192.168.x.x
export MCP_PORT=8000The server uses explicit host validation based on the configured public host and port.
5. Run
PYTHONPATH=. python server.pyThe MCP endpoint is:
https://<MCP_PUBLIC_HOST>:8000/mcpThe server refuses to run as root.
6. Connect a client
Point an MCP-compatible client at the MCP endpoint.
The authorization flow uses dynamic public-client registration, an interactive consent step, OAuth 2.0 Authorization Code flow, and PKCE S256.
Testing
The release v1.0.0 was verified with:
124 passedHistorical full-suite command used for v1.0.0:
PYTHONPATH=. ./venv/bin/pytest -qCurrent CI command:
PYTHONPATH=. pytest -q --ignore=tests/test_integration.pyCurrent CI verification: 123 passed.
The suite covers:
OAuth provider and integration flow
Authentication
Transport security
TLS
Rate limiting
SSRF/network security
Input validation
File tools
MCP tools
Audit logging and sanitization
Configuration
The release commit is:
f642badaa27315e6b446e1b4370cf113fdc652e1Project Structure
secure-mcp-server/
├── core/
│ ├── audit_extension.py
│ ├── audit_sanitizer.py
│ ├── oauth_provider.py
│ ├── oauth_routes.py
│ ├── rate_limit.py
│ ├── security.py
│ ├── ssrf.py
│ └── validation.py
├── scripts/
│ └── generate_tls.py
├── tools/
│ ├── file_tools.py
│ ├── info_tools.py
│ ├── network_tools.py
│ └── system_tools.py
├── tests/
├── config.py
├── server.py
├── test_client.py
├── requirements.txt
├── LICENSE
└── README.mdDevelopment Principles
Least privilege and explicit allowlisting
Secure defaults
No generic shell or command execution
No hardcoded secrets
Input validation
Authentication before protected operations
Auditability
Fail-safe behavior
Reproducible testing
Evidence-based security claims
Workflow:
Implement
↓
Test
↓
Verify
↓
DocumentA feature should not be described as secure merely because it exists in source code. The implementation and relevant tests should be verified first.
Roadmap
GitHub Actions CI with automated tests
Dependency/update automation
Additional read-only tools reviewed against the least-privilege model
Documented MCP client setup guides
Additional security hardening based on verified requirements
Responsible Use
Use this software only on systems you own or are explicitly authorized to administer or test.
The project is intended for controlled, authorized environments and should not be treated as a general-purpose remote administration interface.
Security Policy
If you discover a security vulnerability, avoid publishing sensitive details in a public issue.
Use the repository's GitHub Security Advisory mechanism for private vulnerability reporting.
License
Licensed under the Apache License 2.0.
This server cannot be deployed
Maintenance
Related MCP Connectors
Zero-trust gateway for AI agents: score tool calls, verify agent cards, enforce policy, audit.
OAuth 2.1 short-link tools for AI agents with scoped tokens, approvals, audit logs, and revocation.
Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.
Security gateway for AI agents: policy, approval, and audited execution, no secrets shared.
Related MCP Servers
- FlicenseAqualityDmaintenanceEnables AI assistants to perform authorized penetration testing and security assessments by exposing 20+ Kali Linux security tools (nmap, sqlmap, gobuster, hydra, etc.) through a safe, validated interface with command allowlists, rate limiting, and input sanitization.191-
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to safely execute OSINT and reconnaissance tools from Kali Linux through a typed job API with bearer authentication, job validation, and allowlisted Docker execution.Apache 2.0
- FlicenseBqualityBmaintenanceEnables AI assistants to perform penetration testing by running real Kali Linux security tools and returning structured, verified findings instead of raw terminal output.100-
- AlicenseNot gradedqualityBmaintenanceEnables LLMs and AI agents to perform defensive security posture assessments, privilege escalation surface audits, and post-quantum cryptography readiness checks through read-only diagnostic tools.MIT