Skip to main content
Glama
propfire11

mcp-stm32-server

by propfire11

🔌 MCP STM32 Controller Server / MCP STM32 컨트롤러 서버

Python MCP License

**MCP (Model Context Protocol)**를 통해 STM32 마이크로컨트롤러를 제어할 수 있습니다. AI 어시스턴트는 자연어만으로 GPIO를 읽고 쓰고, LED를 제어하고, ADC를 읽고, OLED를 구동할 수 있습니다.

MCP(Model Context Protocol) 프로토콜을 통해 STM32 마이크로컨트롤러를 제어합니다. AI 어시스턴트는 이 서비스가 제공하는 도구를 호출하여 STM32의 GPIO 읽기/쓰기, LED 제어, ADC 읽기, OLED 화면 조작 등을 수행할 수 있습니다.


아키텍처

AI Assistant (Claude) ←→ MCP Server (this program) ←→ UART ←→ STM32 firmware

통신은 JSON 라인 프로토콜을 사용합니다. 한 줄에 하나의 JSON 객체가 들어가며 \n으로 끝납니다.


빠른 시작

1. 의존성 설치

pip install -r requirements.txt

2. 하드웨어 연결

  • STM32 USART1: PA9 (TX), PA10 (RX)

  • USB-TTL 모듈을 통해 PC에 연결합니다

  • 아래에서 설명하는 JSON 라인 프로토콜을 구현한 펌웨어를 기기에 플래시합니다

3. 서버 시작

# auto-detect the serial port
python main.py

# specify a serial port
python main.py --port COM3

# SSE mode (HTTP service)
python main.py --sse --port COM3

도구

도구

설명

인수

ping

STM32 온라인 상태 확인

set_led

LED 밝기 설정

brightness: 0-100

get_led

현재 LED 밝기 읽기

read_pin

GPIO 레벨 읽기

pin: "PA0", "PC13", ...

write_pin

GPIO 레벨 설정

pin + value: 0/1

read_adc

ADC 값 읽기

channel: 0-2

oled_clear

OLED 화면 지우기

oled_print

OLED에 텍스트 표시

x + y + text

리소스

URI

설명

stm32://status

연결 상태, 포트 정보, 가동 시간


구성

환경 변수 또는 명령줄 인수를 통해 설정합니다:

인수

환경 변수

기본값

설명

--port

STM32_PORT

자동 감지

시리얼 포트

--baud

115200

전송 속도

--sse

false

SSE 모드

--sse-port

8000

SSE 포트


Claude Desktop과 통합

claude_desktop_config.json 파일을 편집합니다:

{
  "mcpServers": {
    "stm32": {
      "command": "python",
      "args": ["C:/path/to/mcp-stm32-server/main.py", "--port", "COM3"],
      "env": {}
    }
  }
}

통신 프로토콜 (JSON-lines)

각 줄은 독립적인 JSON 객체입니다. 펌웨어는 같은 id를 가진 JSON 라인 하나로 응답하기만 하면 됩니다.

요청:

{"id":1,"cmd":"set_led","args":{"brightness":75}}

성공 응답:

{"id":1,"status":"ok","data":{"brightness":75}}

오류 응답:

{"id":1,"status":"error","msg":"brightness must be 0-100"}

펌웨어 계약: 수신한 모든 요청에 대해 동일한 idstatus("ok" / "error"), 그리고 data 또는 msg를 포함한 JSON 라인 하나로 응답해야 합니다. 부팅 중에 출력되는 유효한 JSON이 아닌 로그 줄은 클라이언트가 자동으로 건너뜁니다.


라이선스

MIT License.


아키텍처

AI 助手 (Claude) ←→ MCP Server (本程序) ←→ 串口 ←→ STM32 固件

통신은 JSON 라인 프로토콜을 사용하며, 각 줄은 JSON 객체 하나이고 \n으로 끝납니다.


빠른 시작

1. 의존성 설치

pip install -r requirements.txt

2. 하드웨어 연결

  • STM32의 USART1: PA9(TX), PA10(RX)

  • USB-TTL 모듈을 통해 컴퓨터에 연결합니다

  • 아래에서 설명하는 JSON 라인 프로토콜을 구현한 펌웨어를 기기에 플래시합니다

3. 서버 시작

# 自动检测串口
python main.py

# 指定串口
python main.py --port COM3

# SSE 模式(HTTP 服务)
python main.py --sse --port COM3

도구 목록

도구

설명

인수

ping

STM32 온라인 상태 확인

없음

set_led

LED 밝기 설정

brightness: 0-100

get_led

LED 밝기 읽기

없음

read_pin

GPIO 레벨 읽기

pin: "PA0", "PC13" 등

write_pin

GPIO 레벨 설정

pin + value: 0/1

read_adc

ADC 값 읽기

channel: 0-2

oled_clear

OLED 화면 지우기

없음

oled_print

OLED에 텍스트 표시

x + y + text

리소스

URI

설명

stm32://status

연결 상태, 시리얼 포트 정보, 실행 시간


구성

환경 변수 또는 명령줄 인수를 통해 설정:

인수

환경 변수

기본값

설명

--port

STM32_PORT

자동 감지

시리얼 포트

--baud

115200

전송 속도

--sse

false

SSE 모드

--sse-port

8000

SSE 포트


Claude Desktop과 통합

claude_desktop_config.json 파일을 편집합니다:

{
  "mcpServers": {
    "stm32": {
      "command": "python",
      "args": ["C:/path/to/mcp-stm32-server/main.py", "--port", "COM3"],
      "env": {}
    }
  }
}

프로토콜 형식 (JSON 라인)

각 줄은 독립된 JSON 객체입니다. 펌웨어는 같은 id를 가진 JSON 라인 하나만 응답하면 됩니다.

요청:

{"id":1,"cmd":"set_led","args":{"brightness":75}}

성공 응답:

{"id":1,"status":"ok","data":{"brightness":75}}

오류 응답:

{"id":1,"status":"error","msg":"brightness must be 0-100"}

펌웨어 약속: 요청을 수신할 때마다 동일한 id를 포함하고 status("ok" / "error")와 data 또는 msg를 갖는 JSON 라인으로 응답합니다. 부팅 중 출력되는 JSON 형식이 아닌 로그 줄은 클라이언트가 자동으로 건너뜁니다.


라이선스

MIT License.

-
license - not tested
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

  • Connect AI assistants to GitHub - manage repos, issues, PRs, and workflows through natural language.

  • A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…

  • LLM chat, text summarization and AI image generation

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/propfire11/mcp-stm32-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server