{"id":35013591,"url":"https://github.com/ezhuk/modbus-mcp","last_synced_at":"2026-02-28T04:56:56.171Z","repository":{"id":293757271,"uuid":"982496184","full_name":"ezhuk/modbus-mcp","owner":"ezhuk","description":"A Model Context Protocol (MCP) server for Modbus.","archived":false,"fork":false,"pushed_at":"2026-01-13T02:00:02.000Z","size":1005,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-13T05:22:25.410Z","etag":null,"topics":["mcp","mcp-server","modbus"],"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-13T01:24:04.000Z","updated_at":"2026-01-13T02:00:00.000Z","dependencies_parsed_at":"2025-05-17T01:27:47.854Z","dependency_job_id":"2c83134f-9df6-492c-94f2-0f29bdc3ee6a","html_url":"https://github.com/ezhuk/modbus-mcp","commit_stats":null,"previous_names":["ezhuk/modbus-mcp"],"tags_count":41,"template":false,"template_full_name":null,"purl":"pkg:github/ezhuk/modbus-mcp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezhuk%2Fmodbus-mcp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezhuk%2Fmodbus-mcp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezhuk%2Fmodbus-mcp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezhuk%2Fmodbus-mcp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ezhuk","download_url":"https://codeload.github.com/ezhuk/modbus-mcp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezhuk%2Fmodbus-mcp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28483402,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: 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","modbus"],"created_at":"2025-12-27T05:07:48.694Z","updated_at":"2026-01-16T21:39:25.699Z","avatar_url":"https://github.com/ezhuk.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Modbus MCP Server\n\n[![test](https://github.com/ezhuk/modbus-mcp/actions/workflows/test.yml/badge.svg)](https://github.com/ezhuk/modbus-mcp/actions/workflows/test.yml)\n[![codecov](https://codecov.io/github/ezhuk/modbus-mcp/graph/badge.svg?token=RCKEZAJGXX)](https://codecov.io/github/ezhuk/modbus-mcp)\n[![PyPI - Version](https://img.shields.io/pypi/v/modbus-mcp.svg)](https://pypi.org/p/modbus-mcp)\n\nA lightweight [Model Context Protocol (MCP)](https://modelcontextprotocol.io) server that connects LLM agents to [Modbus](https://en.wikipedia.org/wiki/Modbus) devices in a secure, standardized way, enabling seamless integration of AI-driven workflows with Building Automation (BAS) and Industrial Control (ICS) systems, allowing agents to monitor real-time sensor data, actuate devices, and orchestrate complex automation tasks.\n\n## Getting Started\n\nUse [uv](https://github.com/astral-sh/uv) to add and manage the Modbus 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/modbus-mcp/blob/main/docs/modbus-mcp/installation.mdx) section of the documentation for full installation instructions and more details.\n\n```bash\nuv add modbus-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 modbus_mcp import ModbusMCP\n\nmcp = ModbusMCP()\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\nmodbus-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 modbus-mcp\n```\n\n### Configuration\n\nFor the use cases where most operations target a specific device, such as a Programmable Logic Controller (PLC) or Modbus gateway, its connection settings (`host`, `port`, and `unit`) can be specified at runtime using environment variables so that all prompts that omit explicit connection parameters will be routed to this device.\n\n```bash\nexport MODBUS_MCP_MODBUS__HOST=10.0.0.1\nexport MODBUS_MCP_MODBUS__PORT=502\nexport MODBUS_MCP_MODBUS__UNIT=1\n```\n\nThese settings can also be specified in a `.env` file in the working directory.\n\n```text\n# .env\nmodbus_mcp_modbus__host=10.0.0.1\nmodbus_mcp_modbus__port=502\nmodbus_mcp_modbus__unit=1\n```\n\nWhen interacting with multiple devices, each device’s connection parameters (`host`, `port`, `unit`) can be defined with a unique `name` in a `devices.json` file in the working directory. Prompts can then refer to devices by `name`.\n\n```json\n{\n  \"devices\": [\n    {\"name\": \"Boiler\", \"host\": \"10.0.0.3\", \"port\": 503, \"unit\": 3},\n    {\"name\": \"Valve\", \"host\": \"10.0.0.4\", \"port\": 504, \"unit\": 4}\n  ]\n}\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 Modbus 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/e3673921-0396-4561-8640-884e9cef609a)\n\n## Core Concepts\n\nThe Modbus MCP server is built with [FastMCP 2.0](https://github.com/jlowin/fastmcp) and leverages its core building blocks - resource templates, tools, and prompts - to streamline Modbus read and write operations with minimal boilerplate and a clean, Pythonic interface.\n\n### Read Registers\n\nEach register 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, unit) and read parameters (address, count).\n\n```python\n@mcp.resource(\"tcp://{host}:{port}/{address}?count={count}\u0026unit={unit}\")\n@mcp.tool(\n    annotations={\"title\": \"Read Registers\", \"readOnlyHint\": True, \"openWorldHint\": True}\n)\nasync def read_registers(\n    host: str = settings.modbus.host,\n    port: int = settings.modbus.port,\n    address: int = 40001,\n    count: int = 1,\n    unit: int = settings.modbus.unit,\n) -\u003e int | list[int]:\n    \"\"\"Reads the contents of one or more registers on a remote unit.\"\"\"\n    ...\n```\n\n### Write Registers\n\nWrite operations are exposed as a [tool](https://gofastmcp.com/servers/tools), accepting the same connection details (host, port, unit) and allowing to set the contents of one or more `holding registers` or `coils` in a single, atomic call.\n\n```python\n@mcp.tool(\n    annotations={\n        \"title\": \"Write Registers\",\n        \"readOnlyHint\": False,\n        \"openWorldHint\": True,\n    }\n)\nasync def write_registers(\n    data: list[int],\n    host: str = settings.modbus.host,\n    port: int = settings.modbus.port,\n    address: int = 40001,\n    unit: int = settings.modbus.unit,\n) -\u003e str:\n    \"\"\"Writes data to one or more registers on a remote unit.\"\"\"\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=\"modbus_help\", tags={\"modbus\", \"help\"})\ndef modbus_help() -\u003e list[Message]:\n    \"\"\"Provides examples of how to use the Modbus MCP server.\"\"\"\n    ...\n```\n\nHere are some example text inputs that can be used to interact with the server.\n\n```text\nPlease read the value of register 40001 on 127.0.0.1:502.\nSet register 40005 to 123 on host 192.168.1.10, unit 3.\nWrite [1, 2, 3] to holding registers starting at address 40010.\nWhat is the status of input register 30010 on 10.0.0.5?\n```\n\n## Examples\n\nThe `examples` folder contains sample projects showing how to integrate with the Modbus MCP server using various client APIs to provide tools and context to LLMs.\n\n- [openai-agents](https://github.com/ezhuk/modbus-mcp/tree/main/examples/openai-agents) - shows how to connect to the Modbus MCP server using the [OpenAI Agents SDK](https://openai.github.io/openai-agents-python/mcp/).\n- [openai](https://github.com/ezhuk/modbus-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/modbus-mcp/tree/main/examples/pydantic-ai) - shows how to connect to the Modbus MCP server using the [PydanticAI Agent Framework](https://ai.pydantic.dev).\n\n## Docker\n\nThe Modbus MCP server can be deployed as a Docker container as follows:\n\n```bash\ndocker run -d \\\n  --name modbus-mcp \\\n  --restart=always \\\n  -p 8080:8000 \\\n  --env-file .env \\\n  ghcr.io/ezhuk/modbus-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/modbus-mcp?tab=MIT-1-ov-file).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fezhuk%2Fmodbus-mcp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fezhuk%2Fmodbus-mcp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fezhuk%2Fmodbus-mcp/lists"}