### Set Up Kafka Server on macOS Source: https://docs.emqx.com/en/emqx/latest/data-integration/data-bridge-kafka.html Install and run Kafka using provided commands. This example uses KRaft to start Kafka. ```bash wget https://archive.apache.org/dist/kafka/3.3.1/kafka_2.13-3.3.1.tgz tar -xzf kafka_2.13-3.3.1.tgz cd kafka_2.13-3.3.1 # Use KRaft start Kafka KAFKA_CLUSTER_ID="$(bin/kafka-storage.sh random-uuid)" bin/kafka-storage.sh format -t $KAFKA_CLUSTER_ID -c config/kraft/server.properties bin/kafka-server-start.sh config/kraft/server.properties ``` -------------------------------- ### Start Example with Docker Compose Source: https://docs.emqx.com/en/emqx/latest/deploy/cluster/lb-haproxy.html Use Docker Compose to start the EMQX cluster and HAProxy environment. ```bash docker compose up -d ``` -------------------------------- ### Start EMQX in Background with Installation Package Source: https://docs.emqx.com/en/emqx/latest/getting-started/getting-started.html Start EMQX in the background using the installation package. This method is not recommended for general use. Access the EMQX Dashboard at http://localhost:18083/. ```bash ./emqx/bin/emqx start ``` -------------------------------- ### Install Plugin via API Source: https://docs.emqx.com/en/emqx/latest/extensions/plugin-management.html Instructions for installing, starting, stopping, and checking plugins using the EMQX API. ```APIDOC ## Install Plugin via API ### Description Install a compiled plugin package and manage its lifecycle using the EMQX API. ### Steps 1. **Allow Installation:** ```bash emqx ctl plugins allow my_emqx_plugin-1.0.0 ``` 2. **Install Plugin:** ```bash curl -u $KEY:$SECRET -X POST http://$EMQX_HOST:18083/api/v5/plugins/install -H "Content-Type: multipart/form-data" -F "plugin=@my_emqx_plugin-1.0.0.tar.gz" ``` 3. **Check Plugin List:** ```bash curl -u $KEY:$SECRET http://$EMQX_HOST:18083/api/v5/plugins | jq ``` 4. **Start/Stop Plugin:** ```bash curl -s -u $KEY:$SECRET -X PUT "http://$EMQX_HOST:18083/api/v5/plugins/my_emqx_plugin-1.0.0/start" curl -s -u $KEY:$SECRET -X PUT "http://$EMQX_HOST:18083/api/v5/plugins/my_emqx_plugin-1.0.0/stop" ``` ``` -------------------------------- ### Run Kotlin MCP Server Example Source: https://docs.emqx.com/en/emqx/latest/emqx-ai/sdks/mcp-sdk-kotlin.html Starts the MCP server example using Gradle. Specify the MQTT client ID and MCP server name as arguments. ```bash ./gradlew run --args="--mqtt kt001 demo/kotlin-mcp-server" ``` -------------------------------- ### Start EMQX in foreground Source: https://docs.emqx.com/en/emqx/latest/deploy/install-debian.html Start EMQX in the foreground after installing with a tar.gz archive. This is useful for development or debugging. ```bash ./emqx/bin/emqx foreground ``` -------------------------------- ### Start EMQX using systemd Source: https://docs.emqx.com/en/emqx/latest/deploy/install-debian.html Use this command to start EMQX as a systemd service after installation with a deb package. ```bash sudo systemctl start emqx ``` -------------------------------- ### Example Node Evacuation Command Source: https://docs.emqx.com/en/emqx/latest/deploy/cluster/rebalancing.html This example demonstrates starting node evacuation, migrating clients from 'emqx@127.0.0.1' to 'emqx2@127.0.0.1' and 'emqx3@127.0.0.1'. It specifies custom rates for connection and session eviction, and a takeover wait time. ```bash ./bin/emqx ctl rebalance start --evacuation \ --wait-health-check 60 \ --wait-takeover 200 \ --conn-evict-rate 30 \ --sess-evict-rate 30 \ --migrate-to "emqx2@127.0.0.1 emqx3@127.0.0.1" Rebalance(evacuation) started ``` -------------------------------- ### Clone Example Repository Source: https://docs.emqx.com/en/emqx/latest/deploy/cluster/lb-haproxy.html Clone the example repository to get the Docker Compose configuration for HAProxy and EMQX load balancing. ```bash git clone https://github.com/emqx/emqx-usage-example cd emqx-usage-example/mqtt-lb-haproxy ``` -------------------------------- ### List All Gateways Source: https://docs.emqx.com/en/emqx/latest/admin/cli.html Lists all configured gateways along with their status, client count, and start time. The example shows a sample output with multiple gateways. ```bash $ emqx ctl gateway list Gateway(name=coap, status=running, clients=0, started_at=2023-05-22T14:23:50.353+08:00) Gateway(name=exproto, status=unloaded) Gateway(name=lwm2m, status=unloaded) Gateway(name=mqttsn, status=unloaded) Gateway(name=stomp, status=unloaded) ``` -------------------------------- ### Install and Run PostgreSQL Docker Image Source: https://docs.emqx.com/en/emqx/latest/data-integration/data-bridge-pgsql.html Starts a PostgreSQL Docker container and sets a password. Accesses the container and connects to the PostgreSQL server to create a database. ```bash # To start the PostgreSQL docker image and set the password as public docker run --name PostgreSQL -p 5432:5432 -e POSTGRES_PASSWORD=public -d postgres # Access the container docker exec -it PostgreSQL bash # Locate the PostgreSQL server in the container and input the preset password psql -U postgres -W # Create and then select the database CREATE DATABASE emqx_data; \c emqx_data; ``` -------------------------------- ### Install and Run EMQX Enterprise with Docker Source: https://docs.emqx.com/en/emqx/latest/getting-started/getting-started.html Use this command to download and start the latest version of EMQX Enterprise. Ensure Docker is installed and running. Access the EMQX Dashboard at http://localhost:18083/. ```bash docker run -d --name emqx -p 1883:1883 -p 8083:8083 -p 8084:8084 -p 8883:8883 -p 18083:18083 emqx/emqx-enterprise:latest ``` -------------------------------- ### Install EMQX Helm Chart from GitHub Source: https://docs.emqx.com/en/emqx/latest/deploy/kubernetes/chart.html Install the EMQX Helm chart by cloning the repository and running the Helm install command. ```bash git clone https://github.com/emqx/emqx.git cd emqx/deploy/charts/emqx-enterprise helm install my-emqx . ``` -------------------------------- ### Subscribe to Topics with eMQTT-Bench Source: https://docs.emqx.com/en/emqx/latest/performance/benchmark-emqtt-bench.html Starts a specified number of clients to subscribe to a given topic. This example sets up 500 connections, each subscribing to the topic 't' with Qos0. ```bash ./emqtt_bench sub -t t -h emqx-server -c 500 ``` -------------------------------- ### Start EMQX with Environment Variable Source: https://docs.emqx.com/en/emqx/latest/data-integration/data-bridge-kafka.html Set environment variables for EMQX startup. Ensure variable names have the `EMQXVAR_` prefix. This example sets the Kafka topic name. ```bash EMQXVAR_KAFKA_TOPIC=testtopic-in bin/emqx start ``` -------------------------------- ### Install a Plugin with EMQX CLI Source: https://docs.emqx.com/en/emqx/latest/admin/cli.html Install a plugin package that is located in the plugin installation directory. Requires the plugin's name and version. ```bash emqx ctl plugins install emqx_auth_mnesia-3.0.1 ``` -------------------------------- ### Install EMQX Helm Chart from Helm Repository Source: https://docs.emqx.com/en/emqx/latest/deploy/kubernetes/chart.html Install the EMQX Helm chart from the official Helm repository by adding the repo and running the install command. ```bash helm repo add emqx https://repos.emqx.io/charts helm install my-emqx emqx/emqx-enterprise ``` -------------------------------- ### Start Gateway Source: https://docs.emqx.com/en/emqx/latest/admin/cli.html Starts a specified gateway. The example shows starting the 'coap' gateway. ```bash $ emqx ctl gateway start coap ok ``` -------------------------------- ### Initialize Demo Project (Bash) Source: https://docs.emqx.com/en/emqx/latest/emqx-ai/sdks/mcp-sdk-python.html Creates a new project directory and navigates into it using uv for managing dependencies. ```bash uv init mcp_over_mqtt_demo cd mcp_over_mqtt_demo ``` -------------------------------- ### Set Up emqx-ft Client Environment Source: https://docs.emqx.com/en/emqx/latest/file-transfer/quick-start.html Clone the `emqx-ft` repository, create a virtual environment, and install the necessary dependencies to use the file transfer command-line tool. ```bash git clone https://github.com/emqx/emqx-ft.git cd emqx-ft python3 -m venv .venv source .venv/bin/activate pip install . ``` -------------------------------- ### Install Node-RED via NPM Source: https://docs.emqx.com/en/emqx/latest/connect-emqx/node-red.html Installs Node-RED globally using npm. Ensure Node.js LTS is installed. After installation, run 'node-red' to start the editor. ```bash npm install -g --unsafe-perm node-red ``` ```bash node-red ``` -------------------------------- ### Verify Redis Installation Source: https://docs.emqx.com/en/emqx/latest/data-integration/data-bridge-redis.html Use the SET and GET commands to verify that Redis is installed and running correctly. ```bash 127.0.0.1:6379> set emqx "Hello World" OK 127.0.0.1:6379> get emqx "Hello World" ``` -------------------------------- ### EMQX Configuration Paths Examples Source: https://docs.emqx.com/en/emqx/latest/configuration/configuration.html Examples of how to reference configuration values using dot-separated paths for different settings. ```bash node.name = "emqx.127.0.0.1" zone.zone1.max_packet_size = "10M" authentication.1.enable = true ``` -------------------------------- ### Example $SYS Topic Paths Source: https://docs.emqx.com/en/emqx/latest/observability/mqtt-system-topics.html These are example topic paths for retrieving EMQX version and uptime information from a specific node. ```bash $SYS/brokers/emqx@127.0.0.1/version $SYS/brokers/emqx@127.0.0.1/uptime ``` -------------------------------- ### Install Datalayers using Docker Source: https://docs.emqx.com/en/emqx/latest/data-integration/data-bridge-datalayers.html Use this command to install and start Datalayers using Docker. Refer to the official Datalayers documentation for detailed installation steps. ```bash docker run -d --name datalayers -p 8080:8080 -p 9092:9092 -p 5432:5432 -p 8081:8081 -p 8082:8082 -p 8083:8083 -p 8084:8084 -p 8085:8085 -p 8086:8086 -p 8087:8087 -p 8088:8088 -p 8089:8089 -p 8090:8090 -p 8091:8091 -p 8092:8092 -p 8093:8093 -p 8094:8094 -p 8095:8095 -p 8096:8096 -p 8097:8097 -p 8098:8098 -p 8099:8099 -p 9100:9100 -p 9101:9101 -p 9102:9102 -p 9103:9103 -p 9104:9104 -p 9105:9105 -p 9106:9106 -p 9107:9107 -p 9108:9108 -p 9109:9109 -p 9110:9110 -p 9111:9111 -p 9112:9112 -p 9113:9113 -p 9114:9114 -p 9115:9115 -p 9116:9116 -p 9117:9117 -p 9118:9118 -p 9119:9119 -p 9120:9120 -p 9121:9121 -p 9122:9122 -p 9123:9123 -p 9124:9124 -p 9125:9125 -p 9126:9126 -p 9127:9127 -p 9128:9128 -p 9129:9129 -p 9130:9130 -p 9131:9131 -p 9132:9132 -p 9133:9133 -p 9134:9134 -p 9135:9135 -p 9136:9136 -p 9137:9137 -p 9138:9138 -p 9139:9139 -p 9140:9140 -p 9141:9141 -p 9142:9142 -p 9143:9143 -p 9144:9144 -p 9145:9145 -p 9146:9146 -p 9147:9147 -p 9148:9148 -p 9149:9149 -p 9150:9150 -p 9151:9151 -p 9152:9152 -p 9153:9153 -p 9154:9154 -p 9155:9155 -p 9156:9156 -p 9157:9157 -p 9158:9158 -p 9159:9159 -p 9160:9160 -p 9161:9161 -p 9162:9162 -p 9163:9163 -p 9164:9164 -p 9165:9165 -p 9166:9166 -p 9167:9167 -p 9168:9168 -p 9169:9169 -p 9170:9170 -p 9171:9171 -p 9172:9172 -p 9173:9173 -p 9174:9174 -p 9175:9175 -p 9176:9176 -p 9177:9177 -p 9178:9178 -p 9179:9179 -p 9180:9180 -p 9181:9181 -p 9182:9182 -p 9183:9183 -p 9184:9184 -p 9185:9185 -p 9186:9186 -p 9187:9187 -p 9188:9188 -p 9189:9189 -p 9190:9190 -p 9191:9191 -p 9192:9192 -p 9193:9193 -p 9194:9194 -p 9195:9195 -p 9196:9196 -p 9197:9197 -p 9198:9198 -p 9199:9199 -p 9200:9200 -p 9201:9201 -p 9202:9202 -p 9203:9203 -p 9204:9204 -p 9205:9205 -p 9206:9206 -p 9207:9207 -p 9208:9208 -p 9209:9209 -p 9210:9210 -p 9211:9211 -p 9212:9212 -p 9213:9213 -p 9214:9214 -p 9215:9215 -p 9216:9216 -p 9217:9217 -p 9218:9218 -p 9219:9219 -p 9220:9220 -p 9221:9221 -p 9222:9222 -p 9223:9223 -p 9224:9224 -p 9225:9225 -p 9226:9226 -p 9227:9227 -p 9228:9228 -p 9229:9229 -p 9230:9230 -p 9231:9231 -p 9232:9232 -p 9233:9233 -p 9234:9234 -p 9235:9235 -p 9236:9236 -p 9237:9237 -p 9238:9238 -p 9239:9239 -p 9240:9240 -p 9241:9241 -p 9242:9242 -p 9243:9243 -p 9244:9244 -p 9245:9245 -p 9246:9246 -p 9247:9247 -p 9248:9248 -p 9249:9249 -p 9250:9250 -p 9251:9251 -p 9252:9252 -p 9253:9253 -p 9254:9254 -p 9255:9255 -p 9256:9256 -p 9257:9257 -p 9258:9258 -p 9259:9259 -p 9260:9260 -p 9261:9261 -p 9262:9262 -p 9263:9263 -p 9264:9264 -p 9265:9265 -p 9266:9266 -p 9267:9267 -p 9268:9268 -p 9269:9269 -p 9270:9270 -p 9271:9271 -p 9272:9272 -p 9273:9273 -p 9274:9274 -p 9275:9275 -p 9276:9276 -p 9277:9277 -p 9278:9278 -p 9279:9279 -p 9280:9280 -p 9281:9281 -p 9282:9282 -p 9283:9283 -p 9284:9284 -p 9285:9285 -p 9286:9286 -p 9287:9287 -p 9288:9288 -p 9289:9289 -p 9290:9290 -p 9291:9291 -p 9292:9292 -p 9293:9293 -p 9294:9294 -p 9295:9295 -p 9296:9296 -p 9297:9297 -p 9298:9298 -p 9299:9299 -p 9300:9300 -p 9301:9301 -p 9302:9302 -p 9303:9303 -p 9304:9304 -p 9305:9305 -p 9306:9306 -p 9307:9307 -p 9308:9308 -p 9309:9309 -p 9310:9310 -p 9311:9311 -p 9312:9312 -p 9313:9313 -p 9314:9314 -p 9315:9315 -p 9316:9316 -p 9317:9317 -p 9318:9318 -p 9319:9319 -p 9320:9320 -p 9321:9321 -p 9322:9322 -p 9323:9323 -p 9324:9324 -p 9325:9325 -p 9326:9326 -p 9327:9327 -p 9328:9328 -p 9329:9329 -p 9330:9330 -p 9331:9331 -p 9332:9332 -p 9333:9333 -p 9334:9334 -p 9335:9335 -p 9336:9336 -p 9337:9337 -p 9338:9338 -p 9339:9339 -p 9340:9340 -p 9341:9341 -p 9342:9342 -p 9343:9343 -p 9344:9344 -p 9345:9345 -p 9346:9346 -p 9347:9347 -p 9348:9348 -p 9349:9349 -p 9350:9350 -p 9351:9351 -p 9352:9352 -p 9353:9353 -p 9354:9354 -p 9355:9355 -p 9356:9356 -p 9357:9357 -p 9358:9358 -p 9359:9359 -p 9360:9360 -p 9361:9361 -p 9362:9362 -p 9363:9363 -p 9364:9364 -p 9365:9365 -p 9366:9366 -p 9367:9367 -p 9368:9368 -p 9369:9369 -p 9370:9370 -p 9371:9371 -p 9372:9372 -p 9373:9373 -p 9374:9374 -p 9375:9375 -p 9376:9376 -p 9377:9377 -p 9378:9378 -p 9379:9379 -p 9380:9380 -p 9381:9381 -p 9382:9382 -p 9383:9383 -p 9384:9384 -p 9385:9385 -p 9386:9386 -p 9387:9387 -p 9388:9388 -p 9389:9389 -p 9390:9390 -p 9391:9391 -p 9392:9392 -p 9393:9393 -p 9394:9394 -p 9395:9395 -p 9396:9396 -p 9397:9397 -p 9398:9398 -p 9399:9399 -p 9400:9400 -p 9401:9401 -p 9402:9402 -p 9403:9403 -p 9404:9404 -p 9405:9405 -p 9406:9406 -p 9407:9407 -p 9408:9408 -p 9409:9409 -p 9410:9410 -p 9411:9411 -p 9412:9412 -p 9413:9413 -p 9414:9414 -p 9415:9415 -p 9416:9416 -p 9417:9417 -p 9418:9418 -p 9419:9419 -p 9420:9420 -p 9421:9421 -p 9422:9422 -p 9423:9423 -p 9424:9424 -p 9425:9425 -p 9426:9426 -p 9427:9427 -p 9428:9428 -p 9429:9429 -p 9430:9430 -p 9431:9431 -p 9432:9432 -p 9433:9433 -p 9434:9434 -p 9435:9435 -p 9436:9436 -p 9437:9437 -p 9438:9438 -p 9439:9439 -p 9440:9440 -p 9441:9441 -p 9442:9442 -p 9443:9443 -p 9444:9444 -p 9445:9445 -p 9446:9446 -p 9447:9447 -p 9448:9448 -p 9449:9449 -p 9450:9450 -p 9451:9451 -p 9452:9452 -p 9453:9453 -p 9454:9454 -p 9455:9455 -p 9456:9456 -p 9457:9457 -p 9458:9458 -p 9459:9459 -p 9460:9460 -p 9461:9461 -p 9462:9462 -p 9463:9463 -p 9464:9464 -p 9465:9465 -p 9466:9466 -p 9467:9467 -p 9468:9468 -p 9469:9469 -p 9470:9470 -p 9471:9471 -p 9472:9472 -p 9473:9473 -p 9474:9474 -p 9475:9475 -p 9476:9476 -p 9477:9477 -p 9478:9478 -p 9479:9479 -p 9480:9480 -p 9481:9481 -p 9482:9482 -p 9483:9483 -p 9484:9484 -p 9485:9485 -p 9486:9486 -p 9487:9487 -p 9488:9488 -p 9489:9489 -p 9490:9490 -p 9491:9491 -p 9492:9492 -p 9493:9493 -p 9494:9494 -p 9495:9495 -p 9496:9496 -p 9497:9497 -p 9498:9498 -p 9499:9499 -p 9500:9500 -p 9501:9501 -p 9502:9502 -p 9503:9503 -p 9504:9504 -p 9505:9505 -p 9506:9506 -p 9507:9507 -p 9508:9508 -p 9509:9509 -p 9510:9510 -p 9511:9511 -p 9512:9512 -p 9513:9513 -p 9514:9514 -p 9515:9515 -p 9516:9516 -p 9517:9517 -p 9518:9518 -p 9519:9519 -p 9520:9520 -p 9521:9521 -p 9522:9522 -p 9523:9523 -p 9524:9524 -p 9525:9525 -p 9526:9526 -p 9527:9527 -p 9528:9528 -p 9529:9529 -p 9530:9530 -p 9531:9531 -p 9532:9532 -p 9533:9533 -p 9534:9534 -p 9535:9535 -p 9536:9536 -p 9537:9537 -p 9538:9538 -p 9539:9539 -p 9540:9540 -p 9541:9541 -p 9542:9542 -p 9543:9543 -p 9544:9544 -p 9545:9545 -p 9546:9546 -p 9547:9547 -p 9548:9548 -p 9549:9549 -p 9550:9550 -p 9551:9551 -p 9552:9552 -p 9553:9553 -p 9554:9554 -p 9555:9555 -p 9556:9556 -p 9557:9557 -p 9558:9558 -p 9559:9559 -p 9560:9560 -p 9561:9561 -p 9562:9562 -p 9563:9563 -p 9564:9564 -p 9565:9565 -p 9566:9566 -p 9567:9567 -p 9568:9568 -p 9569:9569 -p 9570:9570 -p 9571:9571 -p 9572:9572 -p 9573:9573 -p 9574:9574 -p 9575:9575 -p 9576:9576 -p 9577:9577 -p 9578:9578 -p 9579:9579 -p 9580:9580 -p 9581:9581 -p 9582:9582 -p 9583:9583 -p 9584:9584 -p 9585:9585 -p 9586:9586 -p 9587:9587 -p 9588:9588 -p 9589:9589 -p 9590:9590 -p 9591:9591 -p 9592:9592 -p 9593:9593 -p 9594:9594 -p 9595:9595 -p 9596:9596 -p 9597:9597 -p 9598:9598 -p 9599:9599 -p 9600:9600 -p 9601:9601 -p 9602:9602 -p 9603:9603 -p 9604:9604 -p 9605:9605 -p 9606:9606 -p 9607:9607 -p 9608:9608 -p 9609:9609 -p 9610:9610 -p 9611:9611 -p 9612:9612 -p 9613:9613 -p 9614:9614 -p 9615:9615 -p 9616:9616 -p 9617:9617 -p 9618:9618 -p 9619:9619 -p 9620:9620 -p 9621:9621 -p 9622:9622 -p 9623:9623 -p 9624:9624 -p 9625:9625 -p 9626:9626 -p 9627:9627 -p 9628:9628 -p 9629:9629 -p 9630:9630 -p 9631:9631 -p 9632:9632 -p 9633:9633 -p 9634:9634 -p 9635:9635 -p 9636:9636 -p 9637:9637 -p 9638:9638 -p 9639:9639 -p 9640:9640 -p 9641:9641 -p 9642:9642 -p 9643:9643 -p 9644:9644 -p 9645:9645 -p 9646:9646 -p 9647:9647 -p 9648:9648 -p 9649:9649 -p 9650:9650 -p 9651:9651 -p 9652:9652 -p 9653:9653 -p 9654:9654 -p 9655:9655 -p 9656:9656 -p 9657:9657 -p 9658:9658 -p 9659:9659 -p 9660:9660 -p 9661:9661 -p 9662:9662 -p 9663:9663 -p 9664:9664 -p 9665:9665 -p 9666:9666 -p 9667:9667 -p 9668:9668 -p 9669:9669 -p 9670:9670 -p 9671:9671 -p 9672:9672 -p 9673:9673 -p 9674:9674 -p 9675:9675 -p 9676:9676 -p 9677:9677 -p 9678:9678 -p 9679:9679 -p 9680:9680 -p 9681:9681 -p 9682:9682 -p 9683:9683 -p 9684:9684 -p 9685:9685 -p 9686:9686 -p 9687:9687 -p 9688:9688 -p 9689:9689 -p 9690:9690 -p 9691:9691 -p 9692:9692 -p 9693:9693 -p 9694:9694 -p 9695:9695 -p 9696:9696 -p 9697:9697 -p 9698:9698 -p 9699:9699 -p 9700:9700 -p 9701:9701 -p 9702:9702 -p 9703:9703 -p 9704:9704 -p 9705:9705 -p 9706:9706 -p 9707:9707 -p 9708:9708 -p 9709:9709 -p 9710:9710 -p 9711:9711 -p 9712:9712 -p 9713:9713 -p 9714:9714 -p 9715:9715 -p 9716:9716 -p 9717:9717 -p 9718:9718 -p 9719:9719 -p 9720:9720 -p 9721:9721 -p 9722:9722 -p 9723:9723 -p 9724:9724 -p 9725:9725 -p 9726:9726 -p 9727:9727 -p 9728:9728 -p 9729:9729 -p 9730:9730 -p 9731:9731 -p 9732:9732 -p 9733:9733 -p 9734:9734 -p 9735:9735 -p 9736:9736 -p 9737:9737 -p 9738:9738 -p 9739:9739 -p 9740:9740 -p 9741:9741 -p 9742:9742 -p 9743:9743 -p 9744:9744 -p 9745:9745 -p 9746:9746 -p 9747:9747 -p 9748:9748 -p 9749:9749 -p 9750:9750 -p 9751:9751 -p 9752:9752 -p 9753:9753 -p 9754:9754 -p 9755:9755 -p 9756:9756 -p 9757:9757 -p 9758:9758 -p 9759:9759 -p 9760:9760 -p 9761:9761 -p 9762:9762 -p 9763:9763 -p 9764:9764 -p 9765:9765 -p 9766:9766 -p 9767:9767 -p 9768:9768 -p 9769:9769 -p 9770:9770 -p 9771:9771 -p 9772:9772 -p 9773:9773 -p 9774:9774 -p 9775:9775 -p 9776:9776 -p 9777:9777 -p 9778:9778 -p 9779:9779 -p 9780:9780 -p 9781:9781 -p 9782:9782 -p 9783:9783 -p 9784:9784 -p 9785:9785 -p 9786:9786 -p 9787:9787 -p 9788:9788 -p 9789:9789 -p 9790:9790 -p 9791:9791 -p 9792:9792 -p 9793:9793 -p 9794:9794 -p 9795:9795 -p 9796:9796 -p 9797:9797 -p 9798:9798 -p 9799:9799 -p 9800:9800 -p 9801:9801 -p 9802:9802 -p 9803:9803 -p 9804:9804 -p 9805:9805 -p 9806:9806 -p 9807:9807 -p 9808:9808 -p 9809:9809 -p 9810:9810 -p 9811:9811 -p 9812:9812 -p 9813:9813 -p 9814:9814 -p 9815:9815 -p 9816:9816 -p 9817:9817 -p 9818:9818 -p 9819:9819 -p 9820:9820 -p 9821:9821 -p 9822:9822 -p 9823:9823 -p 9824:9824 -p 9825:9825 -p 9826:9826 -p 9827:9827 -p 9828:9828 -p 9829:9829 -p 9830:9830 -p 9831:9831 -p 9832:9832 -p 9833:9833 -p 9834:9834 -p 9835:9835 -p 9836:9836 -p 9837:9837 -p 9838:9838 -p 9839:9839 -p 9840:9840 -p 9841:9841 -p 9842:9842 -p 9843:9843 -p 9844:9844 -p 9845:9845 -p 9846:9846 -p 9847:9847 -p 9848:9848 -p 9849:9849 -p 9850:9850 -p 9851:9851 -p 9852:9852 -p 9853:9853 -p 9854:9854 -p 9855:9855 -p 9856:9856 -p 9857:9857 -p 9858:9858 -p 9859:9859 -p 9860:9860 -p 9861:9861 -p 9862:9862 -p 9863:9663 -p 9864:9864 -p 9865:9865 -p 9866:9866 -p 9867:9867 -p 9868:9868 -p 9869:9869 -p 9870:9870 -p 9871:9871 -p 9872:9872 -p 9873:9873 -p 9874:9874 -p 9875:9875 -p 9876:9876 -p 9877:9877 -p 9878:9878 -p 9879:9879 -p 9880:9880 -p 9881:9881 -p 9882:9882 -p 9883:9883 -p 9884:9884 -p 9885:9885 -p 9886:9886 -p 9887:9887 -p 9888:9888 -p 9889:9889 -p 9890:9890 -p 9891:9891 -p 9892:9892 -p 9893:9893 -p 9894:9894 -p 9895:9895 -p 9896:9896 -p 9897:9897 -p 9898:9898 -p 9899:9899 -p 9900:9900 -p 9901:9901 -p 9902:9902 -p 9903:9903 -p 9904:9904 -p 9905:9905 -p 9906:9906 -p 9907:9907 -p 9908:9908 -p 9909:9909 -p 9910:9910 -p 9911:9911 -p 9912:9912 -p 9913:9913 -p 9914:9914 -p 9915:9915 -p 9916:9916 -p 9917:9917 -p 9918:9918 -p 9919:9919 -p 9920:9920 -p 9921:9921 -p 9922:9922 -p 9923:9923 -p 9924:9924 -p 9925:9925 -p 9926:9926 -p 9927:9927 -p 9928:9928 -p 9929:9929 -p 9930:9930 -p 9931:9931 -p 9932:9932 -p 9933:9933 -p 9934:9934 -p 9935:9935 -p 9936:9936 -p 9937:9937 -p 9938:9938 -p 9939:9939 -p 9940:9940 -p 9941:9941 -p 9942:9942 -p 9943:9943 -p 9944:9944 -p 9945:9945 -p 9946:9946 -p 9947:9947 -p 9948:9948 -p 9949:9949 -p 9950:9950 -p 9951:9951 -p 9952:9952 -p 9953:9953 -p 9954:9954 -p 9955:9955 -p 9956:9956 -p 9957:9957 -p 9958:9958 -p 9959:9959 -p 9960:9960 -p 9961:9961 -p 9962:9962 -p 9963:9963 -p 9964:9964 -p 9965:9965 -p 9966:9966 -p 9967:9967 -p 9968:9968 -p 9969:9969 -p 9970:9970 -p 9971:9971 -p 9972:9972 -p 9973:9973 -p 9974:9974 -p 9975:9975 -p 9976:9976 -p 9977:9977 -p 9978:9978 -p 9979:9979 -p 9980:9980 -p 9981:9981 -p 9982:9982 -p 9983:9983 -p 9984:9984 -p 9985:9985 -p 9986:9986 -p 9987:9987 -p 9988:9988 -p 9989:9989 -p 9990:9990 -p 9991:9991 -p 9992:9992 -p 9993:9993 -p 9994:9994 -p 9995:9995 -p 9996:9996 -p 9997:9997 -p 9998:9998 -p 9999:9999 -p 10000:10000 datalayers/datalayers:latest ``` -------------------------------- ### Initialize MCP Server with Tools and Resources (Python) Source: https://docs.emqx.com/en/emqx/latest/emqx-ai/sdks/mcp-sdk-python.html Sets up a FastMCP server, exposing an addition tool and a dynamic greeting resource. Configure MQTT broker details and logging level. ```python # demo_mcp_server.py from mcp.server.fastmcp import FastMCP # Create an MCP server mcp = FastMCP( "demo_mcp_server/calculator", log_level="DEBUG", mqtt_server_description="A simple FastMCP server that exposes a calculator tool", mqtt_options={ "host": "broker.emqx.io", }, ) # Add an addition tool @mcp.tool() def add(a: int, b: int) -> int: """Add two numbers""" return a + b # Add a dynamic greeting resource @mcp.resource("greeting://{name}") def get_greeting(name: str) -> str: """Get a personalized greeting""" return f"Hello, {name}!" ``` -------------------------------- ### Start EMQX in Daemon Mode Source: https://docs.emqx.com/en/emqx/latest/deploy/install-macOS.html Use this command to start EMQX in the background. Ensure you are in the EMQX installation directory. ```bash ./bin/emqx start ``` -------------------------------- ### Start a Plugin with EMQX CLI Source: https://docs.emqx.com/en/emqx/latest/admin/cli.html Start a specified plugin. Requires the plugin's name and version. ```bash emqx ctl plugins start emqx_auth_mnesia-3.0.1 ``` -------------------------------- ### Stop EMQX with Installation Package Source: https://docs.emqx.com/en/emqx/latest/getting-started/getting-started.html Use this command to stop a running EMQX instance that was started with an installation package. ```bash ./emqx/bin/emqx stop ``` -------------------------------- ### Clone Example Code and Navigate Directory Source: https://docs.emqx.com/en/emqx/latest/gateway/exproto.html Clone the emqx-extension-examples repository and navigate into the Python gRPC server directory. This provides the necessary server code. ```bash git clone https://github.com/emqx/emqx-extension-examples cd exproto-svr-python ``` -------------------------------- ### Install gRPC Dependencies Source: https://docs.emqx.com/en/emqx/latest/gateway/exproto.html Install the necessary gRPC libraries for Python. These are required to run the example gRPC server. ```bash python -m pip install grpcio python -m pip install grpcio-tools ``` -------------------------------- ### Start TDengine Docker and Create Database Source: https://docs.emqx.com/en/emqx/latest/data-integration/data-bridge-tdengine.html Use these commands to start a TDengine Docker container, access its shell, and create the 'mqtt' database. ```bash # To start the TDengine docker image docker run --name TDengine -p 6041:6041 tdengine/tdengine # Access the container docker exec -it TDengine bash # Locate the TDengine server in the container taos # Create and then select the database CREATE DATABASE mqtt; use mqtt; ```