mcp-server-filesystem について
FileSystem MCP Server は、ファイルシステム操作を提供する MCP サーバーです。Node.js 上で npx により起動し、VS Code、Cursor、Windsurf、Claude Desktop などの MCP クライアントで利用できます。
主な機能
- 01npx で起動するローカル stdio サーバー
- 02SSE と Streamable HTTP のリモートエンドポイント
- 03allowed-directories による アクセス先ディレクトリの制限
- 04JavaScript / TypeScript プロジェクトからのインプロセス呼び出し
活用シーン
- 01アシスタントによるローカルプロジェクト内のファイル読み書き
- 02Cursor や Claude Desktop へのファイルアクセス機能の追加
MCP 対応
本プロジェクトは、ファイルシステム操作を MCP クライアントに提供する MCP サーバーです。クライアントは stdio、SSE、Streamable HTTP で接続できます。
設定
ローカルサーバーの設定はどのクライアントでも共通です。コピーしてクライアントの MCP 設定ファイルに貼り付けてください。
ツール
ローカルサーバーのツールはマシン上で起動して初めて取得できます。メンテナーはまだツール一覧を提供していません。
詳細
FileSystem MCP サーバー
ファイルシステム操作を提供する Model Context Protocol(MCP)サーバーです。
要件
- Node.js 18 以降
- VS Code、Cursor、Windsurf、Claude Desktop、またはその他の MCP クライアント
はじめに
ローカル(Stdio)
まず、クライアントに Filesystem MCP サーバーをインストールします。一般的な設定は次のとおりです。
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"@agent-infra/mcp-server-filesystem@latest"
]
}
}
}
VS Code にインストール
VS Code CLI を使って Filesystem MCP サーバーをインストールすることもできます。
# For VS Code
code --add-mcp '{"name":"filesystem","command":"npx","args":["@agent-infra/mcp-server-filesystem@latest"]}'
インストール後、VS Code の GitHub Copilot エージェントで Filesystem MCP サーバーを利用できるようになります。
Cursor にインストール
Cursor Settings -> MCP -> Add new MCP Server に移動します。任意の名前を付け、command タイプを選択し、コマンドに npx @agent-infra/mcp-server-filesystem を指定します。Edit をクリックすると、設定を確認したり、コマンド引数などを追加したりすることもできます。
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"@agent-infra/mcp-server-filesystem@latest",
"--allowed-directories /tmp"
]
}
}
}
Windsurf にインストール
Windsurf MCP のドキュメントに従って、次の設定を使用してください。
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"@agent-infra/mcp-server-filesystem@latest",
"--allowed-directories /tmp"
]
}
}
}
Claude Desktop にインストール
MCP のインストールガイドに従って、次の設定を使用してください。
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"@agent-infra/mcp-server-filesystem@latest",
"--allowed-directories /tmp"
]
}
}
}
リモート(SSE / Streamable HTTP)
同時に、--port $your_port 引数を使ってブラウザー MCP を起動すると、SSE および Streamable HTTP サーバーに変換できます。
# normal run remote mcp server
npx @agent-infra/mcp-server-filesystem --port 8089 --allowed-directories <dir>
次のいずれかの MCP サーバーのリモートエンドポイントを使用できます。
- Streamable HTTP(推奨):
http://127.0.0.1::8089/mcp - SSE:
http://127.0.0.1::8089/sse
次に、MCP クライアントの設定で、url を SSE エンドポイントに設定します。
{
"mcpServers": {
"filesystem": {
"url": "http://127.0.0.1::8089/sse"
}
}
}
Streamable HTTP の場合は、url を次のように設定します。
{
"mcpServers": {
"filesystem": {
"type": "streamable-http", // If there is MCP Client support
"url": "http://127.0.0.1::8089/mcp"
}
}
}
インメモリ呼び出し
MCP クライアントが JavaScript / TypeScript に基づいて開発されている場合、ユーザーが Filesystem MCP を使用するためにコマンドラインインターフェイスをインストールする必要がないよう、インプロセス呼び出しを直接使用できます。
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js';
// type: module project usage
import { createServer } from '@agent-infra/mcp-server-filesystem';
// commonjs project usage
// const { createServer } = await import('@agent-infra/mcp-server-filesystem')
const client = new Client(
{
name: 'test filesystem client',
version: '1.0',
},
{
capabilities: {},
},
);
const server = createServer();
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
await Promise.all([
client.connect(clientTransport),
server.connect(serverTransport),
]);
// list tools
const result = await client.listTools();
console.log(result);
// call tool
const toolResult = await client.callTool({
name: 'list_directory',
arguments: {
path: '~/your_computer'
},
});
console.log(toolResult);
開発
http://127.0.0.1:6274/ にアクセスします。
npm run dev
コメント
AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。