npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mcp-local-file-reader

v0.1.0

Published

A Model Context Protocol server for reading local files

Downloads

60

Readme

MCP Local File Reader

一个基于 Model Context Protocol (MCP) 的本地文件读取服务器,允许 AI 模型安全地访问本地文件系统。

功能特点

资源 (Resources)

  • 列出和访问本地文件系统中的文件
  • 支持多种文件类型,包括文本文件和二进制文件
  • 自动检测文件 MIME 类型,提供适当的内容处理

工具 (Tools)

  • read_file - 读取指定文件的内容
    • 对文本文件返回完整内容
    • 对二进制文件返回文件信息摘要
  • list_files - 列出指定目录中的所有文件
    • 返回文件名列表
  • get_file_info - 获取指定文件的详细信息
    • 返回文件大小、类型、创建时间等元数据

安装

npm install mcp-local-file-reader

使用方法

作为命令行工具

安装后,可以直接在命令行中运行:

npx mcp-local-file-reader

在代码中使用

import { spawn } from 'child_process';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

// 启动 MCP 服务器
const mcpServer = spawn('node', [join(__dirname, 'node_modules/mcp-local-file-reader/build/index.js')], {
  stdio: ['pipe', 'pipe', 'pipe']
});

// 与服务器通信
mcpServer.stdout.on('data', (data) => {
  console.log(`MCP 服务器输出: ${data}`);
});

mcpServer.stderr.on('data', (data) => {
  console.error(`MCP 服务器错误: ${data}`);
});

与 AI 工具集成

在 Windsurf 中使用

  1. 在 Windsurf 的 MCP 配置文件中添加以下配置:
{
  "servers": [
    {
      "name": "file-tools",
      "command": "npx mcp-local-file-reader",
      "tools": [
        {
          "name": "read_file",
          "description": "读取指定文件内容"
        },
        {
          "name": "list_files",
          "description": "列出指定目录中的所有文件"
        },
        {
          "name": "get_file_info",
          "description": "获取指定文件的详细信息"
        }
      ]
    }
  ]
}
  1. 重启 Windsurf 以加载新的 MCP 配置

在其他 MCP 兼容的 AI 应用中使用

按照特定应用的 MCP 集成指南,添加此服务器作为工具提供者。

开发

安装依赖:

npm install

构建服务器:

npm run build

开发模式(自动重新构建):

npm run watch

使用 MCP Inspector 测试:

npm run inspector

安全注意事项

此服务器允许 AI 模型访问本地文件系统,请谨慎使用并确保:

  1. 只允许访问必要的目录
  2. 不要暴露敏感文件或目录
  3. 在生产环境中使用前,考虑添加额外的安全限制

许可证

MIT