背景・目的
以前、下記の通りMCPについて基本を整理しました。今回はClaude Desktopでクライアント側でMCPの動作を確認してみます
まとめ
下記にFilesystem MCP Serverの特徴をまとめました
特徴 | 説明 |
---|---|
概要 | ファイルシステム操作用のMCPを実装する Node.js サーバー |
機能 | ・Read/write files ・Create/list/delete directories ・Move files/directories ・Search files ・Get file metadata |
License | MITライセンス |
概要
アーキテクチャ
以前まとめた下記の通り、MCPはMCPホスト、MCPサーバ、データソースの3層で構成されています。
- MCPホストは、Claude DespktopやIDEなどMCPプロトコルを通じてデータにアクセスするプログラム、AIツール
- MCPクライアントは、MCPサーバと1:1接続するプログラム
- LLMは、MCPホスト側に存在します
- MCPサーバは、MCPプロトコルを通じて機能を提供するプログラム
- データソースは、MCPサーバよりアクセス可能なローカルファイル、社内DBは、クラウド上のREST APIなど
Filesystem MCP Server
下記について整理します。
- ファイルシステム操作用のMCPを実装する Node.js サーバー
- 下記の機能を有します
- Read/write files
- Create/list/delete directories
- Move files/directories
- Search files
- Get file metadata
Usage with Claude Desktop
- claude_desktop_config.json に以下を追加します
- サンドボックス化されたディレクトリを /projects にマウントすることで、サーバーに提供できる
- ro フラグを追加すると、そのディレクトリはサーバーによって読み取り専用になる
- Docker
{
"mcpServers": {
"filesystem": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--mount", "type=bind,src=/Users/username/Desktop,dst=/projects/Desktop",
"--mount", "type=bind,src=/path/to/other/allowed/dir,dst=/projects/other/allowed/dir,ro",
"--mount", "type=bind,src=/path/to/file.txt,dst=/projects/path/to/file.txt",
"mcp/filesystem",
"/projects"
]
}
}
}
- NPX
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/username/Desktop",
"/path/to/other/allowed/dir"
]
}
}
}
License
MITラインセンス
実践
Claude Desktopで試す
下記を元に試します。
https://modelcontextprotocol.io/quickstart/user
下記を使用します。
事前準備
-
事前にClaude Desktopをダウンロードしておきます
-
nodeにパスを通します
% which node /usr/local/opt/node@20/bin/node % % sudo ln -s /usr/local/opt/node@20/bin/node /usr/local/bin/node
セットアップ
-
Claude Desktopを開きます
-
claude_desktop_config.jsonが作成されます
-
下記を入力します
{ "mcpServers": { "filesystem": { "command": "npx", "args": [ "-y", "@modelcontextprotocol/server-filesystem", "/Users/username/Desktop", "/path/to/other/allowed/dir" ] } } }
-
Claude Desktopを再起動します
-
次を「デスクトップに、claude_test.txtファイルを作成し、今日の日付(JST)を入力して」とプロンプトを入力します
-
ファイルもできました。(日時を指定すればよかったです)
% ls -l claude_test.txt -rw-r--r--@ 1 XXXX XXXX 25 5 31 17:35 claude_test.txt % cat claude_test.txt 2025年5月31日(土) %
考察
今回は、Claude Desktopを試してみました。次回はMCPさーばをためしてみm
参考