MCP Hardware Access Library

MCP Hardware Access Library

A Python framework that enables secure hardware control through the Model Context Protocol, allowing AI agents and automation systems to interact with physical devices across multiple platforms.

Category
访问服务器

README

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. AI Integration

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

3. Interactive Shell

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

4. 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 .

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

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选