Skip to content

E0428: validators defined multiple times - Compilation fails with any protocol version feature #92

@JeyzDFoo

Description

@JeyzDFoo

The crate fails to compile when using any protocol version feature (2024_11_05, 2025_03_26, 2025_06_18, or draft) due to the validators module being defined multiple times.

Environment:

rust-mcp-schema: v0.7.5 (also affects git main branch)
rustc: 1.91.1
cargo: 1.91.1
OS: macOS
To Reproduce:

Create a new project:

Add to Cargo.toml:

Use in src/main.rs:

Run cargo build

Error Output:

Root Cause:

The define_schema_version! macro in src/generated_schema.rs is invoked for ALL protocol versions (2025_06_18, 2025_03_26, 2024_11_05, draft), and each invocation includes:

This causes multiple definitions of the validators module in the same scope, even when only one protocol version feature is enabled.

Affected Configurations:

✗ All protocol versions: 2024_11_05, 2025_03_26, 2025_06_18, draft
✗ With and without schema_utils feature
✗ Published v0.7.5 from crates.io
✗ Git main branch
Expected Behavior:

The crate should compile successfully when a single protocol version feature is enabled, with only that version's validators module included.

Suggested Fix:

The validators module should be conditionally included based on the active feature, or the macro should be restructured to avoid multiple definitions in the same scope.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions