Skip to main content

UnitMCP package for MCP hardware integration with Ollama LLM and Raspberry Pi hardware control.

Project description

MCP Hardware Project Summary

graph.svg

๐Ÿš€ Project Overview

The MCP Hardware Access Library is a comprehensive Python framework that enables secure hardware control through the Model Context Protocol (MCP). It provides AI agents and automation systems with the ability to interact with physical devices across multiple platforms.

๐Ÿ“Š Project Statistics

  • Total Files: 40+ files
  • Lines of Code: ~5,000+ lines
  • Components: 6 major subsystems
  • Examples: 15+ demonstration scripts
  • Test Coverage: Full client/server tests

๐Ÿ—๏ธ Architecture

Core Components

  1. Client System

    • MCPHardwareClient: Async client for hardware control
    • MCPShell: Interactive command-line interface
    • Pipeline execution support
  2. Server System

    • MCPServer: Main server framework
    • Hardware-specific servers (GPIO, Input, Audio, Camera)
    • Protocol handling and routing
  3. Security Layer

    • Permission management system
    • Client authentication
    • Operation auditing
  4. Pipeline System

    • Automated command sequences
    • Conditional execution
    • Error handling and retries
    • Variable substitution

architecture.svg

๐Ÿ’ก Key Features

1. Hardware Control

  • GPIO Operations: LEDs, buttons, sensors (Raspberry Pi)
  • Input Devices: Keyboard and mouse automation
  • Audio System: Recording, playback, TTS/STT
  • Camera Control: Image capture, face detection, motion detection
  • USB Devices: Device enumeration and management

2. Remote Hardware Setup

  • Automated Setup Scripts: Configure and test hardware components remotely
  • Component-specific Setup: Individual scripts for OLED, LCD, sensors, etc.
  • Simulation Mode: Test setup scripts without physical hardware or sudo privileges
  • Remote Deployment: SSH-based installation and configuration

3. AI Integration

  • Ollama LLM Support: Natural language hardware control
  • Voice Assistant: Speech recognition and synthesis
  • Automated Agents: AI-driven hardware automation

4. Interactive Shell

mcp> led_setup led1 17
mcp> led led1 on
mcp> type "Hello from MCP!"
mcp> pipeline_create automation
mcp> pipeline_run automation

5. Pipeline Automation

steps = [
    PipelineStep("setup", "gpio.setupLED", {"pin": 17}),
    PipelineStep("blink", "gpio.controlLED", {"action": "blink"}),
    PipelineStep("wait", "system.sleep", {"duration": 5})
]
pipeline = Pipeline("demo", steps)
await pipeline.execute(client)

๐Ÿ“ Project Structure

mcp-hardware/
โ”œโ”€โ”€ audio/                 # Audio-related scripts
โ”œโ”€โ”€ build/                 # Build-related files
โ”œโ”€โ”€ hardware/              # Hardware configuration scripts
โ”œโ”€โ”€ install/               # Installation scripts and utilities
โ”œโ”€โ”€ misc/                  # Miscellaneous utilities
โ”œโ”€โ”€ nlp/                   # Natural Language Processing scripts
โ”œโ”€โ”€ python/                # Python-related utilities
โ”œโ”€โ”€ rpi/                   # Raspberry Pi specific scripts
โ”œโ”€โ”€ service/               # Service setup scripts
โ”œโ”€โ”€ ssh/                   # SSH connection utilities
โ”œโ”€โ”€ test/                  # Testing utilities
โ”œโ”€โ”€ update/                # Update and upgrade scripts
โ”œโ”€โ”€ src/unitmcp/           # Main package
โ”‚   โ”œโ”€โ”€ client/                 # Client implementations
โ”‚   โ”œโ”€โ”€ server/                 # Hardware servers
โ”‚   โ”œโ”€โ”€ pipeline/               # Pipeline system
โ”‚   โ”œโ”€โ”€ protocols/              # MCP protocol
โ”‚   โ”œโ”€โ”€ security/               # Permission system
โ”‚   โ””โ”€โ”€ utils/                  # Utilities
โ”œโ”€โ”€ examples/                   # Usage examples
โ”‚   โ”œโ”€โ”€ Basic Controls          # LED, keyboard, mouse
โ”‚   โ”œโ”€โ”€ Automation              # Pipelines, scripts
โ”‚   โ”œโ”€โ”€ AI Integration          # Ollama, voice
โ”‚   โ””โ”€โ”€ Complete Systems        # Traffic light, security
โ””โ”€โ”€ tests/                      # Test suite

๐Ÿš€ Quick Start

Installation

git clone https://github.com/example/mcp-hardware.git
cd mcp-hardware
pip install -e .

Hardware Setup

# Set up hardware components on a local Raspberry Pi
python rpi_control/setup/setup_all.py --component oled

# Set up hardware components on a remote Raspberry Pi
python rpi_control/setup/remote_setup.py --host raspberrypi.local --component oled

# Run setup in simulation mode (no physical hardware or sudo required)
python rpi_control/setup/remote_setup.py --host raspberrypi.local --component oled --simulation

Start Server

python examples/start_server.py

Run Examples

# Basic LED control
python examples/led_control.py

# Interactive shell
python -m unitmcp.client.shell

# Pipeline automation
python examples/pipeline_demo.py

AI Agent <-> MCP Client <-> MCP Servers <-> Hardware Drivers

๐Ÿ“š Example Applications

1. Traffic Light System

  • Simulates complete traffic light with LEDs
  • Pedestrian crossing functionality
  • Timing control and sequencing

2. Security System

  • Motion detection alerts
  • Camera surveillance
  • Multi-sensor integration
  • Automated responses

3. Voice Assistant

  • Natural language commands
  • Hardware control via speech
  • Voice feedback and confirmation

4. Automation Workflows

  • Automated testing sequences
  • Data entry automation
  • System monitoring and alerts

๐Ÿ”ง Supported Platforms

  • Raspberry Pi: Full GPIO and hardware support
  • Linux: Input automation, audio, camera
  • Windows: Keyboard/mouse control, audio
  • macOS: Input devices, limited hardware

๐Ÿ›ก๏ธ Security Features

  • Fine-grained permission system
  • Client authentication
  • Operation auditing
  • Secure protocol communication
  • Input validation and sanitization

๐Ÿ“ˆ Performance

  • Asynchronous architecture
  • Efficient protocol handling
  • Resource pooling
  • Optimized for real-time control

๐Ÿ”„ Integration Options

Python Applications

from unitmcp import MCPHardwareClient

async with MCPHardwareClient() as client:
    await client.control_led("led1", "on")

Shell Scripts

#!/bin/bash
echo "led_setup led1 17" | python -m unitmcp.client.shell
echo "led led1 on" | python -m unitmcp.client.shell

AI Agents

from unitmcp.examples.ollama_integration import OllamaHardwareAgent

agent = OllamaHardwareAgent()
await agent.process_command("Turn on the lights")

๐ŸŽฏ Use Cases

  1. Home Automation: Control lights, sensors, and devices
  2. Robotics: Motor control, sensor integration
  3. Testing Automation: UI testing, hardware validation
  4. Education: Learning hardware programming
  5. Prototyping: Rapid hardware development
  6. Accessibility: Voice-controlled systems

๐Ÿ”ฎ Future Enhancements

  • Web interface dashboard
  • Cloud integration
  • Mobile app control
  • More hardware support
  • Machine learning integration
  • Distributed systems support

๐Ÿ“ž Getting Help

  • Documentation: See README.md and examples
  • Issues: GitHub issue tracker
  • Community: Discussion forums
  • Support: support@example.com

๐Ÿ™ Acknowledgments

  • Anthropic MCP team for the protocol
  • Raspberry Pi Foundation for hardware libraries
  • Open source community for contributions

The MCP Hardware project provides a robust foundation for building hardware automation systems, AI-controlled devices, and interactive hardware applications. With its modular architecture and comprehensive examples, developers can quickly create sophisticated hardware control solutions.

project.svg

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unitmcp-0.1.53.tar.gz (2.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

unitmcp-0.1.53-py3-none-any.whl (356.7 kB view details)

Uploaded Python 3

File details

Details for the file unitmcp-0.1.53.tar.gz.

File metadata

  • Download URL: unitmcp-0.1.53.tar.gz
  • Upload date:
  • Size: 2.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for unitmcp-0.1.53.tar.gz
Algorithm Hash digest
SHA256 8a7cefc27f7c188a9a0a7f07890204bca4925812e34f3a3ab392997dcd0b985a
MD5 ef536357a187c8e69171d5d787df87c5
BLAKE2b-256 22370dba4a148a012510f3a1ccf25033b86e8883d09bf673873618b5dc701fc8

See more details on using hashes here.

File details

Details for the file unitmcp-0.1.53-py3-none-any.whl.

File metadata

  • Download URL: unitmcp-0.1.53-py3-none-any.whl
  • Upload date:
  • Size: 356.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for unitmcp-0.1.53-py3-none-any.whl
Algorithm Hash digest
SHA256 36913c043297f1cfcbd4c877b4568998a9ff8ee91c64e1d5f136ccb563c4c87f
MD5 db6f6ef5113cdce19c9d49836be97223
BLAKE2b-256 5f83f2154a8ede4c8109822cc73518c9ac24f930add1ed168296360902c59f8e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page