mcp-server-security
Protects AI connections. Ensures only authorized users access and data is secure.
What it does
This guide teaches how to secure servers that connect AIs to other tools and data. It helps prevent hackers from accessing or manipulating these servers.
When to use it
- ✓When connecting an AI to important systems.
- ✓When data security is crucial.
- ✓To prevent unauthorized access.
Example of what to ask your AI
“How can I protect my AI server from hackers?”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
How it works
The guide explains how to use encryption to protect communication, verify who can use tools, and log all actions for auditing.
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add sickn33/agentic-awesome-skills --skill mcp-server-securityOr download just the file:
curl -L https://raw.githubusercontent.com/sickn33/agentic-awesome-skills/main/plugins/agentic-awesome-skills-claude/skills/mcp-server-security/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from GitHub.
MCP Server Security
Comprehensive hardening guide for Model Context Protocol (MCP) servers. MCP is the open standard for connecting AI agents to external tools, data sources, and services. Because MCP servers execute real actions on real infrastructure, they are a high-value attack surface. This skill covers every layer of defense you need before exposing an MCP server to agents in production.
2. MCP Threat Model
Before hardening, understand what you are defending against.
| Threat | Vector | Impact |
|---|---|---|
| Unauthorized tool access | Agent calls tools the user should not have access to | Privilege escalation, data breach |
| Prompt injection via resources | Malicious content in MCP resources influences agent behavior | Arbitrary tool execution |
| Data exfiltration via results | Tool results leak sensitive data back to an untrusted agent | Data loss, compliance violation |
| SSRF via MCP tools | Agent tricks a tool into making internal network requests | Internal service compromise |
| Credential theft | API keys or tokens stored insecurely on the MCP server | Full account takeover |
| Denial of service | Agent floods server with tool calls or huge payloads | Service unavailability |
| Man-in-the-middle | Unencrypted transport between agent and MCP server | Eavesdropping, request tampering |
| Supply chain compromise | Malicious MCP server package or plugin | Arbitrary code execution |
3. Transport Security
3.1 TLS for Streamable HTTP and SSE Transports
Every MCP server exposed over HTTP must terminate TLS. Never run plain HTTP in production.
Nginx reverse proxy with TLS termination for an MCP server:
# /etc/nginx/sites-enabled/mcp-server.conf
server {
listen 443 ssl http2;
server_name mcp.internal.example.com;
ssl_certificate /etc/ssl/certs/mcp-server.crt;
ssl_certificate_key /etc/ssl/private/mcp-server.key;
ssl_protocols TLSv1.3;
ssl_ciphers TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256;
ssl_prefer_server_ciphers on;
ssl_session_timeout 1d;
ssl_session_tickets off;
# HSTS header
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" always;
location / {
proxy_pass http://127.0.0.1:3001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
# SSE-specific: disable buffering so events stream immediately
proxy_buffering off;
proxy_cache off;
proxy_read_timeout 86400s;
}
}
3.2 mTLS Between Agent and Server
For high-security environments, require the agent (client) to present a certificate.
# Add to the server block above
ssl_client_certificate /etc/ssl/certs/agent-ca.crt;
ssl_verify_client on;
ssl_verify_depth 2;
Generate a client certificate for an agent:
# Create CA (one-time)
openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 \
-days 365 -noenc -keyout ca-key.pem -out ca-cert.pem \
-subj "/CN=MCP Agent CA"
# Create agent client cert signed by the CA
openssl req -newkey ec -pkeyopt ec_paramgen_curve:P-256 \
-noenc -keyout agent-key.pem -out agent-csr.pem \
-subj "/CN=agent-orchestrator-01"
openssl x509 -req -in agent-csr.pem -CA ca-cert.pem -CAkey ca-key.pem \
-CAcreateserial -out agent-cert.pem -days 90
3.3 Securing stdio Transport
For local stdio-based servers, the attack surface is the process boundary itself:
Use an already reviewed, version-pinned local server entrypoint and a separately enforced sandbox. Do not launch a moving npx -y package or describe Node flags as a complete host-permission boundary. The server needs runtime/module access in addition to its data root; network, process creation, links and writes need explicit platform controls. A configuration example is not permission to create or replace a user's host entry.
…
FAQ
What is MCP?
MCP is a standard for securely connecting AIs to external tools and data.
Why is MCP server security important?
MCP servers can perform real actions on systems, making them valuable targets for attacks.
What are TLS and mTLS?
TLS encrypts communication between the agent and the server. mTLS requires the agent to also present a security certificate.
Details
Original description by the author
Secure Model Context Protocol (MCP) servers with transport encryption, tool authorization, input validation, and audit logging for safe AI agent integrations.
Popularity
- GitHub stars
- 48k
- Ranking position
- #3573
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
00-andruia-consultant
Helps your agent start or improve AI projects. It analyzes code, suggests tools, and creates action plans in Spanish.
sickn33/agentic-awesome-skills
007
Lets your agent perform security audits and threat modeling. It's useful for protecting projects against attacks and vulnerabilities.
sickn33/agentic-awesome-skills
10-andruia-skill-smith
Helps your agent create or improve AI tools. It defines how tools work, writes documentation, and validates the structure.
sickn33/agentic-awesome-skills
20-andruia-niche-intelligence
Lets your agent create a summary about a specific industry. It's useful for understanding the context, rules, usage patterns, and risks of a project, using reliable sources.
sickn33/agentic-awesome-skills
Similar skills
speech
Helps your agent turn text into spoken audio. It's useful for creating narration, lecture audio, or quick voiceovers.
nexu-io/open-design
Docker Hub Automation
Makes your agent automate operations on Docker Hub. It manages repositories, teams, and webhooks for your containers.
ComposioHQ/awesome-claude-skills
New Relic Automation
Helps your agent automate tasks in New Relic. It can manage alerts, monitor applications, and set up notifications.
ComposioHQ/awesome-claude-skills