colinrozzi/component-tools-mcp
If you are the rightful owner of component-tools-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
A Model Context Protocol (MCP) server designed to facilitate WebAssembly component development using `cargo component`.
Component Tools MCP Server
A Model Context Protocol (MCP) server that provides tools for WebAssembly component development using cargo component
.
Features
This MCP server exposes two main tools for working with WebAssembly components:
Tools Available
-
component-bindings - Generates bindings for WebAssembly components
- Runs
cargo component bindings
in the specified directory - Supports additional arguments
- Runs
-
component-build - Builds WebAssembly components
- Runs
cargo component build
in the specified directory - Supports additional arguments like
--release
,--target
, etc.
- Runs
Prerequisites
Before using this server, you need to have cargo-component
installed:
cargo install cargo-component
Installation
- Clone this repository and navigate to the component-tools-mcp directory
- Build the server:
cargo build --release
Usage
Running the Server
# Run with default settings (allows access to all directories)
cargo run
# Run with restricted directory access
cargo run -- --allowed-dir /path/to/your/components --allowed-dir /another/path
# Run with custom logging
cargo run -- --log-level debug --log-file component-tools.log
Command Line Options
--allowed-dir <DIR>
: Specify directories where component operations are allowed (can be used multiple times)--log-level <LEVEL>
: Set log level (trace, debug, info, warn, error) - defaults to "info"--log-file <FILE>
: Log to file instead of stderr
Using with MCP Clients
Once the server is running, MCP clients can use the following tools:
component-bindings
Generate bindings for a component project:
{
"name": "component-bindings",
"arguments": {
"directory": "/path/to/your/component/project",
"args": ["--out-dir", "generated"]
}
}
component-build
Build a component project:
{
"name": "component-build",
"arguments": {
"directory": "/path/to/your/component/project",
"args": ["--release"]
}
}
Security Features
- Directory Restrictions: When
--allowed-dir
is specified, the server will only operate within those directories - Path Validation: All paths are validated before execution
- Command Isolation: Only
cargo component
commands are executed
Error Handling
The server provides detailed error information including:
- Command execution status
- stdout and stderr output
- Exit codes
- Path validation errors
Development
Building
cargo build
Testing
cargo test
Running in Development
cargo run -- --log-level debug
Example Usage
Basic Usage
- Start the server:
cargo run
- Start with directory restrictions:
cargo run -- --allowed-dir /home/user/components --allowed-dir /home/user/other-components
- Start with debug logging:
cargo run -- --log-level debug --log-file component-tools.log
Using with MCP Clients
The server exposes two tools that can be called by MCP clients:
component-bindings
{
"name": "component-bindings",
"arguments": {
"directory": "/path/to/your/component/project",
"args": ["--out-dir", "generated"]
}
}
component-build
{
"name": "component-build",
"arguments": {
"directory": "/path/to/your/component/project",
"args": ["--release"]
}
}
Example MCP Client Configuration
For Claude Desktop or other MCP clients, add this to your configuration:
{
"mcpServers": {
"component-tools": {
"command": "cargo",
"args": ["run", "--release"],
"cwd": "/path/to/component-tools-mcp",
"env": {
"RUST_LOG": "info"
}
}
}
}
Integration with Other Tools
This MCP server is designed to work with:
- Claude desktop app
- Other MCP-compatible clients
- Development workflows involving WebAssembly components
Troubleshooting
"cargo-component not found" Error
Make sure you have cargo-component installed:
cargo install cargo-component
Permission Errors
If you're getting permission errors:
- Check that the target directory exists and is writable
- Ensure the directory is in your allowed directories list (if using
--allowed-dir
)
Build Failures
Component build failures will be reported with full stdout/stderr output to help with debugging.