Skip to main content
Glama

ローカルOSアシスタント&セカンドブレイン(MCP & OpenAI)

Model Context Protocol (MCP) と OpenAI(gpt-4o) を搭載した、自律型・クロスプラットフォーム対応のローカルデスクトップアシスタントです。ローカルシステムコマンドを安全に実行し、ファイルの読み書きを行い、ハードウェア診断を監視し、ローカルのSQLiteデータベース(brain.db)を使用してセッションをまたいだプロジェクトコンテキストを記憶します。


機能

  • MCP FastMCPサーバー(server.py):

    • read_local_file: ローカルファイルのテキスト内容を安全に読み取ります。

    • write_local_file: ローカルファイルにコンテンツを書き込み、不足しているディレクトリを自動的に作成します。

    • list_directory: サイズとファイルタイプの詳細を含む、フォーマット済みのディレクトリ情報を表示します。

    • execute_terminal_command: 破壊的なキーワード(rm、del、rmdir、format、drop)に対する安全プロンプトのガードレール付きでシェルコマンドを実行します。

    • open_application_or_url: デスクトップアプリケーションを起動するか、デフォルトのWebブラウザでURLを開きます(Windows、macOS、Linuxに対応)。

    • get_system_metrics: psutil を使用して、CPU、RAM、ディスク、バッテリーのリアルタイム診断情報を取得します。

    • save_memory: ユーザーノート、プロジェクトスタックコンテキスト、設定をSQLiteの brain.db に永続化します。

    • search_memory: 保存されたメモリ全体を全文検索・パターン検索します。

  • 対話型ターミナルアシスタント(client.py):

    • MCP stdioトランスポートによる動的なツール検出。

    • brain.db からの起動時メモリハイドレーション。

    • 永続的なCLI REPLプロンプト(You > / Brain >)。

  • Claude Desktop対応(claude_desktop_config.json):

    • Claude Desktopとの統合にすぐ使える設定ファイル。


Related MCP server: Desktop Commander MCP

インストールとセットアップ

前提条件

  • Python 3.10以上。

  • OpenAI APIキー(OPENAI_API_KEY)。

1. 仮想環境のセットアップ

プロジェクトのルートディレクトリに移動し、仮想環境を作成します:

# Windows
python -m venv venv
venv\Scripts\activate

# macOS / Linux
python3 -m venv venv
source venv/bin/activate

2. 依存関係のインストール

requirements.txt から固定された依存関係をインストールします:

pip install -r requirements.txt

3. 環境設定

プロジェクトのルートディレクトリに .env ファイルを作成するか、環境変数を設定します:

OPENAI_API_KEY=your_openai_api_key_here

アシスタントの実行

オプションA: 対話型CLIクライアント

対話型アシスタントターミナルを起動します:

python client.py

セッション例:

You > Save a memory under key 'favorite_editor' value 'VS Code with Vim binding' tags ['preference', 'tools']
Brain > I've stored your preference for VS Code with Vim binding in the brain database.

You > What are my current system metrics?
Brain > Your system is running at 15.4% CPU usage with 12.2 GB / 32 GB RAM used and 78% battery remaining.

オプションB: Claude Desktopとの統合

このローカルMCPサーバーを Claude Desktop で使用するには、claude_desktop_config.json の設定をClaude Desktopの設定ファイルに追加します:

  • Windows: %APPDATA%\Claude\claude_desktop_config.json

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

サーバー定義を追加します:

{
  "mcpServers": {
    "local-os-brain": {
      "command": "python",
      "args": [
        "C:/Users/acer/.gemini/antigravity-ide/scratch/mcp_local_brain/server.py"
      ]
    }
  }
}

注: venvを使用する場合は、"python" を仮想環境のPython実行ファイルの絶対パスに置き換えてください。


プロジェクト構造

mcp_local_brain/
├── brain.db                      # SQLite database auto-generated on first run
├── server.py                    # FastMCP Server with OS & Brain Tools
├── client.py                    # Interactive Terminal AI Assistant
├── claude_desktop_config.json   # Claude Desktop configuration snippet
├── requirements.txt             # Pinned python dependencies
└── README.md                    # Documentation & Setup Guide

ライセンス

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to access the local machine over MCP for terminal commands, file operations, code search, process management, and reading or editing PDF, Excel, and Word documents, with no telemetry.
      394 npm
      1
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI clients to perform sandboxed file-system operations, read-only SQLite querying and schema inspection, environment diagnostics, and cryptographic hashing over Stdio or HTTP using JSON-RPC.
      2
      MIT