Skip to content

Add WASM32-WASIP2 target support for WebAssembly deployment #26

@avrabe

Description

@avrabe

Summary

Add comprehensive support for the wasm32-wasip2 target to enable deployment of MCP servers as WebAssembly components with full system interface access.

Background

WASI Preview 2 provides much more system capability than basic WASM, including:

  • File I/O through WASI filesystem interfaces
  • Networking through WASI sockets
  • CLI interfaces through WASI command-line tools
  • Standard library compatibility via rustix/wstd

Implementation Tasks

Core Compilation Support

  • Add wasm32-wasip2 to supported targets in Cargo.toml workspace
  • Add conditional compilation features for WASM-specific code paths
  • Update dependency versions to ensure WASM compatibility
  • Test core protocol functionality on WASM target

Dependency Audit & Updates

  • Audit all dependencies for wasm32-wasip2 compatibility
  • Replace or feature-gate incompatible dependencies:
    • tokio - use WASM-compatible async runtime or feature flags
    • Platform-specific file operations in mcp-auth
    • Network binding operations
  • Add WASM-specific alternatives where needed

Runtime Adaptations

  • Adapt async runtime selection for WASM contexts
  • Update file I/O patterns to use WASI interfaces
  • Modify networking code for WASM socket capabilities
  • Ensure thread-local storage compatibility

Build System Integration

  • Create WASM-specific Cargo features
  • Add build scripts for WASM optimization
  • Integration with rules_wasm_component (separate issue)

Acceptance Criteria

  • All core crates compile successfully for wasm32-wasip2
  • Basic MCP protocol tests pass in WASM context
  • Example MCP server runs as WASM component
  • Documentation for WASM development workflow
  • CI/CD pipeline includes WASM target testing

Related Issues

  • Bazel Build System Integration (#TBD)
  • WASM Development Workflow (#TBD)
  • Transport Layer WASM Compatibility (#TBD)

References

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions