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.
This server offers a standardized interface for:
Key features include:
This server enables:
Key features include:
Clone the repository:
git clone https://github.com/username/mcp-servers.git
cd mcp-servers
Install dependencies:
pip install -r requirements.txt
Create a .env
file with your configuration:
cp .env.example .env
Configure your environment variables in the .env
file (see Configuration section)
MQTT_BROKER=localhost
MQTT_PORT=1883
HOST=0.0.0.0
PORT=8090
TRANSPORT=sse
MEM0_API_KEY=your_api_key_here
MEM0_ENDPOINT=https://api.mem0.ai
HOST=0.0.0.0
PORT=8050
TRANSPORT=sse
python iot_mcp_server.py
python memory_mcp_server.py
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())
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())
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.
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"
]
}
}
}
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.
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.