Skip to content

Conversation

@avrabe
Copy link
Contributor

@avrabe avrabe commented Jul 13, 2025

Summary

This PR fixes multiple CI failures that were causing the External Validation workflow to fail with exit code 101 and runtime panics in integration tests.

Issues Resolved

  • CLI test failures due to environment-dependent assumptions
  • Runtime panics in monitoring integration tests from blocking operations in async context
  • External validation CLI argument parsing errors in scheduled workflows

Changes Made

CLI Test Robustness (test(cli))

  • Fixed test_find_cargo_toml_current_dir to work reliably across different CI environments
  • Replaced environment-dependent test logic with controlled temporary directory approach
  • Maintains test coverage while eliminating CI environment assumptions

Monitoring API Async Compatibility (fix(monitoring))

  • Converted get_current_metrics() from sync to async to prevent runtime blocking
  • Updated all callers to properly await the async method
  • Fixed integration test panics caused by blocking_read() in async runtime
  • Maintains same functionality with proper async/await semantics

External Validation Workflow (ci)

  • Fixed CLI argument syntax in scheduled validation workflow
  • Changed from positional arguments to proper --server-url flag usage
  • Resolves parsing errors in external MCP server validation

Test Results

  • ✅ CLI tests: 68/68 passing
  • ✅ Monitoring tests: 49/49 passing
  • ✅ Integration tests: All monitoring scenarios passing
  • ✅ External validation CLI syntax verified

Test Plan

  • Run CLI unit tests to verify robustness fix
  • Run monitoring unit and integration tests to verify async changes
  • Verify external validation command syntax
  • Confirm no regressions in existing functionality
  • Test cross-platform compatibility (temporary directory handling)

The changes are focused and surgical, addressing specific CI failures without impacting core functionality. All tests pass locally and the fixes target the root causes of the CI issues.

avrabe added 12 commits July 7, 2025 21:04
- Accept client-provided session IDs instead of always creating new ones
- Add Mcp-Session-Id header to responses as per MCP specification
- Ensure compatibility with MCP Inspector session management
- Bump version to 0.4.3
Updated protocol to ensure compatibility with MCP Inspector:
- Changed protocol version to 2025-06-18 while maintaining backward compatibility with 2025-03-26
- Added skip_serializing_if annotations to all capability fields to prevent null values in JSON responses
- Applied skip_serializing_if to instructions field in InitializeResult

MCP Inspector expects clean JSON responses without null values, and this change ensures
our server responses match the reference implementation's behavior. The protocol version
update aligns with the latest MCP specification while maintaining support for older clients
through the SUPPORTED_PROTOCOL_VERSIONS array.
Fixed failing test_path_operations test on Windows by using platform-specific paths:
- Added cfg(unix) and cfg(windows) conditional compilation attributes
- Unix systems use /tmp/test.txt and /tmp/ paths
- Windows systems use C:\temp\test.txt and C:\ paths

This ensures tests pass on both Unix-like systems and Windows without hardcoding
platform-specific assumptions. The test logic remains the same, only the paths
are adjusted based on the target platform.
Applied clippy recommendations to improve code quality:

mcp-transport/src/http.rs:
- Replaced manual Option::map pattern with more idiomatic or_else chain
- Simplified session ID extraction from query parameters and headers

mcp-server/src/handler.rs:
- Fixed variable reuse by extracting server_info once before using its fields
- Properly propagate instructions from backend instead of hardcoded empty string
- This also improves MCP Inspector compatibility by using actual backend instructions

These changes make the code more idiomatic and maintainable while fixing the clippy
warning about manual implementation of Option::map.
Added two new examples demonstrating streamable HTTP transport usage:

hello-world-streamable-http.rs:
- Full-featured example using the MCP server framework
- Demonstrates tool implementation with say_hello and count_greetings tools
- Shows proper backend initialization and server configuration
- Uses port 3002 for streamable HTTP transport

minimal-streamable-http.rs:
- Minimal implementation directly using transport layer
- Matches the transport example pattern for testing
- Implements basic MCP protocol handling without full server framework
- Uses port 3003 to avoid conflicts

These examples help developers understand how to implement MCP servers using
the streamable HTTP transport, which is becoming the preferred transport for
modern MCP implementations due to its simplicity compared to HTTP+SSE.
Updated version across all workspace members to 0.4.4. This release includes:
- MCP Inspector compatibility improvements with proper null handling
- Cross-platform test fixes for Windows support
- Code quality improvements from clippy recommendations
- New streamable HTTP transport examples
- Protocol version updates to align with latest MCP specification

The version bump prepares for publishing updated crates with all the recent
fixes and improvements for better MCP ecosystem compatibility.
Add detailed documentation for all authentication backends including:
- File-based authentication with secure filesystem storage
- Environment variable authentication for containerized deployments
- Memory-only authentication for temporary/development use
- Disabled authentication for trusted environments

This provides users with clear examples for each authentication mode,
making it easier to choose the right approach for their deployment
scenario and eliminating filesystem dependencies when needed.
Add new memory-only-auth example demonstrating:
- Zero filesystem dependency authentication
- Runtime API key management (add/remove keys while running)
- Complete server implementation with authentication tools
- Comprehensive documentation and usage instructions

This example is ideal for development, testing, containerized deployments,
or any scenario where persistent authentication storage is not desired.
All API keys are stored in memory and lost on server restart.
- Fix clippy warnings in profiling demo examples
- Apply consistent code formatting with cargo fmt
- Improve code quality and maintain style consistency
- Update example configurations to use direct initialization

These changes ensure all examples follow Rust best practices
and maintain consistent formatting across the codebase.
The test_find_cargo_toml_current_dir test was failing in CI environments
because it assumed a Cargo.toml file would be present in the working
directory or its parents. This assumption is not guaranteed in CI runners.

Changes:
- Create controlled test environment using temporary directories
- Add explicit Cargo.toml creation within test scope
- Properly restore original working directory after test
- Maintain test coverage while eliminating environment dependencies

This resolves CI test failures with exit code 101 in the external
validation workflow, improving test reliability across different
execution environments.
Fixed critical runtime issue where get_current_metrics() was calling
blocking_read() from within an async runtime context, causing panics
with "Cannot block the current thread from within a runtime" errors.

Changes:
- Convert get_current_metrics() from sync to async method
- Replace blocking_read() with async read().await for system metrics
- Update all callers to properly await the async method
- Fix integration tests to handle the async API changes
- Update metrics endpoint to use async pattern

This resolves integration test failures and prevents runtime panics
when accessing system metrics from async contexts. The change maintains
the same functionality while ensuring proper async/await semantics
throughout the monitoring system.

Fixes: Integration test panics in monitoring_integration module
The scheduled validation workflow was passing server URLs as positional
arguments instead of using the required --server-url flag, causing
CLI parsing errors in external validation runs.

Changes:
- Update mcp-validate command to use --server-url flag syntax
- Fix argument order to match expected CLI interface
- Maintain all other validation parameters and timeout settings

Error fixed:
  error: unexpected argument 'https://demo.mcp-server.dev' found
  Usage: mcp-validate [OPTIONS] --server-url <SERVER_URL>

This ensures the scheduled external validation workflow can properly
execute against test MCP servers without CLI argument parsing failures.
@github-actions
Copy link

github-actions bot commented Jul 13, 2025

PR Validation Results

Quick Validation: ✅

  • Format check
  • Clippy lints
  • Unit tests
  • Documentation

Validation Framework: ✅

  • Framework tests
  • Property-based tests
  • CLI tools

Compatibility Check: ✅

  • Protocol compliance
  • Server compatibility

Summary: ✅ All checks passed

avrabe added 3 commits July 13, 2025 13:02
Convert remaining blocking operations in metrics collector:
- Make start_collection() and stop_collection() async
- Update all callers to use .await
- Fixes remaining "Cannot block the current thread from within a runtime" errors
Replace global directory changes with controlled test environments:
- Update test_find_cargo_toml_with_hierarchy to avoid changing cwd
- Update test_find_cargo_toml_in_temp_dir to validate setup without directory changes
- Prevents CI failures caused by environment-dependent directory operations
Apply cargo fmt to fix spacing and formatting inconsistencies
@avrabe avrabe force-pushed the fix/ci-test-failures branch 4 times, most recently from dd2d4c1 to 969a768 Compare July 14, 2025 16:55
- Fix telemetry span test failure by initializing tracing subscriber in test environment
- Fix persistence timestamp parsing with proper date/hour separation logic
- Update prometheus dependency from 0.13 to 0.14 to resolve protobuf security vulnerability (RUSTSEC-2024-0437)
- Optimize CI workflow matrix strategy to reduce resource contention:
  - Limit nightly builds to Ubuntu only
  - Add explicit timeouts to prevent infrastructure cancellations
  - Set fail-fast: false to continue other jobs if one fails

Fixes macOS nightly test failures and security audit warnings in CI
@avrabe avrabe force-pushed the fix/ci-test-failures branch from 969a768 to 69186b6 Compare July 14, 2025 17:46
@codecov
Copy link

codecov bot commented Jul 14, 2025

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

avrabe added 4 commits July 14, 2025 20:22
- Fix Codecov badge URL and token to point to pulseengine/mcp
- Fix CI badge URL to point to correct repository
- Fix trailing whitespace in inspector tests
Remove  which is flagged by clippy as a constant assertion that gets optimized out
- Include integration-tests in Dockerfile.validation copy commands
- Resolves Docker build failure: 'failed to read /app/integration-tests/Cargo.toml'
- Add permissions section to code-coverage.yml workflow
- Grant pull-requests: write permission for posting coverage comments
- Resolves 'Resource not accessible by integration' error
@github-actions
Copy link

Code Coverage Report ✅

Coverage: 84.27%
Required: 80%
Status: PASSED

Coverage Details
Filename                                                  Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
integration-tests/src/auth_server_integration.rs              375                59    84.27%          26                 9    65.38%         268                68    74.63%           0                 0         -
integration-tests/src/cli_server_integration.rs               387                32    91.73%          35                 5    85.71%         341                23    93.26%           0                 0         -
integration-tests/src/end_to_end_scenarios.rs                 903               172    80.95%          40                 9    77.50%         591                90    84.77%           0                 0         -
integration-tests/src/lib.rs                                   22                12    45.45%           5                 2    60.00%          44                17    61.36%           0                 0         -
integration-tests/src/monitoring_integration.rs               422                52    87.68%          28                 6    78.57%         352                71    79.83%           0                 0         -
integration-tests/src/transport_server_integration.rs         427                96    77.52%          31                11    64.52%         364               123    66.21%           0                 0         -
mcp-auth/src/audit.rs                                         385               262    31.95%          27                17    37.04%         269               177    34.20%           0                 0         -
mcp-auth/src/config.rs                                         20                13    35.00%           6                 5    16.67%          26                19    26.92%           0                 0         -
mcp-auth/src/consent.rs                                       140               140     0.00%          12                12     0.00%          98                98     0.00%           0                 0         -
mcp-auth/src/consent/manager.rs                               477               477     0.00%          39                39     0.00%         376               376     0.00%           0                 0         -
mcp-auth/src/crypto/encryption.rs                              89                89     0.00%           9                 9     0.00%          51                51     0.00%           0                 0         -
mcp-auth/src/crypto/hashing.rs                                 98                98     0.00%          10                10     0.00%          53                53     0.00%           0                 0         -
mcp-auth/src/crypto/keys.rs                                    93                93     0.00%           6                 6     0.00%          61                61     0.00%           0                 0         -
mcp-auth/src/crypto/mod.rs                                     15                15     0.00%           2                 2     0.00%          12                12     0.00%           0                 0         -
mcp-auth/src/jwt.rs                                           321               284    11.53%          29                27     6.90%         255               226    11.37%           0                 0         -
mcp-auth/src/lib.rs                                             8                 5    37.50%           3                 2    33.33%           7                 4    42.86%           0                 0         -
mcp-auth/src/manager.rs                                      1229              1116     9.19%         116               101    12.93%         917               793    13.52%           0                 0         -
mcp-auth/src/manager_vault.rs                                 242               242     0.00%          22                22     0.00%         191               191     0.00%           0                 0         -
mcp-auth/src/middleware/mcp_auth.rs                           240               240     0.00%          24                24     0.00%         208               208     0.00%           0                 0         -
mcp-auth/src/middleware/session_middleware.rs                 435               435     0.00%          41                41     0.00%         359               359     0.00%           0                 0         -
mcp-auth/src/models.rs                                        195               195     0.00%          19                19     0.00%         166               166     0.00%           0                 0         -
mcp-auth/src/monitoring/dashboard_server.rs                   241               241     0.00%          28                28     0.00%         440               440     0.00%           0                 0         -
mcp-auth/src/monitoring/security_monitor.rs                   708               708     0.00%          70                70     0.00%         531               531     0.00%           0                 0         -
mcp-auth/src/performance.rs                                   577               577     0.00%          34                34     0.00%         425               425     0.00%           0                 0         -
mcp-auth/src/permissions/mcp_permissions.rs                   419               419     0.00%          33                33     0.00%         319               319     0.00%           0                 0         -
mcp-auth/src/security/request_security.rs                     702               702     0.00%          49                49     0.00%         615               615     0.00%           0                 0         -
mcp-auth/src/session/session_manager.rs                       457               457     0.00%          50                50     0.00%         353               353     0.00%           0                 0         -
mcp-auth/src/setup/mod.rs                                     161               161     0.00%          21                21     0.00%         161               161     0.00%           0                 0         -
mcp-auth/src/setup/validator.rs                               141               141     0.00%          11                11     0.00%         106               106     0.00%           0                 0         -
mcp-auth/src/storage.rs                                       681               664     2.50%          48                44     8.33%         399               381     4.51%           0                 0         -
mcp-auth/src/transport/auth_extractors.rs                     155               155     0.00%          27                27     0.00%         137               137     0.00%           0                 0         -
mcp-auth/src/transport/http_auth.rs                           303               303     0.00%          20                20     0.00%         216               216     0.00%           0                 0         -
mcp-auth/src/transport/stdio_auth.rs                          268               268     0.00%          22                22     0.00%         195               195     0.00%           0                 0         -
mcp-auth/src/transport/websocket_auth.rs                      351               351     0.00%          23                23     0.00%         257               257     0.00%           0                 0         -
mcp-auth/src/validation.rs                                    144               144     0.00%          13                13     0.00%          95                95     0.00%           0                 0         -
mcp-auth/src/vault/infisical.rs                               637               637     0.00%          54                54     0.00%         489               489     0.00%           0                 0         -
mcp-auth/src/vault/mod.rs                                     135               135     0.00%          17                17     0.00%          92                92     0.00%           0                 0         -
mcp-cli-derive/src/lib.rs                                     324               324     0.00%          22                22     0.00%         262               262     0.00%           0                 0         -
mcp-cli/src/config.rs                                          81                68    16.05%          13                10    23.08%          70                61    12.86%           0                 0         -
mcp-cli/src/lib.rs                                             15                15     0.00%           5                 5     0.00%          15                15     0.00%           0                 0         -
mcp-cli/src/server.rs                                         241               241     0.00%          34                34     0.00%         207               207     0.00%           0                 0         -
mcp-cli/src/utils.rs                                          101               101     0.00%          13                13     0.00%          73                73     0.00%           0                 0         -
mcp-logging/src/aggregation.rs                                311               311     0.00%          27                27     0.00%         228               228     0.00%           0                 0         -
mcp-logging/src/alerting.rs                                   552               344    37.68%          39                17    56.41%         419               226    46.06%           0                 0         -
mcp-logging/src/correlation.rs                                415               415     0.00%          34                34     0.00%         299               299     0.00%           0                 0         -
mcp-logging/src/dashboard.rs                                  391               197    49.62%          21                15    28.57%         394               182    53.81%           0                 0         -
mcp-logging/src/metrics.rs                                    306               127    58.50%          36                19    47.22%         329               123    62.61%           0                 0         -
mcp-logging/src/persistence.rs                                360               360     0.00%          26                26     0.00%         202               202     0.00%           0                 0         -
mcp-logging/src/profiling.rs                                  502               496     1.20%          37                36     2.70%         398               354    11.06%           0                 0         -
mcp-logging/src/sanitization.rs                               268               265     1.12%          22                21     4.55%         181               173     4.42%           0                 0         -
mcp-logging/src/structured.rs                                 258               255     1.16%          24                23     4.17%         230               227     1.30%           0                 0         -
mcp-logging/src/telemetry.rs                                   75                34    54.67%          12                 5    58.33%          78                24    69.23%           0                 0         -
mcp-monitoring/src/collector.rs                               179                78    56.42%          19                 8    57.89%         133                52    60.90%           0                 0         -
mcp-monitoring/src/config.rs                                    3                 0   100.00%           1                 0   100.00%           8                 0   100.00%           0                 0         -
mcp-monitoring/src/lib.rs                                       3                 0   100.00%           1                 0   100.00%           3                 0   100.00%           0                 0         -
mcp-monitoring/src/metrics.rs                                   3                 3     0.00%           1                 1     0.00%          11                11     0.00%           0                 0         -
mcp-protocol/src/error.rs                                     149               109    26.85%          24                15    37.50%         115                81    29.57%           0                 0         -
mcp-protocol/src/lib.rs                                        12                12     0.00%           2                 2     0.00%          11                11     0.00%           0                 0         -
mcp-protocol/src/model.rs                                      94                91     3.19%          22                21     4.55%         118               111     5.93%           0                 0         -
mcp-protocol/src/validation.rs                                126               126     0.00%          15                15     0.00%          94                94     0.00%           0                 0         -
mcp-security/src/config.rs                                      4                 0   100.00%           1                 0   100.00%           9                 0   100.00%           0                 0         -
mcp-security/src/lib.rs                                         3                 0   100.00%           1                 0   100.00%           3                 0   100.00%           0                 0         -
mcp-security/src/middleware.rs                                 18                 3    83.33%           3                 0   100.00%          25                 3    88.00%           0                 0         -
mcp-security/src/validation.rs                                 10                10     0.00%           1                 1     0.00%          11                11     0.00%           0                 0         -
mcp-server/src/alerting_endpoint.rs                           117               117     0.00%          15                15     0.00%         110               110     0.00%           0                 0         -
mcp-server/src/backend.rs                                     112                97    13.39%          25                21    16.00%          97                84    13.40%           0                 0         -
mcp-server/src/context.rs                                      55                14    74.55%          10                 3    70.00%          46                16    65.22%           0                 0         -
mcp-server/src/dashboard_endpoint.rs                          104               104     0.00%          12                12     0.00%          79                79     0.00%           0                 0         -
mcp-server/src/handler.rs                                     262               160    38.93%          48                25    47.92%         205               112    45.37%           0                 0         -
mcp-server/src/health_endpoint.rs                              83                83     0.00%           5                 5     0.00%          91                91     0.00%           0                 0         -
mcp-server/src/metrics_endpoint.rs                            133               133     0.00%           7                 7     0.00%          86                86     0.00%           0                 0         -
mcp-server/src/middleware.rs                                  110                15    86.36%          11                 3    72.73%          92                 5    94.57%           0                 0         -
mcp-server/src/server.rs                                      327               111    66.06%          38                19    50.00%         230                77    66.52%           0                 0         -
mcp-transport/src/batch.rs                                    191               191     0.00%          14                14     0.00%         128               128     0.00%           0                 0         -
mcp-transport/src/config.rs                                    15                12    20.00%           5                 4    20.00%          15                12    20.00%           0                 0         -
mcp-transport/src/http.rs                                     651               634     2.61%          39                36     7.69%         436               406     6.88%           0                 0         -
mcp-transport/src/lib.rs                                       13                 3    76.92%           1                 0   100.00%          12                 3    75.00%           0                 0         -
mcp-transport/src/stdio.rs                                    233               186    20.17%          17                12    29.41%         162               119    26.54%           0                 0         -
mcp-transport/src/streamable_http.rs                          223               223     0.00%          19                19     0.00%         165               165     0.00%           0                 0         -
mcp-transport/src/validation.rs                               191               191     0.00%          14                14     0.00%         135               135     0.00%           0                 0         -
mcp-transport/src/websocket.rs                                 15                 9    40.00%           5                 3    40.00%          17                11    35.29%           0                 0         -
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                       20242             16458    18.69%        1791              1476    17.59%       15871             12667    20.19%           0                 0         -

View full report on Codecov

@avrabe avrabe merged commit d075235 into main Jul 15, 2025
22 of 23 checks passed
@avrabe avrabe deleted the fix/ci-test-failures branch July 15, 2025 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants