---
title: "Control OBS Studio Rust from code: WebSocket or MCP"
source: https://obs-rust.com/websocket/
commit: 524486a44c81ef30b039f10ab955bc778f39e225
tier: core
tokens_est: 548
---
# Control OBS Studio Rust from code: WebSocket or MCP

OBS Studio Rust can be driven two ways: obs-websocket from any machine that can reach OBS, or the MCP server
on the OBS machine itself (Linux).

## Choose

| You are writing | Use | Why |
|---|---|---|
| A tool, bot, overlay, Stream Deck action or any existing obs-websocket client | **obs-websocket v5** | The standard OBS remote-control protocol: 147 requests, 60 events, 7 enums. Existing clients work unchanged. |
| An AI agent that should operate OBS through typed tools | **MCP server** | 30 typed tools with JSON Schema arguments and results; 13 are read-only. Errors are typed (`ToolError`) and `wait_for` blocks on a condition instead of polling. |

## obs-websocket v5

- Connect to `ws://<host>:4455`: the OBS machine itself or any host that can reach it (the port is set in
  Tools → WebSocket Server Settings). A WebSocket client may run remotely.
- Handshake: the server sends `Hello` (op 0); you reply `Identify` (op 1) with `rpcVersion: 1` and, if a
  password is set, `authentication = base64(sha256(base64(sha256(password + salt)) + challenge))`; the server
  answers `Identified` (op 2). Then send `Request` (op 6) messages and read `RequestResponse` (op 7).
- First request: `{"op":6,"d":{"requestType":"GetVersion","requestId":"1"}}`.
- Full reference: https://obs-rust.com/websocket/ (browsable, with a live console),
  https://obs-rust.com/websocket/protocol.json (machine-readable spec),
  https://obs-rust.com/ai/docs/obs-websocket-reference.md (markdown, one section per request).
- Client libraries and runnable snippets: https://obs-rust.com/ai/docs/site-examples.md.

## MCP server

- Linux only for now: the server is built from an obs-studio checkout and runs on Linux. It is local: it runs on
  the OBS machine, next to the agent.
- The server speaks JSON-RPC over stdio (MCP protocol 2025-06-18). Client config, requirements and
  example sessions: https://obs-rust.com/mcp/index.md.
- Tool list without starting the server: https://obs-rust.com/mcp/schema.json (tools/list + resources/list + ToolError).
- A read-only allowlist for cautious clients: https://obs-rust.com/mcp/read-only-allowlist.json.
