This directory contains example Rust programs that demonstrate how to validate tool configurations for the AHMA MCP server.
Each example loads and validates a specific tool configuration from the configs/ directory:
- cargo_tool.rs - Validates
configs/cargo.json(Rust build tool) - file-tools.rs - Validates
configs/file-tools.json(Unix file operations) - gh_tool.rs - Validates
configs/gh.json(GitHub CLI) - git_tool.rs - Validates
configs/git.json(Git version control) - kotlin_tool.rs - Validates
configs/kotlin.json(Kotlin/Android Gradle wrapper) - python_tool.rs - Validates
configs/python.json(Python interpreter)
Run any example using cargo:
# Run a specific example
cargo run --example cargo_tool
cargo run --example file-tools
cargo run --example gh_tool
cargo run --example git_tool
cargo run --example gradlew_tool
cargo run --example python_toolWhen you run an example, you'll see output like:
Loading cargo tool configuration from: /path/to/ahma-mcp/examples/configs/cargo.json
OK Configuration is valid!
📋 Tool Details:
Name: cargo
Description: Rust's build tool and package manager
Command: cargo
Enabled: true
Subcommands: 14
🔧 Available Subcommands:
- build: Compile the current package.
- run: Run a binary or example of the local package.
- add: Add dependencies to a Cargo.toml manifest file.
...
All configuration JSON files are located in the configs/ directory and follow the MCP Tool Definition Format (MTDF) schema. These configs have "enabled": true set and can be copied to the .ahma/ directory for actual use.
The examples use the MtdfValidator from ahma-mcp::schema_validation to validate configurations against the MTDF schema. This ensures:
- Required fields are present
- Field types are correct
- Values are within acceptable ranges
- Logical consistency is maintained
Integration tests verify that all examples run successfully:
# Run schema validation tests
cargo nextest run --package ahma-mcp --test tool_config_schema_validation_test
# Run execution tests
cargo nextest run --package ahma-mcp --test tool_examples_execution_testTo add a new tool configuration:
- Create
configs/newtool.jsonfollowing the MTDF schema - Create
newtool.rsexample based on existing examples - Add to
Cargo.toml:[[example]] name = "newtool" path = "examples/newtool.rs"
- Add tests in
tests/tool_config_schema_validation_test.rs - Add execution tests in
tests/tool_examples_execution_test.rs
- /.ahma/README.md - Comprehensive guide to tool configurations
- /docs/mtdf-schema.json - JSON Schema definition
- ahma-mcp/src/schema_validation.rs - Validation implementation