Smart Hydroponic MCP Server
Provides tools to interact with a PostgreSQL database storing hydroponic sensor data, including listing tables, describing table schemas, reading recent sensor entries, and querying aggregated time-series data.
Enables efficient time-series aggregation of hydroponic sensor data using TimescaleDB's time_bucket functionality.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Smart Hydroponic MCP ServerWhat's the average pH over the last 7 days?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
๐ฑ Smart Hydroponic MCP Server
Server Model Context Protocol (MCP) berbasis semantic context untuk sistem IoT Smart Hydroponic. Menghubungkan Large Language Models (LLM) dengan database time-series PostgreSQL + TimescaleDB secara aman, efisien, dan terstandardisasi.
Apa itu Model Context Protocol (MCP)?
MCP adalah standar terbuka (open standard) yang memungkinkan agen kecerdasan buatan (seperti Claude Desktop, Cursor, atau custom LLM agent) mengakses data real-time, context feeds, tools terparameterisasi, dan prompt workflow secara seragam tanpa membebani LLM dengan kueri SQL mentah.
โจ Fitur Utama
๐ฆ MCP Resource (
hydroponic://state/latest): Menyajikan snapshot telemetri kondisi kebun terkini (pH, TDS, suhu rata-rata, kelembapan, flowrate, volume tandon, dan status aktuator) dalam format teks bersih untuk LLM.๐ Downsampled Historical Trend (
get_historical_trend): Menggunakan fungsi TimescaleDBtime_bucket('1 hour', dataid)untuk menyajikan tren historis teragregasi (rata-rata, minimum, maksimum, sampel) tanpa menghabiskan context window LLM.โก Actuator Uptime Summary (
get_actuator_summary): Menghitung keandalan sistem dan persentase aktif aktuator (pump_status,light_status,automation_status) selama rentang waktu evaluasi.๐ฉบ Standardized Diagnostic Prompt (
diagnose_environment): Workflow prompt cerdas yang memandu AI membandingkan kondisi riil terhadap standar agronomi hidroponik dan menyusun diagnosis komprehensif.๐ก๏ธ SQLAlchemy 2.0 Async Core & Safe Raw SQL: Koneksi dikelola dengan
create_async_enginedanasync_sessionmaker, sementara query dieksekusi dengan parameterized binding:paramyang kebal terhadap SQL Injection.๐งช Automated Testing & CI/CD: Dilengkapi test suite
pytestdan pipeline GitHub Actions otomatis untuk linting, testing, dan Docker build/push.
Related MCP server: MCP PostgreSQL
๐ Prasyarat
Python >= 3.14
Package Manager:
uvPostgreSQL dengan ekstensi TimescaleDB (mendukung partisi hypertable berbasis
UUIDv7/timestamp).
โ๏ธ Konfigurasi Environment
Salin atau buat file .env di direktori utama:
HYDROPONIC_DB_HOST=127.0.0.1
HYDROPONIC_DB_PORT=5432
HYDROPONIC_DB_USER=admin_iot_db
HYDROPONIC_DB_PASSWORD=your_password
HYDROPONIC_DB_NAME=iot_hydroponik
HYDROPONIC_DB_SCHEMA=public
HYDROPONIC_TABLE_NAME=hydroponic_dataAtau menggunakan connection string tunggal:
DATABASE_URL=postgresql+asyncpg://admin_iot_db:your_password@127.0.0.1:5432/iot_hydroponik๐ Menjalankan Server
Proyek ini menggunakan standardisasi package manager uv:
# Sinkronisasi dependensi dan jalankan server
uv run main.pyServer HTTP SSE FastMCP akan aktif pada http://0.0.0.0:8000.
Untuk menjalankan pengujian otomatis:
# Menjalankan unit & integration tests
uv run pytest -v
# Pengecekan linter & format kode
uv run ruff check .
uv run ruff format --check .๐ค Integrasi dengan AI Client (Claude Desktop / Cursor)
Tambahkan konfigurasi berikut pada file pengaturan MCP klien Anda (misalnya claude_desktop_config.json):
{
"mcpServers": {
"smart-hydroponic": {
"command": "uv",
"args": [
"run",
"c:/path/to/smart-hydroponic-mcp/main.py"
],
"env": {
"HYDROPONIC_DB_HOST": "127.0.0.1",
"HYDROPONIC_DB_PORT": "5432",
"HYDROPONIC_DB_USER": "admin_iot_db",
"HYDROPONIC_DB_PASSWORD": "your_password",
"HYDROPONIC_DB_NAME": "iot_hydroponik"
}
}
}
}๐ณ Docker Deployment
Server ini dapat dijalankan dalam kontainer Docker:
# Build Docker image secara lokal
docker build -t smart-hydroponic-mcp:latest .
# Menjalankan kontainer dengan file environment
docker run -d --name smart-hydroponic-mcp -p 8000:8000 --env-file .env smart-hydroponic-mcp:latestAtau menggunakan Docker Compose:
docker compose up -dThis server cannot be deployed
Maintenance
Related MCP Connectors
- mcpOAuthcom.gibsonai
GibsonAI MCP server: manage your databases with natural language
Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.
- dataOAuthco.thinair
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Related MCP Servers
- AlicenseAqualityBmaintenanceAn MCP server that gives AI agents direct read-only access to PostgreSQL databases, enabling natural language analytics through tools for schema exploration, querying, trend analysis, and data quality checks.115MIT
- AlicenseNot gradedqualityDmaintenanceA read-only MCP server for PostgreSQL that enables safe database introspection and querying via natural language.442 npmMIT
- FlicenseNot gradedqualityBmaintenanceA read-only PostgreSQL MCP server that translates natural language queries into SQL, enforcing database routing, table/column whitelists, and safety checks. It offers schema inspection and query tools with optional output as SQL or results.-
- FlicenseNot gradedqualityCmaintenanceRead-only MCP server exposing a fleet management PostgreSQL database via schema introspection and safe SELECT query tools, enabling natural language question answering about fleet data.-