Skip to content

MCP Server Fails to Compile - Axum 0.7 Handler Trait Errors #522

Closed as not planned

Description

@malibio

MCP Server Fails to Compile - Axum 0.7 Handler Trait Errors

Summary

The MCP HTTP server in packages/core/src/mcp/server.rs has compilation errors that prevent the backend from building. This appears to be a pre-existing issue that affects main branch and was not introduced by recent PRs.

Error Details

error[E0277]: the trait bound `fn(...) -> ... {handle_streamable_http_request}: Handler<_, _>` is not satisfied
 --> packages/core/src/mcp/server.rs:241:29

error[E0277]: the trait bound `fn(State<...>, ...) -> ... {handle_http_mcp_request}: Handler<_, _>` is not satisfied
 --> packages/core/src/mcp/server.rs:243:37

Both handle_streamable_http_request and handle_http_mcp_request fail to satisfy Axum's Handler trait.

Impact

  • Severity: High (prevents compilation)
  • Scope: MCP server only (doesn't affect desktop app)
  • Status: Likely not caught in CI (MCP module may not be tested)

Root Cause Analysis

The handlers use Axum 0.7 extractors but the trait bounds aren't satisfied. Possible causes:

  1. Extractor ordering issue: Axum 0.7 has strict requirements for extractor order

    • Tried: State, HeaderMap, String ❌
    • Tried: HeaderMap, State, String ❌
    • Tried: State, HeaderMap, Bytes ❌
  2. State type mismatch: The tuple state type may not be compatible

    • Current: State<(Arc<McpServices>, Option<ResponseCallback>, Arc<ServerState>)>
  3. Missing trait imports: May need additional Axum trait imports

  4. Return type issue: Result<Response, StatusCode> may not implement IntoResponse correctly

Investigation Done

  • Verified issue exists in main branch (commit d1a9854)
  • Verified issue exists in last known "working" commit (5b288cf)
  • Tried multiple extractor orderings per Axum 0.7 docs
  • Tried #[axum::debug_handler] attribute (no additional info)
  • Checked Axum version: 0.7.9

Recommendations

  1. Verify if MCP is actually used: Check if any code paths call the MCP server
  2. Add to CI: Ensure cargo check --lib runs in CI to catch this
  3. Consult Rust/Axum expert: This requires deep Axum trait knowledge
  4. Consider refactoring: May need to redesign handler signatures for Axum 0.7 compatibility

Acceptance Criteria

  • cargo check --lib compiles without errors
  • Both handlers satisfy Handler<_, _> trait bound
  • MCP server integration tests pass (if they exist)
  • Add CI check to prevent regression

Related Files

  • packages/core/src/mcp/server.rs - Main file with errors (lines 241, 243, 281, 467)
  • packages/core/Cargo.toml - Axum dependency version

Labels

backend, mcp, bug, compilation-error, needs-rust-expert

Priority

Medium - Blocks backend compilation but doesn't affect core desktop app functionality. Should be fixed but not blocking current sprint work.

Activity

  1. malibio commented on Nov 17, 2025

    @malibio
    CollaboratorAuthor

    Update: False Alarm - MCP Compiles Successfully

    After further investigation, the MCP HTTP server compiles and works correctly when built as part of the workspace or Tauri app.

    What works:

    • ✅ cargo build (full workspace) - compiles successfully
    • ✅ cd packages/desktop-app && cargo check - compiles successfully
    • ✅ MCP HTTP server runs fine in production

    What fails:

    • ❌ cd packages/core && cargo check --lib - fails with Handler trait errors

    Root Cause:
    The Axum handler compilation errors only occur when checking packages/core as an isolated library. This is likely due to how Cargo resolves dependencies and features differently between workspace builds vs isolated library checks.

    Impact:
    None - this was a false alarm. The MCP server works correctly.

    Recommendation:
    Close this issue as invalid. The apparent compilation errors were due to incorrect testing methodology (checking library in isolation vs full workspace build).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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