========================================
MCP FILESYSTEM – SEADISTUS ja KASUTUSJUHEND
========================================

Asukoht serveris: /opt/docker-compose/third/server/mcp-filesystem
Andmete kaust:     /data/mcp-filesystem
Tailscale IP:      100.87.1.24
Serveri hostname:  ohmu

------------------------------------------------
1. MIS SEE ON?
------------------------------------------------
MCP (Model Context Protocol) failiserver võimaldab AI
assistentidel (opencode, Claude Desktop, VS Code jne)
lugeda, kirjutada ja hallata faile läbi standardse MCP
liidese.

------------------------------------------------
2. KUIDAS KÄIVITADA?
------------------------------------------------
   cd /opt/docker-compose/third/server/mcp-filesystem
   bash run.sh

See käivitab kaks konteinerit:
  a) mcp-filesystem     – stdio-põhine (docker-compose)
  b) mcp-filesystem-sse – SSE/HTTP endpoint (docker run)

------------------------------------------------
3. KONTEINERITE EHITAMINE
------------------------------------------------
Stdio image:
  docker build -t mcp/filesystem -f src/filesystem/Dockerfile .

SSE image (vajab Node.js + Python mcp-proxy):
  docker build -t mcp-filesystem-sse /opt/docker-compose/third/server/mcp-filesystem

------------------------------------------------
4. ÜHENDAMINE OPENCODE'GA
------------------------------------------------

4a. SAMAS MASINAS (kohalik stdio):
  opencode.json:
  {
    "mcp": {
      "filesystem": {
        "type": "local",
        "command": [
          "docker", "run", "-i", "--rm",
          "--mount", "type=bind,src=/data/mcp-filesystem,dst=/projects/data",
          "mcp/filesystem",
          "/projects"
        ]
      }
    }
  }

4b. TEISES MASINAS (üle Tailscale, HTTP/SSE):
  opencode.json:
  {
    "mcp": {
      "filesystem": {
        "type": "remote",
        "url": "http://100.87.1.24:3100/sse"
      }
    }
  }

4c. TEISES MASINAS (üle Tailscale, SSH stdio):
  opencode.json:
  {
    "mcp": {
      "filesystem": {
        "type": "local",
        "command": [
          "ssh", "ardo@100.87.1.24",
          "docker", "exec", "-i", "mcp-filesystem",
          "node", "/app/dist/index.js", "/projects"
        ]
      }
    }
  }

  Eeldus: SSH võti on seadistatud (ssh-copy-id ohmu@100.87.1.24)

------------------------------------------------
5. MCP TÖÖRIISTAD (AI-le saadaval)
------------------------------------------------
- filesystem_list_allowed_directories
- filesystem_list_directory
- filesystem_list_directory_with_sizes
- filesystem_read_text_file
- filesystem_read_multiple_files
- filesystem_write_file
- filesystem_edit_file
- filesystem_create_directory
- filesystem_read_media_file
- filesystem_get_file_info
- filesystem_move_file
- filesystem_search_files
- filesystem_directory_tree

------------------------------------------------
6. TESTIMINE
------------------------------------------------
Pärast ühendamist küsi AI-lt:
  "Loetle failid kaustas /projects/data"
  "Millised MCP tööriistad sul saadaval on?"

------------------------------------------------
7. SÜSTEEMI TAASTAMINE (puhtalt uuesti)
------------------------------------------------
Kui kogu süsteem on kadunud:

  7a. Klooni MCP serverite repo:
      git clone https://github.com/modelcontextprotocol/servers.git
      cd servers
      docker build -t mcp/filesystem -f src/filesystem/Dockerfile .

  7b. Loo SSE image:
      cd /opt/docker-compose/third/server/mcp-filesystem
      docker build -t mcp-filesystem-sse .

  7c. Käivita:
      bash run.sh

  7d. Lisa opencode.json ja taaskäivita opencode.

------------------------------------------------
8. FAILIDE ASUKOHT
------------------------------------------------
Andmed:     /data/mcp-filesystem
Varukoopia: /backups/docker/mcp-fileserver

------------------------------------------------
9. n8n MCP KLIENT
------------------------------------------------
n8n (v2.13+) saab kasutada MCP servereid workflow'des.

Seadistus:
  - Loodud: /data/docker/n8n/mcp.json
  - Endpoint: http://100.87.1.24:3100/sse
  - N8N_MCP_TOOLS_ENABLED=true lisatud docker-compose.env

Kasutamine n8n-s:
  - Ava https://n8n.tail20e23.ts.net
  - Uus workflow → otsi "MCP Client" node
  - Endpoint URL: http://100.87.1.24:3100/sse
  - Type: SSE
  - Nüüd saad workflow'des lugeda/kirjutada faile.

------------------------------------------------
10. INTEGREERITUD TEENUSED
------------------------------------------------
MCP kaudu nähtavad:
  /projects/data/            – docker-compose konfiguratsioonid
  /projects/n8n/             – n8n andmebaas ja logid
  /projects/n8n-workflows    – 15 eksporditud workflow'd
  /projects/anythingllm/     – dokumendid, vektorbaas
  /projects/open-webui/      – 2410 üleslaetud faili
  /projects/backups/         – varukoopiad

------------------------------------------------
11. LISATEE
------------------------------------------------
Lähemalt loe: https://opencode.ai/docs/mcp/servers/
