[Claude] Implement HTTP MCP server for tile control#22
Open
wmmiii wants to merge 5 commits into
Open
Conversation
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
commented
Jan 15, 2026
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)"); |
Owner
Author
There was a problem hiding this comment.
Let's remove these lines. I'd like to keep stdio as clean as possible.
Owner
Author
There was a problem hiding this comment.
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 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). |
| use tauri::AppHandle; | ||
|
|
||
| #[derive(Serialize, Deserialize, Clone)] | ||
| pub struct TileInfo { |
Owner
Author
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add embedded HTTP MCP (Model Context Protocol) server in the Rust/Tauri
backend for external control of tiles in the active scene.
Features:
Implementation details:
Technical changes: