MCP (Opsional)
Hubungkan agent ke DB, API, browser via MCP.
MCP (Opsional)
MCP = standar hubungkan AI agent ke layanan/data eksternal (database, API, file system, browser).
Link resmi: https://modelcontextprotocol.io Daftar server terpercaya:
- Official: https://github.com/modelcontextprotocol/servers
- Community: https://github.com/punkpeye/awesome-mcp-servers
- Registry: https://mcp.so
Apa Itu MCP?
AI Agent (OpenCode) ──MCP──► External Service (DB, API, Files)
Agent nggak perlu tahu detail API masing-masing. Cukup pakai MCP tools.
Kapan Butuh MCP?
| Butuh MCP | Nggak Butuh | |-----------|-------------| | Akses database (Postgres, MySQL) | Cuma baca/tulis file lokal | | Panggil API (GitHub, Slack, Notion) | Project sederhana offline | | Browser automation (scrape, test) | Belajar dasar agent | | File system remote (SSH, FTP) | Model gratis sudah cukup |
Contoh MCP Server Populer
| Server | Fungsi | |--------|--------| | filesystem | Baca/tulis file lokal | | github | Issue, PR, repo | | postgres | Query database | | sqlite | Database lokal | | fetch | HTTP request | | puppeteer | Browser automation |
Cara Tambah MCP ke OpenCode
Via OpenCode (mudah):
Tambah MCP server filesystem
Manual config:
{
"mcp": {
"filesystem": {
"type": "local",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/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
- Bisa baca semua file di folder yg diizinkan
- Server remote bisa lihat data yg dikirim
- Token di config = risiko kebocoran
Best practice:
- Pakai MCP official/populer
- Batasi folder akses (jangan root
/)- Read-only mode kalau bisa
- Audit config berkala
- Hapus MCP yg nggak dipakai
Kapan Mulai Pakai MCP?
Setelah:
- ✅ Agent pertama jalan
- ✅ Paham cara OpenCode kerja
- ✅ Butuh integrasi yg nggak bisa manual
Belum perlu buru-buru. Fokus belajar dulu.
Selesai Tutorial Opsional! 🎉
Kembali ke: Daftar Tutorial
