librechat-personal-files-mcp
librechat-personal-files-mcp
LibreChat エージェント向けに、ユーザーごとの個人ファイルストレージ、永続的なドキュメント、RAGインデックス/検索、そして不透明な公開リンク公開を提供するMCPサーバー。
機能
ユーザーごとのストレージ:
/data/private/<userId>/配下にプライベートファイルを保存し、完全なCRUD・一覧・移動操作をサポートします。ドキュメントカタログ:
save_documentation/update_documentationはdocs/に書き込み、memory-index.json(スキーマv2)を更新します。RAG統合:
index_documentはコンテンツをPOST /embedで rag_api に送信し、カナリア検証(issue #305)を行います。search_knowledgeはセマンティック検索、remove_from_knowledgeは削除に使用します。公開リンク公開:
publish_fileは暗号学的にランダムなトークン(128ビット以上)を生成します。ファイルはNginx のX-Accel-RedirectとContent-Disposition: attachment、nosniff、no-storeを通じて配信されます。厳格なセキュリティ:
X-User-Idが欠落または不正な場合はフェイルクローズします。パストラバーサルを遮断し、絶対パスや..セグメントを拒否します。シンボリックリンクによるエスケープ検出、予約セグメントの保護、クロスプロセスロック付きのアトミックなインデックス書き込みを備えています。
Related MCP server: knowledge_mgmt
アーキテクチャ
┌──────────────┐ ┌────────────────────────┐ ┌─────────────┐
│ LibreChat │────▶│ librechat-personal-files-mcp │──▶│ rag_api │
│ (Agent) │ MCP │ (stateless HTTP /mcp) │ │ (vector DB) │
└──────────────┘ └────────────────────────┘ └─────────────┘
│
│ GET /files/{token}
▼
┌──────────────┐
│ Nginx │
│ (X-Accel) │
└──────────────┘
│
▼
┌──────────────┐
│ /data/private│ (read-only bind)
└──────────────┘クイックスタート(開発)
cd /opt/LibreChat/mcp-personal-files
python -m venv .venv
.venv/bin/pip install -e ".[dev]"
.venv/bin/python -m pytest
.venv/bin/python -m ruff check .
# Run server
STORAGE_ROOT=/tmp/pf-private JWT_SECRET=$(openssl rand -hex 32) .venv/bin/personal-files-mcp本番デプロイ
1. ホストの準備(root で一度だけ実行)
cd /opt/LibreChat
groupadd -g 2500 lcfiles 2>/dev/null || true
mkdir -p ./data/private/_system
chown -R 2000:2500 ./data/private
chmod 2770 ./data/private
setfacl -R -m g:2500:rX,d:g:2500:rX ./data/private 2>/dev/null || \
echo "ACL tools absent; using 644/755 fallback"
grep -q '^JWT_SECRET=' .env || echo "JWT_SECRET=$(openssl rand -hex 32)" >> .env2. docker-compose.override.yml に追加
docker-compose.snippet.yml のブロックを既存のオーバーライドファイルにコピーしてください。
3. LibreChat 管理パネルの設定
MCP設定の下に追加:
mcpSettings:
allowedAddresses:
- 'librechat-personal-files:8080'
mcpServers:
personal-files:
type: streamable-http
url: http://librechat-personal-files:8080/mcp
timeout: 120000
chatMenu: false
headers:
X-User-ID: '{{LIBRECHAT_USER_ID}}'
X-User-Email: '{{LIBRECHAT_USER_EMAIL}}'LibreChat を再起動します。
4. Nginx設定(既存のserverブロックに追加)
limit_req_zone $binary_remote_addr zone=pubfiles:10m rate=5r/s;
location ^~ /files/ {
limit_req zone=pubfiles burst=10 nodelay;
limit_req_status 429;
proxy_pass http://librechat-personal-files:8080/files/;
proxy_set_header X-Original-URI $request_uri;
proxy_set_header X-Real-IP $remote_addr;
}
location ^~ /_protected/ {
internal;
alias /data/private/;
}Nginx をリロードします。
環境変数
変数 | デフォルト | 説明 |
|
| ユーザーIDを運ぶヘッダー |
|
| ユーザーデータのルートディレクトリ |
|
| レガシー共有エリア(移行中は読み書き可能) |
|
| rag_api のエンドポイント |
| required | LibreChat/rag_api と共有するHS256シークレット(32文字以上) |
|
| 公開リンクのベースURL |
|
| 最大アップロードサイズ |
|
| 公開リンク用SQLiteレジストリ |
MCPツール
ストレージ
list_files(path="", recursive=false, pattern=null)— ファイル/ディレクトリの一覧表示read_file(path)— UTF-8テキストを読み取る。バイナリまたは2MB超の場合はエラーwrite_file(path, content)— テキスト(UTF-8)を書き込む。親ディレクトリも作成update_file(path, content)— 既存ファイルを更新delete_file(path)— ファイルまたはディレクトリを削除move_file(src, dst)— ユーザールート内で移動get_file_info(path)— メタデータ + docindex + 公開ステータス
ドキュメント
save_documentation(filename, content, title?, description?, tags?, topics?)—docs/に保存し、インデックスを更新。公開やインデックス化は行いませんupdate_documentation(filename, content, ...)— 既存ドキュメントを更新get_document_metadata(filename)— 完全なインデックスエントリを取得
RAG
search_knowledge(query, limit=8)— セマンティック検索(JWTにより所有者スコープ)index_document(path)— エンベディング + カナリア検証を行い、インデックスステータスを更新remove_from_knowledge(path)— rag_api から削除し、インデックスをクリアget_index_status()— 件数 + rag_api のヘルスステータス
公開
publish_file(path, expires_in_days?)— 公開リンクを作成/再利用し、トークン + URL を返すunpublish_file(path_or_token)— リンクを無効化(ファイルは非公開のまま)get_public_link(path)— パスに対する有効なリンクを取得list_public_links()— ユーザーの全リンクを一覧表示
セキュリティモデル
アイデンティティ: LibreChat が注入する
X-User-Idヘッダー({{LIBRECHAT_USER_ID}})。プレースホルダーが未解決 → 空文字列 → フェイルクローズ。フェイルクローズ: ヘッダーが欠落、空、または不正な場合は HTTP 403
{"error":"missing_user_identity"}または{"error":"invalid_user_identity"}を返します。パスの安全性: すべてのパスは相対パスで、絶対パスと
..は拒否されます。Path.resolve()とプレフィックスチェックによりシンボリックリンクのエスケープを検出します。分離: JWT の
sub/id= userId により rag_api の所有者スコープを強制します(PR #319、2026-08-15 マージ)。公開リンク: 不透明な
secrets.token_urlsafe(16)トークンを使用し、URLにはユーザーやパスを含めません。失効は410 Goneで行い、期限切れエントリは遅延クリーンアップされます。
開発
# Run tests
.venv/bin/pytest -q
# Lint
.venv/bin/ruff check .
# Type check (optional)
.venv/bin/mypy src/personal_files_mcp # if mypy added to depsライセンス
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- FlicenseNot gradedqualityBmaintenanceEnables AI agents to process files locally — OCR images, extract text from PDFs and DOCX, and describe images using local vision models, all without sending data to external services.
- AlicenseNot gradedqualityDmaintenanceEnables uploading, organizing, and semantically searching documents with support for various file types and embedding providers.27MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents with long-term memory and retrieval-augmented generation (RAG) capabilities, allowing them to recall past conversations, search local files, and learn user preferences.MIT
- AlicenseAqualityCmaintenanceProvides AI agents with local file-processing capabilities for token counting, RAG chunking, CSV/JSON conversion, QR generation, and more, while keeping documents private on the user's machine.71MIT
Related MCP Connectors
File uploads for AI agents. Upload, list, and manage files. No signup required.
Securely search and manage workspace context files for AI agents and teams.
Upload any file, get a tracked shareable link. DocSend for AI agents.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/martinriesel/librechat-personal-files-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server