Skip to content
gentic.news — AI News Intelligence Platform
Connecting to the Living Graph…

Listen to today's AI briefing

Daily podcast — 5 min, AI-narrated summary of top stories

Developer typing code on a laptop with a terminal showing file system commands and server startup logs
Open SourceScore: 76

Build a Zero-Dependency MCP Server

Build a zero-dependency MCP server in 50 lines of Python to give Claude Code direct file access. Register it in claude.json and skip SDK bloat.

·1d ago·4 min read··19 views·AI-Generated·Report error
Share:
Source: news.google.comvia gn_mcp_protocolMulti-Source
How do I build a zero-dependency MCP server so Claude Code can read and write files on my machine?

Yes. Write a ~50-line Python MCP server using the stdlib's `json` and `subprocess` modules to expose `read_file` and `write_file` tools. Register it in `claude.json` and Claude Code can edit files without a heavy SDK.

TL;DR

You can build a lightweight MCP server from scratch with zero dependencies to give Claude Code read/write access to any file on your system.

The Problem: Claude Code Can't See Your Files

Claude Code is powerful, but it has a blind spot: it can't directly read or write arbitrary files on your system unless you explicitly pass them in the conversation or use its built-in file tools. For developers working with large codebases, configuration files, or data files scattered across directories, this creates friction.

You could install a heavy MCP SDK or use an existing file server, but sometimes you just want something lightweight, auditable, and dependency-free.

What Changed — The Zero-Dependency Approach

A developer recently published a walkthrough of building a Model Context Protocol (MCP) server using only Python's standard library — no pip install, no SDKs, no frameworks. The result: a ~50-line server that exposes read_file and write_file tools to any MCP-compatible client, including Claude Code.

The Model Context Protocol (MCP), introduced by Anthropic in November 2024, standardizes how AI models connect to external tools and data. This server implements the JSON-RPC-based protocol directly over stdin/stdout, which is exactly how Claude Code communicates with MCP servers.

What It Means For You

If you've ever been frustrated that Claude Code can't access a config file in /etc/ or a data file in /data/, this is your solution. You get:

  • No dependencies — runs on any Python 3.6+ installation
  • Full control — you write exactly what tools to expose
  • Security — you control the file paths and permissions
  • Zero bloat — no SDK updates or version conflicts

This is particularly useful for CI/CD pipelines, Docker containers, or any environment where you can't or won't install extra packages.

Try It Now — Build Your Own File Server

Step 1: The Server Code

Create a file called file_server.py:

#!/usr/bin/env python3
"""Zero-dependency MCP server for file read/write."""
import json
import sys
import os

def read_file(path):
    with open(path, 'r') as f:
        return f.read()

def write_file(path, content):
    os.makedirs(os.path.dirname(path), exist_ok=True)
    with open(path, 'w') as f:
        f.write(content)
    return "ok"

def handle_request(request):
    method = request.get("method")
    params = request.get("params", {})
    if method == "list_tools":
        return {
            "tools": [{
                "name": "read_file",
                "description": "Read a file from the filesystem",
                "inputSchema": {
                    "type": "object",
                    "properties": {
                        "path": {"type": "string"}
                    },
                    "required": ["path"]
                }
            }, {
                "name": "write_file",
                "description": "Write content to a file",
                "inputSchema": {
                    "type": "object",
                    "properties": {
                        "path": {"type": "string"},
                        "content": {"type": "string"}
                    },
                    "required": ["path", "content"]
                }
            }]
        }
    elif method == "call_tool":
        name = params["name"]
        args = params["arguments"]
        if name == "read_file":
            result = read_file(args["path"])
        elif name == "write_file":
            result = write_file(args["path"], args["content"])
        else:
            return {"error": f"Unknown tool: {name}"}
        return {"content": [{"type": "text", "text": str(result)}]}
    return {"error": f"Unknown method: {method}"}

def main():
    for line in sys.stdin:
        request = json.loads(line)
        response = handle_request(request)
        sys.stdout.write(json.dumps(response) + "\n")
        sys.stdout.flush()

if __name__ == "__main__":
    main()

Step 2: Register with Claude Code

Add this server to your claude.json configuration:

{
  "mcpServers": {
    "file-access": {
      "command": "python3",
      "args": ["/path/to/file_server.py"]
    }
  }
}

Step 3: Use It

Restart Claude Code. Now you can ask it to read or write files directly:

"Read /etc/hosts and tell me what entries exist"
"Write a new config file at /data/config.json with these settings..."

Claude Code will call your MCP server's tools automatically.

Why This Matters for Claude Code Users

The MCP ecosystem is growing fast — Anthropic's protocol is now used by Claude Code, GitHub Copilot, and others. But you don't need to wait for someone else to build the server you need. With ~50 lines of Python, you can create custom tools that give Claude Code exactly the capabilities your workflow demands.

This approach scales: add tools for database queries, API calls, or even custom business logic. Each tool is just a function registered in the list_tools response.

Security Note

This server has no path sanitization. In production, add checks to restrict access to specific directories or file types. For example:

def read_file(path):
    allowed_prefix = "/home/user/projects/"
    if not path.startswith(allowed_prefix):
        raise PermissionError(f"Access denied: {path}")
    with open(path, 'r') as f:
        return f.read()

The Takeaway

You don't need a heavy SDK to extend Claude Code. The Model Context Protocol is simple enough to implement from scratch. Build exactly the tools you need, with zero dependencies, and keep your workflow lean.


Source: news.google.com

Source: gentic.news · · author= · citation.json

AI-assisted reporting. Generated by gentic.news from multiple verified sources, fact-checked against the Living Graph of 4,300+ entities. Edited by Ala SMITH.

Following this story?

Get a weekly digest with AI predictions, trends, and analysis — free.

AI Analysis

Claude Code users should immediately adopt this pattern for any custom tooling they need. Instead of searching for an existing MCP server or installing a full SDK, write a 50-line Python script that implements exactly the tools your project requires. This is especially valuable for: 1. **File operations** — as shown here, direct read/write access without passing files manually 2. **Database queries** — wrap sqlite3 or psycopg2 with a simple `query_database` tool 3. **API wrappers** — call internal APIs without exposing credentials in the conversation The key workflow change: keep a `mcp_servers/` directory in your project with custom servers. Register them in `claude.json`. Now Claude Code has exactly the capabilities your codebase needs, without bloat. Test by asking Claude Code to list the available tools with `/tools` after restarting.
This story is part of
The AI Infrastructure War Shifts from Chips to Developer Tools
Nvidia's enterprise pivot and AWS's OpenAI bet collide with Cursor's quiet ascent
Compare side-by-side
Model Context Protocol vs Python
Enjoyed this article?
Share:

AI Toolslive

Five one-click lenses on this article. Cached for 24h.

Pick a tool above to generate an instant lens on this article.

Related Articles

From the lab

The framework underneath this story

Every article on this site sits on top of one engine and one framework — both built by the lab.

More in Open Source

View all