A Model Context Protocol (MCP) server for BACnet.
Project description
BACnet MCP Server
A lightweight Model Context Protocol (MCP) server that connects LLM agents to BACnet devices in a secure, standardized way, enabling seamless integration of AI-driven workflows with Building Automation (BAS), Building Management (BMS) and Industrial Control (ICS) systems, allowing agents to monitor real-time sensor data, actuate devices, and orchestrate complex automation tasks.
Getting Started
The server is built with FastMCP 2.0 and uses uv for project and dependency management. Simply run the following command to install uv or check out the installation guide for more details and alternative installation methods.
curl -LsSf https://astral.sh/uv/install.sh | sh
Clone the repository, then use uv to install project dependencies and create a virtual environment.
git clone https://github.com/ezhuk/bacnet-mcp.git
cd bacnet-mcp
uv sync
Start the BACnet MCP server by running the following command in your terminal. It defaults to using the Streamable HTTP transport on port 8000.
uv run bacnet-mcp
To confirm the server is up and running and explore available resources and tools, run the MCP Inspector and connect it to the BACnet MCP server at http://127.0.0.1:8000/mcp/. Make sure to set the transport to Streamable HTTP.
npx @modelcontextprotocol/inspector
Core Concepts
The BACnet MCP server leverages FastMCP 2.0's core building blocks - resource templates, tools, and prompts - to streamline BACnet read and write operations with minimal boilerplate and a clean, Pythonic interface.
Read Properties
Each object on a device is mapped to a resource (and exposed as a tool) and resource templates are used to specify connection details (host, port) and read parameters (instance, property).
@mcp.resource("udp://{host}:{port}/{obj}/{instance}/{prop}")
@mcp.tool(
annotations={
"title": "Read Property",
"readOnlyHint": True,
"openWorldHint": True,
}
)
async def read_property(
host: str = settings.bacnet.host,
port: int = settings.bacnet.port,
obj: str = "analogValue",
instance: str = "1",
prop: str = "presentValue",
) -> str:
"""Reads the content of a BACnet object property on a remote unit."""
...
Write Properties
Write operations are exposed as a tool, accepting the same connection details (host, port) and allowing to set the content of an object property in a single, atomic call.
@mcp.tool(
annotations={
"title": "Write Property",
"readOnlyHint": False,
"openWorldHint": True,
}
)
async def write_property(
host: str = settings.bacnet.host,
port: int = settings.bacnet.port,
obj: str = "analogValue,1",
prop: str = "presentValue",
data: str = "1.0",
) -> str:
"""Writes a BACnet object property on a remote device."""
...
Authentication
To enable Bearer Token authentication for the Streamable HTTP transport, provide the RSA public key in PEM format in the .env file. Check out the Bearer Token Authentication section for more details.
Interactive Prompts
Structured response messages are implemented using prompts that help guide the interaction, clarify missing parameters, and handle errors gracefully.
@mcp.prompt(name="bacnet_help", tags={"bacnet", "help"})
def bacnet_help() -> list[Message]:
"""Provides examples of how to use the BACnet MCP server."""
...
Here are some example text inputs that can be used to interact with the server.
Read the presentValue property of analogInput,1 at 10.0.0.4.
Fetch the units property of analogInput 2.
Write the value 42 to analogValue instance 1.
Set the presentValue of binaryOutput 3 to True.
Examples
The examples folder contains sample projects showing how to integrate with the BACnet MCP server using various client APIs to provide tools and context to LLMs.
- openai-agents - shows how to connect to the BACnet MCP server using the OpenAI Agents SDK.
- openai - a minimal app leveraging remote MCP server support in the OpenAI Python library.
- pydantic-ai - shows how to connect to the BACnet MCP server using the PydanticAI Agent Framework.
Docker
The BACnet MCP server can be deployed as a Docker container as follows:
docker run -d \
--name bacnet-mcp \
--restart=always \
-p 8080:8000 \
--env-file .env \
ghcr.io/ezhuk/bacnet-mcp:latest
This 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.
License
The server is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bacnet_mcp-0.1.21.tar.gz.
File metadata
- Download URL: bacnet_mcp-0.1.21.tar.gz
- Upload date:
- Size: 68.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29ad2a0ef0a91994356ef184b48b6b9e3ec00d1dea26c2237bc7b13459192d5a
|
|
| MD5 |
933f9c54a34794b7f3cc165db472bfb7
|
|
| BLAKE2b-256 |
4d279f74168f0121d2d57cb62fd98a50cd303516df996af37c49f96a10219d2f
|
Provenance
The following attestation bundles were made for bacnet_mcp-0.1.21.tar.gz:
Publisher:
pypi.yml on ezhuk/bacnet-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bacnet_mcp-0.1.21.tar.gz -
Subject digest:
29ad2a0ef0a91994356ef184b48b6b9e3ec00d1dea26c2237bc7b13459192d5a - Sigstore transparency entry: 254284615
- Sigstore integration time:
-
Permalink:
ezhuk/bacnet-mcp@a2126462130e3f8b8b591d1965d1641c601d5dee -
Branch / Tag:
refs/tags/v0.1.21 - Owner: https://github.com/ezhuk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@a2126462130e3f8b8b591d1965d1641c601d5dee -
Trigger Event:
release
-
Statement type:
File details
Details for the file bacnet_mcp-0.1.21-py3-none-any.whl.
File metadata
- Download URL: bacnet_mcp-0.1.21-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de885cc8fe64d6f079053ce342a7b253c19352d4dd80c4015d131059362ca320
|
|
| MD5 |
de2f21beb2b52316648b009d460e34f0
|
|
| BLAKE2b-256 |
4a40159aaa0781daec07cb6e6567935844942d086281b6656391efafa59f57d5
|
Provenance
The following attestation bundles were made for bacnet_mcp-0.1.21-py3-none-any.whl:
Publisher:
pypi.yml on ezhuk/bacnet-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bacnet_mcp-0.1.21-py3-none-any.whl -
Subject digest:
de885cc8fe64d6f079053ce342a7b253c19352d4dd80c4015d131059362ca320 - Sigstore transparency entry: 254284621
- Sigstore integration time:
-
Permalink:
ezhuk/bacnet-mcp@a2126462130e3f8b8b591d1965d1641c601d5dee -
Branch / Tag:
refs/tags/v0.1.21 - Owner: https://github.com/ezhuk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@a2126462130e3f8b8b591d1965d1641c601d5dee -
Trigger Event:
release
-
Statement type: