Skip to main content
Glama
secheaders-mcp

secheaders-mcp

by hellonimen

secheaders-mcp

An MCP (Model Context Protocol) server that lets an AI assistant check a website's HTTP security headers. Ask it something like "How secure are the headers on example.com?" and the assistant calls this server, gets back a grade from A to F, and explains which headers are missing and how to fix them.

I built it to learn MCP hands-on, combining it with my background in web application security.

Tools

Tool

What it does

Network?

check_url(url)

Fetches a public http(s) URL with one GET and grades its security headers

Yes, a single passive request

analyze_raw_headers(raw_headers)

Grades headers you paste as text (Name: value per line)

No

explain_header(header)

Explains what a header protects against and gives a safe example value

No

What it checks: HSTS, Content-Security-Policy, X-Frame-Options, X-Content-Type-Options, Referrer-Policy and Permissions-Policy. It also flags version leaks (Server, X-Powered-By), an HSTS max-age under 180 days, and a CSP that allows unsafe-inline or unsafe-eval.

Related MCP server: web-security-guard

Security design

Giving an AI agent a tool that fetches URLs is risky. A prompt-injection attack could trick the agent into calling the tool against http://127.0.0.1/admin or the cloud metadata endpoint 169.254.169.254. This is SSRF (server-side request forgery). To prevent it, check_url:

  • only accepts http:// and https:// URLs, so file://, ftp:// and gopher:// are rejected

  • resolves the hostname first and refuses private, loopback, link-local and reserved IPs

  • sends one passive GET with a 10-second timeout, so it does no scanning or fuzzing

These rules are covered by tests.

Quick start

git clone https://github.com/hellonimen/secheaders-mcp.git
cd secheaders-mcp
python -m venv .venv && source .venv/bin/activate   # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
pytest -v            # 17 tests

Use it with Claude Desktop (or any MCP client)

Add this to claude_desktop_config.json, then restart Claude Desktop:

{
  "mcpServers": {
    "secheaders": {
      "command": "python",
      "args": ["-m", "secheaders_mcp.server"]
    }
  }
}

If you installed it in a virtual environment, use the full path to that environment's python.

Try it with the MCP Inspector

mcp dev src/secheaders_mcp/server.py

How it's built

src/secheaders_mcp/
  checks.py   # pure logic: grading + SSRF guard (no MCP code, easy to unit test)
  server.py   # MCP layer: 3 tools registered with @mcp.tool(), stdio transport
tests/
  test_checks.py  # unit tests for grading and SSRF blocking
  test_server.py  # end-to-end: a real MCP client lists and calls the tools in-process
  • Built on the official MCP Python SDK (MCPServer, v2).

  • The business logic is kept separate from the MCP layer, so the same checks could be reused in a CLI or a CI job.

  • GitHub Actions runs the test suite on Python 3.11 and 3.12 for every push.

Scoring

The score is the percentage of the 6 recommended headers present, minus 5 points for each version leak and each weak setting. Grades: A ≥ 90, B ≥ 75, C ≥ 50, D ≥ 25, otherwise F.

Ideas for next steps

  • A TLS certificate tool (expiry date, protocol version)

  • Cookie flag checks (Secure, HttpOnly, SameSite)

  • A Streamable HTTP transport, so a team can share one server

Disclaimer

Only scan sites you own or have permission to test. check_url makes one ordinary request, the same as a browser visit.

License

MIT

Available Tools

3 tools
analyze_raw_headersA

Grade HTTP response headers pasted as text, one 'Name: value' per line. No network used.

Inputs: raw_headers (required).

check_urlA

Fetch a public http(s) URL and grade its security headers (A-F) with fixes.

Passive only: sends one GET request, the same as a browser visiting the page.

Inputs: url (required).

explain_headerC

Explain what a security header protects against and give a safe example value.

Inputs: header (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 3 tools

    Disambiguation5/5

    Although check_url and analyze_raw_headers both grade security headers, their boundary is explicit: one fetches a live URL while the other processes pasted header text. explain_header is clearly educational and separate from grading.

    Naming Consistency5/5

    All three tool names use a consistent snake_case verb_noun pattern: check_url, analyze_raw_headers, explain_header. The naming is predictable and easy to infer.

    Tool Count5/5

    Three tools are well-scoped for a security-header grading service: live scan, offline scan, and header explanation. Each tool covers a distinct workflow with no filler.

    Completeness4/5

    The surface covers the core tasks of grading a live URL, grading pasted headers, and explaining individual headers. Minor gaps exist, such as no consolidated reference/list of supported headers or explicit remediation output for analyze_raw_headers, but these are workable.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables Claude to scan a website's HTTP security headers and receive an A–F grade against OWASP best practices, including per-header pass/warn/fail results and copy-paste fixes for missing headers.
      1
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to audit URLs for security headers, generate CSP Level 3 policies, compute SRI hashes, evaluate WCAG 2.2 contrast, and remediate headers.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI assistants to scan any website's HTTP security headers — HSTS, CSP, framing, COOP/CORP, and cookies — returning a score along with fix snippets.
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Enables AI agents and developers to audit any URL or domain for seven critical OWASP HTTP security headers, returning an A+ to F grade plus actionable Nginx, Apache, Caddy, and Cloudflare remediation snippets. It also probes /.well-known/security.txt and /security.txt to surface responsible vulnerability disclosure contacts, bug bounty scopes, and PGP keys.
      2
      MIT