IoT Home Automation MCP server

Enables smart home automation with IoT device control and persistent memory for maintaining context across interactions through MQTT protocol
Back to servers
Provider
Jordy Cuan
Release date
Apr 21, 2025
Language
Python
Stats
1 star

Model Context Protocol (MCP) servers provide standardized interfaces for IoT device control and memory management. They enable communication with smart devices and persistent memory storage through a consistent protocol, making them ideal for applications requiring device control or long-term data storage capabilities.

MCP Server Types

IoT Device Control MCP Server

This server offers a standardized interface for:

  • Home automation
  • Industrial IoT monitoring
  • Remote device management
  • Smart building control systems

Key features include:

  • Sending commands to IoT devices
  • Querying device state and status
  • Subscribing to real-time device updates
  • Support for MQTT protocol

Memory Management MCP Server

This server enables:

  • Conversation history storage
  • Knowledge management
  • Contextual awareness in AI applications
  • Persistent information storage

Key features include:

  • Information storage in long-term memory
  • Retrieval of all stored memories
  • Semantic search capabilities

Installation and Setup

Prerequisites

  • Python (recommended version 3.7+)
  • Pip package manager

Installation Steps

  1. Clone the repository:

    git clone https://github.com/username/mcp-servers.git
    cd mcp-servers
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Create a .env file with your configuration:

    cp .env.example .env
    
  4. Configure your environment variables in the .env file (see Configuration section)

Configuration

IoT MCP Server Environment Variables

MQTT_BROKER=localhost
MQTT_PORT=1883
HOST=0.0.0.0
PORT=8090
TRANSPORT=sse

Memory MCP Server Environment Variables

MEM0_API_KEY=your_api_key_here
MEM0_ENDPOINT=https://api.mem0.ai
HOST=0.0.0.0
PORT=8050
TRANSPORT=sse

Running the Servers

Starting the IoT MCP Server

python iot_mcp_server.py

Starting the Memory MCP Server

python memory_mcp_server.py

Using the IoT MCP Server

Available API Tools

  • send_command: Send a command to an IoT device
  • get_device_state: Get the current state of an IoT device
  • subscribe_to_updates: Subscribe to real-time updates from a device

Example Usage

To send a command to turn on a smart light:

import requests

response = requests.post("http://localhost:8090/mcp", json={
    "name": "send_command",
    "parameters": {
        "device_id": "light-001",
        "command": "turn_on",
        "parameters": {"brightness": 80}
    }
})
print(response.json())

To get the current state of a device:

import requests

response = requests.post("http://localhost:8090/mcp", json={
    "name": "get_device_state",
    "parameters": {
        "device_id": "thermostat-002"
    }
})
print(response.json())

Using the Memory MCP Server

Available API Tools

  • save_memory: Save information to long-term memory
  • get_all_memories: Get all stored memories for the user
  • search_memories: Search memories using semantic search

Example Usage

To save a memory:

import requests

response = requests.post("http://localhost:8050/mcp", json={
    "name": "save_memory",
    "parameters": {
        "user_id": "user123",
        "content": "The meeting is scheduled for March 15th at 2pm.",
        "tags": ["meeting", "schedule"]
    }
})
print(response.json())

To retrieve all memories for a user:

import requests

response = requests.post("http://localhost:8050/mcp", json={
    "name": "get_all_memories",
    "parameters": {
        "user_id": "user123"
    }
})
print(response.json())

To search memories using semantic search:

import requests

response = requests.post("http://localhost:8050/mcp", json={
    "name": "search_memories",
    "parameters": {
        "user_id": "user123",
        "query": "When is my next meeting?",
        "limit": 5
    }
})
print(response.json())

Troubleshooting

  • If you encounter connection issues with the IoT server, ensure your MQTT broker is running and accessible.
  • For Memory server issues, verify your Mem0 API key is valid and properly configured.
  • Check server logs for detailed error messages when troubleshooting.

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later