ab_mcp

ab_mcp

A file system MCP server that confines AI assistant file tools to a single folder, with read-only by default and optional write access.

Category
访问服务器

README

ab_mcp — give an AI a folder, not your whole disk

I kept wanting to let Claude help with a project folder — "what's in here?", "find every TODO", "read me that config" — without giving it the keys to my entire filesystem. So I wrote this.

It's a tiny Model Context Protocol server: it hands an AI assistant a handful of file tools, all locked to one folder you choose. Reading is on by default; writing is off until you say otherwise. The whole thing is a single, readable server.py — so before you trust it, you can actually read it.

Why you might want this: "AI can read my files" and "AI can rewrite my files" are very different levels of trust. This server lets you start with the first and opt into the second only when you mean to.

What it can do

Tool What it does
list_files(subdir=".") List files/folders under the root
read_file(path) Read a text file (size-capped)
read_lines(path, start=1, end=0) Read a line range — for files too big to read whole
search_files(query, subdir=".", max_results=0) Case-insensitive text search across files
find_files(pattern="*", subdir=".") Find files by name/glob, e.g. *.py
file_stats(path=".") Line/word/char counts, or directory size
write_file(path, content) Create/overwrite a file — disabled unless AB_MCP_ALLOW_WRITE is set

Every path is confined to the root directory — requests that try to escape it (../../etc/passwd) are rejected.

Setup

cd ab_mcp
python -m venv .venv
source .venv/Scripts/activate      # Windows Git Bash
# .venv\Scripts\activate           # Windows PowerShell/cmd
pip install -r requirements.txt

Try it standalone (dev inspector)

mcp dev server.py

This opens the MCP Inspector in your browser so you can click each tool and see output.

Run it directly

python server.py

The server speaks stdio — it waits for an MCP client to connect. That's normal; it won't print anything on its own.

Configuration

Everything is controlled with environment variables — no code edits needed:

Variable Default Purpose
AB_MCP_NAME ab_mcp Server name advertised to MCP clients
AB_MCP_ROOT this project folder The single folder all tools are confined to
AB_MCP_MAX_BYTES 200000 Max file size (bytes) that read_file will read whole
AB_MCP_MAX_RESULTS 50 Default number of search hits before stopping
AB_MCP_LINE_PREVIEW 200 Characters of each matching line shown in search results
AB_MCP_ENCODING utf-8 Text encoding used to read files
AB_MCP_ALLOW_WRITE (off) Set to 1/true/yes to enable the write_file tool
AB_MCP_IGNORE .venv,venv,__pycache__,.git,node_modules,.idea Comma-separated folders to skip

Example — point it at any folder, allow larger files, ignore a dist dir:

AB_MCP_ROOT="/path/to/your/folder" \
AB_MCP_MAX_BYTES=500000 \
AB_MCP_IGNORE=".git,dist,build" \
python server.py

Connect it to Claude Desktop

Edit claude_desktop_config.json (%APPDATA%\Claude\claude_desktop_config.json on Windows) and add:

Replace the paths with the absolute path to your own clone:

{
  "mcpServers": {
    "ab_mcp": {
      "command": "C:\\path\\to\\ab_mcp\\.venv\\Scripts\\python.exe",
      "args": ["C:\\path\\to\\ab_mcp\\server.py"],
      "env": {
        "AB_MCP_ROOT": "C:\\path\\to\\the\\folder\\to\\expose"
      }
    }
  }
}

Restart Claude Desktop. You'll see the ab_mcp tools available in the chat.

Connect it to Claude Code

claude mcp add ab_mcp -- /path/to/ab_mcp/.venv/Scripts/python.exe /path/to/ab_mcp/server.py

License

MIT — see the LICENSE file. Add your name to the copyright line before publishing.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选