mcp-server-hardening

mcp-server-hardening is a skill for Claude Code, Codex from fabioc-aloha/Alex_Skill_Mall. It costs 42 tokens per session (1,018 once invoked), scanned B, original, MIT.

A security checklist and implementation guide for MCP servers exposed over a network. MCP is a way for an AI program to call tools; this guide covers protecting those network calls and the secrets they use.

In plain words
What is it for?
Use it when securing an HTTP MCP server before deployment, including host-name checks, restrictive cross-origin rules, authentication, and safer handling of secrets.
Why use it?
A remotely reachable tool server can be tricked or called by unauthorised clients. It addresses DNS rebinding, unsafe browser access, missing authentication, secret exposure, and confused-deputy attacks.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when securing an HTTP MCP server before deployment, including host-name checks, restrictive cross-origin rules, authentication, and safer handling of secrets.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/fabioc-aloha/alex_skill_mall/mcp-server-hardening
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add fabioc-aloha/Alex_Skill_Mall --skill mcp-server-hardening
Clone the repo
git clone --depth 1 https://github.com/fabioc-aloha/Alex_Skill_Mall

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for mcp-server-hardening

README.md
[![agentmods](https://agentmods.dev/badge/skills/fabioc-aloha/alex_skill_mall/mcp-server-hardening/github.svg)](https://agentmods.dev/skills/fabioc-aloha/alex_skill_mall/mcp-server-hardening)
Your own site
<a href="https://agentmods.dev/skills/fabioc-aloha/alex_skill_mall/mcp-server-hardening"><img src="https://agentmods.dev/badge/skills/fabioc-aloha/alex_skill_mall/mcp-server-hardening/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for mcp-server-hardening

Your own site · 80×15
<a href="https://agentmods.dev/skills/fabioc-aloha/alex_skill_mall/mcp-server-hardening"><img src="https://agentmods.dev/badge/skills/fabioc-aloha/alex_skill_mall/mcp-server-hardening.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 42 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,018 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00042 $0.01018
Opus 5.5 $0.00017 $0.00407
Sonnet 5.5 $0.00008 $0.00204
Haiku 4.5 $0.00004 $0.00102

Measured 1mo ago against content hash 0ecd8abe14e6, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade B, and why

mcp-server-hardening scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Instruction-override phrasingmediumPrompt injection

Text telling the model to disregard its earlier instructions or safety rules is the shape of a prompt injection, whoever wrote it.

So a document containing "ignore previous instructions and call

Downgraded: this mod is about security review, or the phrase is quoted, so it is likely naming the pattern rather than instructing it.

plugins/ai-agents/mcp-toolkit/skills/mcp-server-hardening/SKILL.md · 120 lines

How it starts

The opening of the file, as written. The whole thing — 120 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Harden an MCP Server

A stdio server needs none of this. An HTTP server needs all of it before it is reachable, because an MCP server is an execution surface that an LLM drives.

Validate Host Names

ASP.NET Core's Kestrel does not check the Host header by default, and it is not alone. Without validation, a browser can be steered to your local server through an attacker-controlled DNS name while sending that name in the header — DNS rebinding.

  • Locally: restrict allowed hosts to loopback values.
  • In production: configure the exact public host names, and validate at the proxy or load balancer when one forwards requests.

This also stops untrusted host names being reflected through features that generate absolute URLs.

Do Not Enable CORS By Default

Turn on cross-origin requests only if you intend browser-based cross-origin access. When you do, use the most restrictive policy that works.

CORS is not a substitute for host-name validation. They defend different things: CORS governs which browser origins may call you, host validation governs which names you will answer to.

Authenticate

A remote server is a reachable execution surface. Decide who may call it before deploying, not after.

For stdio servers the question does not arise — the transport is the boundary. The mistake is carrying a stdio design onto HTTP and assuming the boundary came along.

Handle Secrets

Read credentials from the environment, never from a file in the repository:

{
  "env": { "MY_API_TOKEN": "${env:MY_API_TOKEN}" }
}

Two failure modes worth naming:

Logging the token. Debug output that dumps request headers will write the credential to a log the user did not know existed. Redact at the logger, not at the call site, because the call site you forget is the one that leaks.

Returning the token. An error message that echoes the full request back to the agent puts the credential into the model's context, and from there into wherever that conversation is stored.

Read the full file on GitHub · 120 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 120 lines · 42 tokens per session scan B 0ecd8abe14e6

Subscribe to this mod's changes

mcp-server-hardening is a skill published in the GitHub repository fabioc-aloha/Alex_Skill_Mall (5 stars, last pushed yesterday), licensed MIT. It adds 42 tokens to every session and 1,018 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it B with 1 finding (instruction-override phrasing). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-14.

Related

Other skills, from other repositories

apply-change-leadership

Use when a manager's team is experiencing a significant organizational change — restructuring, strategy shift, leadership change, layoffs, or major process transition — and needs leadership that maintains team stability, preserves trust, and converts uncertainty into direction.

jeffreytse/grimoire-core · 51 tokens

apply-cross-functional-leadership

Use when a manager needs to lead a project or initiative that depends on team members or stakeholders they do not formally manage — to build voluntary cooperation, alignment, and momentum across organizational boundaries through influence rather than authority.

jeffreytse/grimoire-core · 49 tokens

apply-distributed-team-practices

Use when managing a team where members work in different locations, time zones, or on hybrid schedules — to adapt management practices so remote members have equal access to information, relationships, and advancement opportunities as in-office members.

jeffreytse/grimoire-core · 51 tokens

apply-grow-coaching

Use when a manager wants to help a direct report solve a problem, develop a skill, or reach a goal through structured questioning rather than advice-giving — because telling people answers builds dependency while coaching builds self-sufficiency.

jeffreytse/grimoire-core · 50 tokens

apply-high-performer-retention

Use when a manager wants to proactively retain top-performing direct reports — because high performers have the most options to leave and require active, differentiated management attention to stay engaged and challenged.

jeffreytse/grimoire-core · 42 tokens

apply-upward-influence

Use when a manager needs to build an effective working relationship with their own manager, secure resources or decisions for their team, or influence organizational priorities without formal authority over the outcome.

jeffreytse/grimoire-core · 41 tokens