Skip to content

[Claude] Implement HTTP MCP server for tile control#22

Open
wmmiii wants to merge 5 commits into
will-mcpfrom
claude/http-mcp-tile-control-L3toO
Open

[Claude] Implement HTTP MCP server for tile control#22
wmmiii wants to merge 5 commits into
will-mcpfrom
claude/http-mcp-tile-control-L3toO

Conversation

@wmmiii
Copy link
Copy Markdown
Owner

@wmmiii wmmiii commented Jan 15, 2026

Add embedded HTTP MCP (Model Context Protocol) server in the Rust/Tauri
backend for external control of tiles in the active scene.

Features:

  • GET /tiles - List all tiles in active scene with state
  • POST /tiles/:id/enable - Enable/start a tile
  • POST /tiles/:id/disable - Disable/stop a tile
  • POST /tiles/:id/amount - Set tile strength (0.0-1.0)
  • GET /health - Server health check

Implementation details:

  • Embedded Axum HTTP server on localhost:3001
  • Direct access to PROJECT_REF for thread-safe state management
  • Automatic startup with Tauri application
  • CORS enabled for local development
  • Comprehensive API documentation in MCP_SERVER.md

Technical changes:

  • Add axum, tower, and tower-http dependencies
  • Create src-tauri/src/mcp.rs module with REST endpoints
  • Initialize HTTP server in lib.rs setup()
  • Update README.md with MCP server quick start guide

Add embedded HTTP MCP (Model Context Protocol) server in the Rust/Tauri
backend for external control of tiles in the active scene.

Features:
- GET /tiles - List all tiles in active scene with state
- POST /tiles/:id/enable - Enable/start a tile
- POST /tiles/:id/disable - Disable/stop a tile
- POST /tiles/:id/amount - Set tile strength (0.0-1.0)
- GET /health - Server health check

Implementation details:
- Embedded Axum HTTP server on localhost:3001
- Direct access to PROJECT_REF for thread-safe state management
- Automatic startup with Tauri application
- CORS enabled for local development
- Comprehensive API documentation in MCP_SERVER.md

Technical changes:
- Add axum, tower, and tower-http dependencies
- Create src-tauri/src/mcp.rs module with REST endpoints
- Initialize HTTP server in lib.rs setup()
- Update README.md with MCP server quick start guide
Switch from Axum web framework to Hyper HTTP library for the MCP
server implementation. This reduces dependencies by reusing the same
HTTP libraries already present through Tauri and reqwest.

Changes:
- Replace axum, tower, tower-http with hyper, hyper-util, http-body-util
- Rewrite mcp.rs to use Hyper's lower-level HTTP server API
- Manual request routing based on path and method
- CORS headers handled directly in response builders
- Update documentation to reflect Hyper usage

Benefits:
- No additional dependencies (all transitive through reqwest)
- Smaller dependency footprint
- Direct control over HTTP handling
- Same functionality and API
Replace simple REST API with full MCP (Model Context Protocol)
implementation including standardized handshake and capability discovery.

Changes:
- Add JSON-RPC 2.0 request/response structures
- Implement initialize method for MCP handshake
- Implement tools/list for capability discovery
- Implement tools/call for tool execution
- Expose 4 tools: list_tiles, enable_tile, disable_tile, set_tile_amount
- Proper JSON-RPC error codes (-32700, -32600, -32601, -32602, -32000)
- Server capabilities declaration
- MCP protocol version 2024-11-05

Benefits:
- Compatible with Claude Desktop and other MCP clients
- Standardized protocol for AI assistant integration
- Automatic tool discovery (no hardcoded APIs)
- Follows official MCP specification

Documentation:
- Complete rewrite of MCP_SERVER.md with JSON-RPC examples
- Updated README.md with MCP quick start
- Python and TypeScript client examples
- Claude Desktop integration instructions
Replace manual JSON-RPC implementation with the jsonrpsee crate, which
provides automatic protocol handling and simplifies the codebase.

Changes:
- Replace hyper/http-body-util with jsonrpsee dependency
- Rewrite mcp.rs to use RpcModule and method registration
- Automatic JSON-RPC 2.0 request/response handling
- Built-in error code management
- CORS support included

Benefits:
- ~200 lines of code removed (manual JSON-RPC structs/parsing)
- Type-safe method registration
- Better error handling with ErrorObjectOwned
- No manual HTTP routing or response building
- Industry-standard JSON-RPC library

The API remains identical - all MCP methods work the same way.
@wmmiii wmmiii changed the base branch from main to will-mcp January 15, 2026 15:06
@wmmiii wmmiii changed the title Implement HTTP MCP server for tile control [Claude] Implement HTTP MCP server for tile control Jan 15, 2026
Comment thread src-tauri/src/mcp.rs Outdated
Comment on lines +375 to +386
println!("DMX MCP Server listening on http://{}", addr);
println!("Protocol: JSON-RPC 2.0 over HTTP (via jsonrpsee)");
println!("MCP Protocol Version: 2024-11-05");
println!("\nAvailable methods:");
println!(" initialize - Initialize MCP connection and get server capabilities");
println!(" tools/list - List all available tools");
println!(" tools/call - Execute a tool");
println!("\nAvailable tools:");
println!(" list_tiles - List all tiles in active scene");
println!(" enable_tile - Enable a tile");
println!(" disable_tile - Disable a tile");
println!(" set_tile_amount - Set tile strength (0.0-1.0)");
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove these lines. I'd like to keep stdio as clean as possible.

Comment thread MCP_SERVER.md Outdated
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this file. I am currently the only one who works on this project and maintaining such a file will be challenging for human developers.

Comment thread README.md Outdated
Comment on lines +54 to +73
### Quick Start

```bash
# Initialize connection
curl -X POST http://localhost:3001 \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "method": "initialize", "params": {"protocolVersion": "2024-11-05"}, "id": 1}'

# List available tools
curl -X POST http://localhost:3001 \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "method": "tools/list", "id": 2}'

# Call a tool (list tiles)
curl -X POST http://localhost:3001 \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "params": {"name": "list_tiles", "arguments": {}}, "id": 3}'
```

For complete API documentation, see [MCP_SERVER.md](MCP_SERVER.md).
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this section.

Comment thread src-tauri/src/mcp.rs Outdated
use tauri::AppHandle;

#[derive(Serialize, Deserialize, Clone)]
pub struct TileInfo {
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of creating a new struct here can we just leverage the protos that we already have written?

- Remove println! statements to keep stdio clean
- Replace custom TileInfo struct with existing protobuf types
- Remove MCP_SERVER.md documentation file
- Remove HTTP MCP Server section from README

Changes use existing dmx_engine::proto::scene::TileMap types
and convert to JSON via tilemap_to_json() helper.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants