disk-space-mcp

disk-space-mcp

Enables checking and validating disk space usage via a single tool, reporting total, used, and available space with optional free space thresholds.

Category
Visit Server

README

disk-space-mcp

A small Model Context Protocol server that reports and validates free disk space. It exposes a single read-only tool, check_disk_space, backed by Node's fs.statfs — no shell-outs to df, no runtime dependencies beyond the MCP SDK and Zod.

Tool: check_disk_space

Reports total / used / available space for the filesystem that contains a path, and validates it against optional free-space thresholds.

Argument Type Default Description
path string home directory Any path; stats apply to the filesystem containing it.
minFreeGb number — If available space is below this many GiB, status becomes "warning".
minFreePercent number 10 If available space is below this percentage, status becomes "warning".

It returns both a human-readable text block and structuredContent:

{
  "path": "/Users/you",
  "totalBytes": 494384795648,
  "usedBytes": 312000000000,
  "freeBytes": 182000000000,
  "availableBytes": 175000000000,
  "usedPercent": 63.11,
  "availablePercent": 35.4,
  "status": "ok",
  "message": "OK: 163 GiB available of 460 GiB (35.4% free, 63.11% used) on /Users/you."
}

availableBytes (POSIX bavail) is the space actually usable by your user and is the value the thresholds check; freeBytes (bfree) additionally counts space reserved for root.

Develop

npm install
npm run build      # tsc -> dist/
npm test           # vitest: pure-logic unit tests + in-memory protocol tests
npm run typecheck  # tsc --noEmit
npm run smoke      # build first, then spawn the server and call the tool over stdio

Register with Claude Code

npm run build
claude mcp add disk-space --scope user -- node /ABSOLUTE/PATH/TO/disk-space-mcp/dist/index.js

Or add it manually to an MCP client config:

{
  "mcpServers": {
    "disk-space": {
      "command": "node",
      "args": ["/ABSOLUTE/PATH/TO/disk-space-mcp/dist/index.js"]
    }
  }
}

Design notes

  • Layered for testability. diskSpace.ts is a pure module (byte math, thresholds, formatting) with no I/O, unit-tested in isolation. getDiskStats.ts is the thin fs.statfs adapter, injected into createServer() so the protocol wiring can be tested end-to-end against an in-memory transport with fabricated stats.
  • stdio-safe. All diagnostics go to stderr; stdout carries only JSON-RPC.
  • Read-only and shell-free. The tool only reads filesystem capacity via statfs; it never reads file contents and never invokes a shell, so there is no command-injection surface. Paths are resolved to absolute and failures (missing path, permission denied) return a clean isError result.
  • Unit semantics. Byte counts use frsize when available (Node ≥ 24.16), falling back to bsize on older runtimes. Sizes are formatted with binary (IEC) units — KiB / MiB / GiB.

Security

  • Read-only, shell-free. The only side effect is fs.statfs. There is no child_process/exec/spawn anywhere, so there is no command-injection surface, and statfs exposes filesystem capacity only — never file contents.
  • Input is validated at the boundary. The path argument is length-capped and rejected if it contains control characters (NUL, ESC, CR, …), which both neutralizes statfs's silent null-byte truncation and prevents control/ANSI sequences from being reflected into tool output that a terminal or agent later renders. minFreeGb / minFreePercent are bounded and must be finite.
  • No information leak on error. Failures return a clean isError result with an errno code (e.g. ENOENT) rather than raw runtime internals; full error detail is logged to stderr only.
  • stdio-only. Only StdioServerTransport is instantiated. The MCP SDK transitively pulls in an HTTP/auth stack that this server never uses; since consumers only run the stdio binary, those code paths are never reached. For a hardened install, npm ci --ignore-scripts is safe (no runtime dependency needs an install script). CI gates production dependencies with npm audit --omit=dev --audit-level=high.

License

MIT — see LICENSE.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured