跳到正文
Skillpedia
连接器(MCP)48k · #5187

mcp-server-security

它能做什么

这份指南讲解如何保护那些把 AI 连接到其他工具和数据的服务器,帮助防止黑客访问或篡改这些服务器。

适用场景

  • ✓当你要把 AI 连接到重要系统时。
  • ✓当数据安全至关重要时。
  • ✓为了防止未经授权的访问。

技能链接

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/mcp-server-security/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/mcp-server-security/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我该如何保护我的 AI 服务器不受黑客攻击?”

每周 5 个新技能,1 分钟读完。

工作原理

指南会介绍如何使用加密来保护通信,如何验证谁可以使用工具,以及如何记录所有操作以便审计。

技术内容(原始 SKILL.md)

作者在 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.

…

常见问题

什么是 MCP?

MCP 是一种标准,用于安全地把 AI 连接到外部工具和数据。

为什么 MCP 服务器的安全很重要?

MCP 服务器可以在系统上执行真实的操作,因此很容易成为攻击目标。

什么是 TLS 和 mTLS?

TLS 对代理与服务器之间的通信进行加密。mTLS 则要求代理同时出示安全证书。

详情

作者的原始描述

Secure Model Context Protocol (MCP) servers with transport encryption, tool authorization, input validation, and audit logging for safe AI agent integrations.

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#5187
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能