MCP (Opsional)
Apa itu MCP, kapan butuh, dan cara nambahin dengan aman.
MCP (Model Context Protocol) - Opsional
MCP = standar buat hubungkan AI agent ke layanan/data eksternal (database, API, file system, browser, dll).
Link resmi: https://modelcontextprotocol.io
Daftar MCP Server Terpercaya:
- Official: https://github.com/modelcontextprotocol/servers
- Community: https://github.com/punkpeye/awesome-mcp-servers
- Registry: https://mcp.so
Apa Itu MCP?
┌─────────────┐ MCP ┌──────────────────┐
│ AI Agent │ ──────────► │ External Service │
│ (OpenCode) │ protocol │ (DB, API, Files) │
└─────────────┘ └──────────────────┘
Agent nggak perlu tau detail API masing-masing. Cukup pakai MCP tools.
Kapan Butuh MCP?
| Butuh MCP | Nggak Butuh MCP | |-----------|-----------------| | Akses database (Postgres, MySQL) | Cuma baca/tulis file lokal | | Panggil API eksternal (GitHub, Slack, Notion) | Project sederhana offline | | Browser automation (scrape, test) | Belajar dasar agent | | File system remote (SSH, FTP) | Model gratis OpenCode cukup |
Contoh MCP Server Populer
| Server | Fungsi | Link | |--------|--------|------| | filesystem | Baca/tulis file lokal | Official | | github | Issue, PR, repo ops | Official | | postgres | Query database | Official | | sqlite | Database lokal | Official | | fetch | HTTP request | Official | | puppeteer | Browser automation | Community | | memory | Persistent memory | Community |
Cara Tambah MCP ke OpenCode
Via OpenCode (mudah):
Tambah MCP server filesystem
Manual config:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"filesystem": {
"type": "local",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/folder"]
},
"github": {
"type": "local",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "your-token"
}
}
}
}
⚠️ Risiko & Keamanan
MCP server = akses penuh ke resource kamu
- Server MCP bisa baca semua file di folder yang diizinkan
- Server remote bisa lihat data yang dikirim
- Token/API key di config = risiko kebocoran
Best practice:
- Pakai MCP official/community yang populer
- Batasi folder akses (jangan root
/)- Gunakan read-only mode kalau bisa
- Audit config secara berkala
- Hapus MCP yang nggak dipakai
Kapan Mulai Pakai MCP?
Setelah:
- ✅ Agent pertama udah jalan
- ✅ Paham cara OpenCode kerja
- ✅ Butuh integrasi spesifik yg nggak bisa dikerjain manual
Belum perlu buru-buru. Fokus belajar dulu.
Selesai Tutorial Opsional! 🎉
Kembali ke: Daftar Tutorial
