{"id":28838413,"url":"https://github.com/ezhuk/mqtt-mcp","last_synced_at":"2026-03-08T23:05:20.199Z","repository":{"id":294994311,"uuid":"986719722","full_name":"ezhuk/mqtt-mcp","owner":"ezhuk","description":"A Model Context Protocol (MCP) server for MQTT.","archived":false,"fork":false,"pushed_at":"2026-02-28T21:50:00.000Z","size":1006,"stargazers_count":9,"open_issues_count":1,"forks_count":7,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-01T00:48:30.083Z","etag":null,"topics":["mcp","mcp-server","mqtt"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ezhuk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-20T03:09:19.000Z","updated_at":"2026-02-28T21:49:40.000Z","dependencies_parsed_at":"2025-07-16T09:56:11.720Z","dependency_job_id":"ee1da80f-8d61-43a0-a0e4-f307e82f2c6f","html_url":"https://github.com/ezhuk/mqtt-mcp","commit_stats":null,"previous_names":["ezhuk/mqtt-mcp"],"tags_count":30,"template":false,"template_full_name":null,"purl":"pkg:github/ezhuk/mqtt-mcp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezhuk%2Fmqtt-mcp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezhuk%2Fmqtt-mcp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezhuk%2Fmqtt-mcp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezhuk%2Fmqtt-mcp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ezhuk","download_url":"https://codeload.github.com/ezhuk/mqtt-mcp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezhuk%2Fmqtt-mcp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30276607,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-08T20:45:49.896Z","status":"ssl_error","status_checked_at":"2026-03-08T20:45:49.525Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mcp","mcp-server","mqtt"],"created_at":"2025-06-19T13:02:49.674Z","updated_at":"2026-03-08T23:05:20.169Z","avatar_url":"https://github.com/ezhuk.png","language":"Python","funding_links":[],"categories":["🤖 AI/ML","Servers"],"sub_categories":["IoT \u0026 Home Automation"],"readme":"## MQTT MCP Server\n\nA lightweight [Model Context Protocol (MCP)](https://modelcontextprotocol.io) server that connects LLM agents to [MQTT](https://en.wikipedia.org/wiki/MQTT) devices in a secure, standardized way, enabling seamless integration of AI-driven workflows with Building Automation (BAS), Industrial Control (ICS) and Smart Home systems, allowing agents to monitor real-time sensor data, actuate devices, and orchestrate complex automation tasks.\n\n[![test](https://github.com/ezhuk/mqtt-mcp/actions/workflows/test.yml/badge.svg)](https://github.com/ezhuk/mqtt-mcp/actions/workflows/test.yml)\n[![codecov](https://codecov.io/github/ezhuk/mqtt-mcp/graph/badge.svg?token=EPF2SIV44I)](https://codecov.io/github/ezhuk/mqtt-mcp)\n[![PyPI - Version](https://img.shields.io/pypi/v/mqtt-mcp.svg)](https://pypi.org/p/mqtt-mcp)\n\n## Getting Started\n\nUse [uv](https://github.com/astral-sh/uv) to add and manage the MQTT MCP server as a dependency in your project, or install it directly via `uv pip install` or `pip install`. See the [Installation](https://github.com/ezhuk/mqtt-mcp/blob/main/docs/mqtt-mcp/installation.mdx) section of the documentation for full installation instructions and more details.\n\n```bash\nuv add mqtt-mcp\n```\n\nThe server can be embedded in and run directly from your application. By default, it exposes a `Streamable HTTP` endpoint at `http://127.0.0.1:8000/mcp/`.\n\n```python\n# app.py\nfrom mqtt_mcp import MQTTMCP\n\nmcp = MQTTMCP()\n\nif __name__ == \"__main__\":\n    mcp.run(transport=\"http\")\n```\n\nIt can also be launched from the command line using the provided `CLI` without modifying the source code.\n\n```bash\nmqtt-mcp\n```\n\nOr in an ephemeral, isolated environment using `uvx`. Check out the [Using tools](https://docs.astral.sh/uv/guides/tools/) guide for more details.\n\n```bash\nuvx mqtt-mcp\n```\n\n### Configuration\n\nFor the use cases where most operations target a specific MQTT broker its connection settings (`host` and `port`) can be specified at runtime using environment variables so that all prompts that omit explicit connection parameters will be routed to this broker.\n\n```bash\nexport MQTT_MCP_MQTT__HOST=10.0.0.1\nexport MQTT_MCP_MQTT__PORT=1883\n```\n\nThese settings can also be specified in a `.env` file in the working directory.\n\n```text\n# .env\nmqtt_mcp_mqtt__host=10.0.0.1\nmqtt_mcp_mqtt__port=1883\n```\n\n### MCP Inspector\n\nTo confirm the server is up and running and explore available resources and tools, run the [MCP Inspector](https://modelcontextprotocol.io/docs/tools/inspector) and connect it to the MQTT MCP server at `http://127.0.0.1:8000/mcp/`. Make sure to set the transport to `Streamable HTTP`.\n\n```bash\nnpx @modelcontextprotocol/inspector\n```\n\n![s01](https://github.com/user-attachments/assets/6ee711b2-994d-4a89-a088-13ad77b09b0e)\n\n## Core Concepts\n\nThe MQTT MCP server leverages FastMCP 2.0's core building blocks - resource templates, tools, and prompts - to streamline MQTT receive and publish operations with minimal boilerplate and a clean, Pythonic interface.\n\n### Receive Message\n\nEach topic on a device is mapped to a resource (and exposed as a tool) and [resource templates](https://gofastmcp.com/servers/resources#resource-templates) are used to specify connection details (host, port) and receive parameters (topic, timeout).\n\n```python\n@mcp.resource(\"mqtt://{host}:{port}/{topic*}\")\n@mcp.tool(\n    annotations={\n        \"title\": \"Receive Message\",\n        \"readOnlyHint\": True,\n        \"openWorldHint\": True,\n    }\n)\nasync def receive_message(\n    topic: str,\n    host: str = settings.mqtt.host,\n    port: int = settings.mqtt.port,\n    timeout: int = 60,\n) -\u003e str:\n    \"\"\"Receives a message published to the specified topic, if any.\"\"\"\n    ...\n```\n\n### Publish Message\n\nPublish operations are exposed as a [tool](https://gofastmcp.com/servers/tools), accepting the same connection details (host, port) and allowing to publish a message to a specific topic in a single, atomic call.\n\n```python\n@mcp.tool(\n    annotations={\n        \"title\": \"Publish Message\",\n        \"readOnlyHint\": False,\n        \"openWorldHint\": True,\n    }\n)\nasync def publish_message(\n    topic: str,\n    message: str,\n    host: str = settings.mqtt.host,\n    port: int = settings.mqtt.port,\n) -\u003e str:\n    \"\"\"Publishes a message to the specified topic.\"\"\"\n    ...\n```\n\n### Authentication\n\nTo enable authentication using the built-in [AuthKit](https://www.authkit.com) provider for the `Streamable HTTP` transport, provide the AuthKit domain and redirect URL in the `.env` file. Check out the [AuthKit Provider](https://gofastmcp.com/servers/auth/remote-oauth#example%3A-workos-authkit-provider) section for more details.\n\n### Interactive Prompts\n\nStructured response messages are implemented using [prompts](https://gofastmcp.com/servers/prompts) that help guide the interaction, clarify missing parameters, and handle errors gracefully.\n\n```python\n@mcp.prompt(name=\"mqtt_help\", tags={\"mqtt\", \"help\"})\ndef mqtt_help() -\u003e list[Message]:\n    \"\"\"Provides examples of how to use the MQTT MCP server.\"\"\"\n    ...\n```\n\nHere are some example text inputs that can be used to interact with the server.\n\n```text\nPublish {\"foo\":\"bar\"} to topic \"devices/foo\" on 127.0.0.1:1883.\nReceive a message from topic \"devices/bar\", waiting up to 30 seconds.\n```\n\n## Examples\n\nThe `examples` folder contains sample projects showing how to integrate with the MQTT MCP server using various client APIs to provide tools and context to LLMs.\n\n- [openai-agents](https://github.com/ezhuk/mqtt-mcp/tree/main/examples/openai-agents) - shows how to connect to the MQTT MCP server using the [OpenAI Agents SDK](https://openai.github.io/openai-agents-python/mcp/).\n- [openai](https://github.com/ezhuk/mqtt-mcp/tree/main/examples/openai) - a minimal app leveraging remote MCP server support in the [OpenAI Python library](https://platform.openai.com/docs/guides/tools-remote-mcp).\n- [pydantic-ai](https://github.com/ezhuk/mqtt-mcp/tree/main/examples/pydantic-ai) - shows how to connect to the MQTT MCP server using the [PydanticAI Agent Framework](https://ai.pydantic.dev).\n\n## Docker\n\nThe MQTT MCP server can be deployed as a Docker container as follows:\n\n```bash\ndocker run -dit \\\n  --name mqtt-mcp \\\n  --restart=always \\\n  -p 8080:8000 \\\n  --env-file .env \\\n  ghcr.io/ezhuk/mqtt-mcp:latest\n```\n\nThis maps port `8080` on the host to the MCP server's port `8000` inside the container and loads settings from the `.env` file, if present.\n\n## License\n\nThe server is licensed under the [MIT License](https://github.com/ezhuk/mqtt-mcp?tab=MIT-1-ov-file).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fezhuk%2Fmqtt-mcp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fezhuk%2Fmqtt-mcp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fezhuk%2Fmqtt-mcp/lists"}