Skip to main content
Glama

Filesystem MCP Server

by bsmi021

文件系统 MCP 服务器

模型上下文协议 (MCP) 服务器实现通过标准化工具接口提供文件系统操作、分析和操控功能。

建筑学

该服务器基于 MCP SDK 构建,并分为不同的层:

graph TD A[MCP Server Layer] --> B[Tool Registry] B --> C[Operations Layer] C --> D[File System Operations] C --> E[Analysis Operations] C --> F[Stream Operations]

成分

  • 服务器层:处理MCP协议通信和工具调度

  • 工具注册表:管理工具注册和执行

  • 操作层:实现核心功能

  • 文件系统接口:提供安全的文件系统访问

安装

  1. 克隆存储库:

git clone <repository-url> cd filesystem-server
  1. 安装依赖项:

npm install
  1. 构建服务器:

npm run build
  1. 配置 MCP 设置(cline_mcp_settings.json):

{ "mcpServers": { "filesystem": { "command": "node", "args": ["path/to/filesystem-server/build/index.js"] } } }

工具参考

目录操作

列表目录

列出带有元数据的目录内容。

interface ListDirectoryParams { path: string; // Directory path recursive?: boolean; // List recursively (default: false) } interface ListDirectoryResult { entries: { name: string; path: string; isDirectory: boolean; size: number; created: string; modified: string; accessed: string; mode: string; }[]; }

创建目录

创建新目录。

interface CreateDirectoryParams { path: string; // Directory path recursive?: boolean; // Create parent directories (default: true) }

文件操作

读取文件

读取具有编码支持的文件内容。

interface ReadFileParams { path: string; // File path encoding?: string; // File encoding (default: 'utf8') }

写入文件

将内容写入文件。

interface WriteFileParams { path: string; // File path content: string; // Content to write encoding?: string; // File encoding (default: 'utf8') }

追加文件

将内容附加到文件。

interface AppendFileParams { path: string; // File path content: string; // Content to append encoding?: string; // File encoding (default: 'utf8') }

分析操作

分析文本

分析文本文件属性。

interface AnalyzeTextParams { path: string; // File path } interface AnalyzeTextResult { lineCount: number; wordCount: number; charCount: number; encoding: string; mimeType: string; }

计算哈希

使用指定的算法计算文件哈希值。

interface CalculateHashParams { path: string; // File path algorithm?: 'md5' | 'sha1' | 'sha256' | 'sha512'; // Hash algorithm } interface CalculateHashResult { hash: string; algorithm: string; }

查找重复项

识别目录中的重复文件。

interface FindDuplicatesParams { path: string; // Directory path } interface FindDuplicatesResult { duplicates: { hash: string; size: number; files: string[]; }[]; }

压缩操作

创建_zip

创建一个 ZIP 档案。

interface CreateZipParams { files: string[]; // Files to include output: string; // Output ZIP path }

提取压缩文件

提取 ZIP 档案。

interface ExtractZipParams { path: string; // ZIP file path output: string; // Output directory }

错误处理

服务器使用标准 MCP 错误代码:

enum ErrorCode { ParseError = -32700, InvalidRequest = -32600, MethodNotFound = -32601, InvalidParams = -32602, InternalError = -32603 }

错误响应包括:

  • 错误代码

  • 人类可读的消息

  • 附加上下文(如有)

错误示例:

{ "code": -32602, "message": "File not found: /path/to/file.txt" }

发展

项目结构

src/ ├── operations/ # Core operations implementation ├── tools/ # MCP tool definitions and handlers ├── __tests__/ # Test suites ├── index.ts # Entry point ├── server.ts # MCP server setup ├── types.ts # Type definitions └── utils.ts # Utility functions

运行测试

运行测试套件:

npm test

覆盖运行:

npm run test:coverage

开发模式

以监视模式运行:

npm run watch

代码质量

检查代码库:

npm run lint

类型检查:

npm run type-check

依赖项

核心依赖项:

  • @modelcontextprotocol/sdk:MCP 服务器实现

  • file-type:文件类型检测

  • mime-types:MIME 类型查找

  • crypto-js:文件哈希

  • 归档器:ZIP 创建

  • extract-zip:ZIP 提取

  • iconv-lite:文本编码

  • chardet:编码检测

开发依赖项:

  • typescript:类型系统

  • 开玩笑:测试

  • eslint:Lint

  • 更漂亮:格式化

  • ts-node:TypeScript 执行

  • nodemon:开发服务器

贡献

  1. 分叉存储库

  2. 创建你的功能分支

  3. 为新功能编写测试

  4. 确保所有测试通过

  5. 提交拉取请求

执照

麻省理工学院

-
security - not tested
A
license - permissive license
-
quality - not tested

Related MCP Servers

  • A
    security
    A
    license
    A
    quality
    A Model Context Protocol server that enables enhanced file system operations including reading, writing, copying, moving files with streaming capabilities, directory management, file watching, and change tracking.
    Last updated -
    19
    MIT License
    • Linux
    • Apple
  • A
    security
    A
    license
    A
    quality
    A Model Context Protocol server that provides secure and intelligent interaction with files and filesystems, offering smart context management and token-efficient operations for working with large files and complex directory structures.
    Last updated -
    21
    50
    MIT License
    • Apple
    • Linux
  • A
    security
    A
    license
    A
    quality
    A server implementing the Model Context Protocol that provides filesystem operations (read/write, directory management, file movement) through a standardized interface with security controls for allowed directories.
    Last updated -
    9
    3
    MIT License
  • -
    security
    F
    license
    -
    quality
    A comprehensive Model Context Protocol server that provides over 50 file and system management tools for AI models, including navigation, file operations, search, compression, and system information capabilities.
    Last updated -

View all related MCP servers

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bsmi021/mcp-filesystem-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server