Skip to content

refactor: migrate to rmcp-based architecture#95

Merged
avrabe merged 19 commits intomainfrom
refactor/rmcp-migration
Mar 28, 2026
Merged

refactor: migrate to rmcp-based architecture#95
avrabe merged 19 commits intomainfrom
refactor/rmcp-migration

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented Mar 28, 2026

Summary

Migrate from full parallel MCP SDK to targeted extensions built on the official rmcp SDK (v1.3, 6.3M downloads).

What changed:

  • 3 crates renamed (decoupled from MCP protocol):
    • pulseengine-mcp-loggingpulseengine-logging
    • pulseengine-mcp-security-middlewarepulseengine-security
    • pulseengine-mcp-authpulseengine-auth (removed mcp-protocol dependency, -212 LOC)
  • 2 new rmcp extension crates (fill gaps rmcp doesn't cover):
    • pulseengine-mcp-resources — resource URI template router for rmcp
    • pulseengine-mcp-apps — MCP Apps / UI Resources extension for rmcp
  • 5 examples rewritten to use rmcp + new crates
  • conformance-server removed (rmcp has its own)
  • Migration guide at docs/MIGRATION.md
  • STPA safety analysis with 58 artifacts covering migration risks

Why: rmcp now covers protocol types, transports, and macros well. Maintaining a parallel implementation is unsustainable. We keep only what rmcp lacks: security middleware, auth/RBAC, observability, resource routing, and MCP Apps.

12 → 5 maintained crates. ~31K lines of spec-tracking code offloaded to rmcp.

Test plan

  • All 3 PoCs validated (Tower auth, resource router, MCP Apps)
  • cargo check --workspace passes
  • pulseengine-logging: 133 tests pass
  • pulseengine-security: 65 tests pass
  • pulseengine-auth: 265 tests pass
  • pulseengine-mcp-resources: 15 tests pass
  • pulseengine-mcp-apps: 16 tests pass
  • All examples compile against rmcp
  • rivet validate passes (98% traceability coverage)

avrabe added 16 commits March 28, 2026 09:03
Rivet project initialized with STPA schema for rmcp migration safety
analysis. 58 artifacts covering losses, hazards, constraints, UCAs,
and loss scenarios for migrating from full MCP stack to rmcp extensions.

Phase 0+1 design spec and implementation plan ready for execution.
Working PoC proving Tower middleware can intercept rmcp HTTP
requests, enforce Bearer auth, and propagate AuthContext into
MCP tool handlers via http::request::Parts extensions.
Implements PoC 3 proving rmcp 1.3 supports the MCP Apps extension
pattern (SEP-1865) for serving interactive HTML via resources and tools.
Implements a matchit-based ResourceRouter that maps MCP URI templates
(file:///, config://) to handler functions, overriding list_resource_templates
and read_resource on ServerHandler alongside #[tool_handler] tools.
Generic structured logging crate — not MCP-specific.
Provides credential scrubbing, metrics, alerting, correlation IDs.
Generic Axum/Tower security middleware — not MCP-specific.
Remove unused mcp-protocol dependency.
URI-template-based resource router built on matchit for rmcp MCP
servers. Provides ResourceRouter<S> with scheme-aware URI matching,
handler dispatch, and template listing for ServerHandler integration.
Generic auth/RBAC/session crate — not MCP-specific.
Remove mcp-protocol dependency, rename MCP-prefixed types
(McpPermission → Permission, McpPermissionChecker → PermissionChecker).
Middleware now operates on generic (method, params) instead of MCP Request.
mcp-logging/ → pulseengine-logging/
mcp-auth/ → pulseengine-auth/
mcp-security-middleware/ → pulseengine-security/

Remove poc/ directory — validation complete, results in poc/RESULTS.md
preserved in git history.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 28, 2026

Code Coverage Report 📊

Local Coverage: 8.08%
Validation: Handled by Codecov

Note: Coverage validation is now performed by Codecov to ensure consistency across all platforms.

Coverage Details
Filename                                                       Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
conformance-tests/src/config.rs                                     51                51     0.00%           5                 5     0.00%          28                28     0.00%           0                 0         -
conformance-tests/src/main.rs                                      144               144     0.00%           6                 6     0.00%          84                84     0.00%           0                 0         -
conformance-tests/src/runner.rs                                    258               258     0.00%           8                 8     0.00%         139               139     0.00%           0                 0         -
conformance-tests/src/transport.rs                                 119               119     0.00%           8                 8     0.00%          75                75     0.00%           0                 0         -
integration-tests/src/auth_server_integration.rs                   317                35    88.96%          26                 9    65.38%         204                43    78.92%           0                 0         -
integration-tests/src/cli_server_integration.rs                    351                21    94.02%          35                 5    85.71%         291                15    94.85%           0                 0         -
integration-tests/src/end_to_end_scenarios.rs                      616                18    97.08%          40                 9    77.50%         442                 9    97.96%           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                    338                35    89.64%          28                 8    71.43%         256                43    83.20%           0                 0         -
integration-tests/src/transport_server_integration.rs              369                40    89.16%          31                11    64.52%         286                47    83.57%           0                 0         -
mcp-client/src/client.rs                                           389               389     0.00%          49                49     0.00%         290               290     0.00%           0                 0         -
mcp-client/src/error.rs                                             17                17     0.00%           5                 5     0.00%          19                19     0.00%           0                 0         -
mcp-client/src/transport.rs                                        135               135     0.00%          17                17     0.00%          73                73     0.00%           0                 0         -
mcp-external-validation/src/auth_integration.rs                    639               639     0.00%          24                24     0.00%         485               485     0.00%           0                 0         -
mcp-external-validation/src/bin/mcp-compliance-report.rs           516               516     0.00%          19                19     0.00%         397               397     0.00%           0                 0         -
mcp-external-validation/src/bin/mcp-validate.rs                    364               364     0.00%          12                12     0.00%         278               278     0.00%           0                 0         -
mcp-external-validation/src/bin/stdio-test-runner.rs               163               163     0.00%           2                 2     0.00%          98                98     0.00%           0                 0         -
mcp-external-validation/src/config.rs                              241               241     0.00%          24                24     0.00%         256               256     0.00%           0                 0         -
mcp-external-validation/src/cross_language.rs                      709               709     0.00%          49                49     0.00%         640               640     0.00%           0                 0         -
mcp-external-validation/src/ecosystem.rs                           508               508     0.00%          29                29     0.00%         455               455     0.00%           0                 0         -
mcp-external-validation/src/error.rs                                63                63     0.00%          12                12     0.00%          61                61     0.00%           0                 0         -
mcp-external-validation/src/fuzzing.rs                             911               911     0.00%          44                44     0.00%         552               552     0.00%           0                 0         -
mcp-external-validation/src/inspector.rs                           452               452     0.00%          28                28     0.00%         361               361     0.00%           0                 0         -
mcp-external-validation/src/jsonrpc.rs                            1363              1363     0.00%          58                58     0.00%         983               983     0.00%           0                 0         -
mcp-external-validation/src/lib.rs                                  67                67     0.00%           6                 6     0.00%          38                38     0.00%           0                 0         -
mcp-external-validation/src/mcp_semantic.rs                       1120              1120     0.00%          74                74     0.00%         859               859     0.00%           0                 0         -
mcp-external-validation/src/mcp_validator.rs                       244               244     0.00%          20                20     0.00%         201               201     0.00%           0                 0         -
mcp-external-validation/src/proptest.rs                            858               858     0.00%          62                62     0.00%         536               536     0.00%           0                 0         -
mcp-external-validation/src/python_sdk.rs                          679               679     0.00%          50                50     0.00%         705               705     0.00%           0                 0         -
mcp-external-validation/src/report.rs                              241               241     0.00%          27                27     0.00%         209               209     0.00%           0                 0         -
mcp-external-validation/src/security.rs                            673               673     0.00%          37                37     0.00%         574               574     0.00%           0                 0         -
mcp-external-validation/src/test_helpers/assertions.rs             546               546     0.00%          50                50     0.00%         418               418     0.00%           0                 0         -
mcp-external-validation/src/test_helpers/mod.rs                    100               100     0.00%          12                12     0.00%          63                63     0.00%           0                 0         -
mcp-external-validation/src/test_helpers/server_harness.rs         365               365     0.00%          35                35     0.00%         273               273     0.00%           0                 0         -
mcp-external-validation/src/validator.rs                           603               603     0.00%          30                30     0.00%         393               393     0.00%           0                 0         -
mcp-macros/src/lib.rs                                               77                77     0.00%          14                14     0.00%          42                42     0.00%           0                 0         -
mcp-macros/src/mcp_backend.rs                                       86                86     0.00%           7                 7     0.00%         206               206     0.00%           0                 0         -
mcp-macros/src/mcp_prompt.rs                                       173               173     0.00%          11                11     0.00%         122               122     0.00%           0                 0         -
mcp-macros/src/mcp_resource.rs                                     221               221     0.00%          11                11     0.00%         161               161     0.00%           0                 0         -
mcp-macros/src/mcp_server.rs                                       151               151     0.00%          10                10     0.00%         346               346     0.00%           0                 0         -
mcp-macros/src/mcp_tool.rs                                         867               867     0.00%          40                40     0.00%         737               737     0.00%           0                 0         -
mcp-macros/src/utils.rs                                            141               141     0.00%          13                13     0.00%         107               107     0.00%           0                 0         -
mcp-protocol/src/error.rs                                          206               166    19.42%          28                19    32.14%         164               130    20.73%           0                 0         -
mcp-protocol/src/errors.rs                                         115               115     0.00%          15                15     0.00%          58                58     0.00%           0                 0         -
mcp-protocol/src/lib.rs                                             12                 7    41.67%           2                 1    50.00%          11                 8    27.27%           0                 0         -
mcp-protocol/src/model.rs                                          559               543     2.86%          94                91     3.19%         689               675     2.03%           0                 0         -
mcp-protocol/src/validation.rs                                    1116              1116     0.00%          44                44     0.00%         673               673     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                                177               177     0.00%          19                19     0.00%         134               134     0.00%           0                 0         -
mcp-server/src/backend.rs                                           80                71    11.25%          26                22    15.38%          68                59    13.24%           0                 0         -
mcp-server/src/builder_trait.rs                                     44                44     0.00%           3                 3     0.00%          37                37     0.00%           0                 0         -
mcp-server/src/cli_helpers.rs                                      220               206     6.36%          25                22    12.00%         142               132     7.04%           0                 0         -
mcp-server/src/common_backend.rs                                    39                39     0.00%          11                11     0.00%          31                31     0.00%           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                               232               232     0.00%          20                20     0.00%         129               129     0.00%           0                 0         -
mcp-server/src/handler.rs                                         1239              1102    11.06%         144               114    20.83%         838               718    14.32%           0                 0         -
mcp-server/src/health_endpoint.rs                                  101               101     0.00%           6                 6     0.00%         108               108     0.00%           0                 0         -
mcp-server/src/metrics_endpoint.rs                                 155               155     0.00%           9                 9     0.00%          96                96     0.00%           0                 0         -
mcp-server/src/middleware.rs                                        76                 9    88.16%           9                 1    88.89%          64                 3    95.31%           0                 0         -
mcp-server/src/observability/collector.rs                          179                78    56.42%          19                 8    57.89%         133                52    60.90%           0                 0         -
mcp-server/src/observability/config.rs                               3                 0   100.00%           1                 0   100.00%           8                 0   100.00%           0                 0         -
mcp-server/src/observability/metrics.rs                              3                 3     0.00%           1                 1     0.00%          11                11     0.00%           0                 0         -
mcp-server/src/observability/mod.rs                                  3                 0   100.00%           1                 0   100.00%           3                 0   100.00%           0                 0         -
mcp-server/src/server.rs                                           326               126    61.35%          45                26    42.22%         240                94    60.83%           0                 0         -
mcp-server/src/tool_context.rs                                     278               266     4.32%          62                59     4.84%         254               242     4.72%           0                 0         -
mcp-transport/src/batch.rs                                         324               324     0.00%          21                21     0.00%         202               202     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                                         2062              2048     0.68%         136               133     2.21%        1340              1314     1.94%           0                 0         -
mcp-transport/src/http_test.rs                                      44                44     0.00%           4                 4     0.00%          29                29     0.00%           0                 0         -
mcp-transport/src/lib.rs                                            84                69    17.86%          18                16    11.11%          82                70    14.63%           0                 0         -
mcp-transport/src/stdio.rs                                         565               552     2.30%          48                43    10.42%         368               350     4.89%           0                 0         -
mcp-transport/src/streamable_http.rs                               609               609     0.00%          54                54     0.00%         474               474     0.00%           0                 0         -
mcp-transport/src/validation.rs                                    291               291     0.00%          18                18     0.00%         190               190     0.00%           0                 0         -
mcp-transport/src/websocket.rs                                      12                 7    41.67%           5                 3    40.00%          12                 7    41.67%           0                 0         -
pulseengine-auth/src/audit.rs                                      491               363    26.07%          34                23    32.35%         337               238    29.38%           0                 0         -
pulseengine-auth/src/config.rs                                     292               285     2.40%          26                25     3.85%         280               273     2.50%           0                 0         -
pulseengine-auth/src/consent.rs                                    269               269     0.00%          18                18     0.00%         171               171     0.00%           0                 0         -
pulseengine-auth/src/consent/manager.rs                            605               605     0.00%          46                46     0.00%         457               457     0.00%           0                 0         -
pulseengine-auth/src/crypto/encryption.rs                          164               164     0.00%          14                14     0.00%          85                85     0.00%           0                 0         -
pulseengine-auth/src/crypto/hashing.rs                             183               183     0.00%          14                14     0.00%          89                89     0.00%           0                 0         -
pulseengine-auth/src/crypto/keys.rs                                187               187     0.00%          12                12     0.00%         110               110     0.00%           0                 0         -
pulseengine-auth/src/crypto/mod.rs                                  20                20     0.00%           3                 3     0.00%          15                15     0.00%           0                 0         -
pulseengine-auth/src/jwt.rs                                        490               453     7.55%          37                35     5.41%         347               318     8.36%           0                 0         -
pulseengine-auth/src/lib.rs                                         18                15    16.67%           6                 5    16.67%          16                13    18.75%           0                 0         -
pulseengine-auth/src/manager.rs                                   1293              1160    10.29%         119               107    10.08%         961               834    13.22%           0                 0         -
pulseengine-auth/src/manager_vault.rs                              280               280     0.00%          24                24     0.00%         239               239     0.00%           0                 0         -
pulseengine-auth/src/middleware/mcp_auth.rs                        276               276     0.00%          27                27     0.00%         209               209     0.00%           0                 0         -
pulseengine-auth/src/middleware/session_middleware.rs              459               459     0.00%          47                47     0.00%         364               364     0.00%           0                 0         -
pulseengine-auth/src/models.rs                                     912               912     0.00%          47                47     0.00%         545               545     0.00%           0                 0         -
pulseengine-auth/src/monitoring/dashboard_server.rs                390               390     0.00%          37                37     0.00%         516               516     0.00%           0                 0         -
pulseengine-auth/src/monitoring/mod.rs                             267               267     0.00%          13                13     0.00%         221               221     0.00%           0                 0         -
pulseengine-auth/src/monitoring/security_monitor.rs                830               830     0.00%          80                80     0.00%         620               620     0.00%           0                 0         -
pulseengine-auth/src/oauth/authorize.rs                            159               159     0.00%          20                20     0.00%         232               232     0.00%           0                 0         -
pulseengine-auth/src/oauth/bearer.rs                               470               470     0.00%          37                37     0.00%         287               287     0.00%           0                 0         -
pulseengine-auth/src/oauth/client_metadata.rs                      210               210     0.00%          15                15     0.00%         157               157     0.00%           0                 0         -
pulseengine-auth/src/oauth/metadata.rs                              75                75     0.00%           7                 7     0.00%          58                58     0.00%           0                 0         -
pulseengine-auth/src/oauth/mod.rs                                   28                28     0.00%           3                 3     0.00%          23                23     0.00%           0                 0         -
pulseengine-auth/src/oauth/models.rs                                30                30     0.00%           6                 6     0.00%          42                42     0.00%           0                 0         -
pulseengine-auth/src/oauth/pkce.rs                                  85                85     0.00%           9                 9     0.00%          56                56     0.00%           0                 0         -
pulseengine-auth/src/oauth/registration.rs                         148               148     0.00%          11                11     0.00%         127               127     0.00%           0                 0         -
pulseengine-auth/src/oauth/resource.rs                              19                19     0.00%           3                 3     0.00%          13                13     0.00%           0                 0         -
pulseengine-auth/src/oauth/storage.rs                              249               249     0.00%          32                32     0.00%         172               172     0.00%           0                 0         -
pulseengine-auth/src/oauth/token.rs                                248               248     0.00%          26                26     0.00%         289               289     0.00%           0                 0         -
pulseengine-auth/src/permissions/mcp_permissions.rs                538               538     0.00%          39                39     0.00%         385               385     0.00%           0                 0         -
pulseengine-auth/src/security/mod.rs                               214               214     0.00%          13                13     0.00%         162               162     0.00%           0                 0         -
pulseengine-auth/src/security/request_security.rs                  714               714     0.00%          50                50     0.00%         621               621     0.00%           0                 0         -
pulseengine-auth/src/session/mod.rs                                220               220     0.00%           9                 9     0.00%         148               148     0.00%           0                 0         -
pulseengine-auth/src/session/session_manager.rs                    546               546     0.00%          63                63     0.00%         420               420     0.00%           0                 0         -
pulseengine-auth/src/storage.rs                                   1850              1838     0.65%         129               125     3.10%        1110              1095     1.35%           0                 0         -
pulseengine-auth/src/transport/auth_extractors.rs                  267               267     0.00%          32                32     0.00%         181               181     0.00%           0                 0         -
pulseengine-auth/src/transport/http_auth.rs                        476               476     0.00%          27                27     0.00%         284               284     0.00%           0                 0         -
pulseengine-auth/src/transport/stdio_auth.rs                       400               400     0.00%          29                29     0.00%         267               267     0.00%           0                 0         -
pulseengine-auth/src/transport/websocket_auth.rs                   531               531     0.00%          30                30     0.00%         332               332     0.00%           0                 0         -
pulseengine-auth/src/validation.rs                                 271               271     0.00%          22                22     0.00%         155               155     0.00%           0                 0         -
pulseengine-auth/src/vault/infisical.rs                            389               389     0.00%          56                56     0.00%         311               311     0.00%           0                 0         -
pulseengine-auth/src/vault/mod.rs                                  154               154     0.00%          19                19     0.00%         105               105     0.00%           0                 0         -
pulseengine-logging/src/aggregation.rs                             388               388     0.00%          32                32     0.00%         281               281     0.00%           0                 0         -
pulseengine-logging/src/alerting.rs                                604               396    34.44%          43                21    51.16%         464               271    41.59%           0                 0         -
pulseengine-logging/src/correlation.rs                             530               530     0.00%          39                39     0.00%         356               356     0.00%           0                 0         -
pulseengine-logging/src/dashboard.rs                               453               259    42.83%          25                19    24.00%         442               230    47.96%           0                 0         -
pulseengine-logging/src/metrics.rs                                 370               191    48.38%          46                29    36.96%         374               168    55.08%           0                 0         -
pulseengine-logging/src/persistence.rs                             402               402     0.00%          29                29     0.00%         232               232     0.00%           0                 0         -
pulseengine-logging/src/profiling.rs                               955               949     0.63%          68                67     1.47%         774               730     5.68%           0                 0         -
pulseengine-logging/src/sanitization.rs                            409               406     0.73%          31                30     3.23%         275               267     2.91%           0                 0         -
pulseengine-logging/src/structured.rs                              355               352     0.85%          35                34     2.86%         291               288     1.03%           0                 0         -
pulseengine-logging/src/telemetry.rs                                74                61    17.57%           6                 4    33.33%          37                27    27.03%           0                 0         -
pulseengine-mcp-apps/src/content.rs                                 37                37     0.00%           4                 4     0.00%          24                24     0.00%           0                 0         -
pulseengine-mcp-apps/src/lib.rs                                     19                19     0.00%           2                 2     0.00%          16                16     0.00%           0                 0         -
pulseengine-mcp-resources/src/router.rs                            146               146     0.00%          14                14     0.00%          83                83     0.00%           0                 0         -
pulseengine-security/src/auth.rs                                   449               449     0.00%          30                30     0.00%         253               253     0.00%           0                 0         -
pulseengine-security/src/config.rs                                 474               474     0.00%          27                27     0.00%         345               345     0.00%           0                 0         -
pulseengine-security/src/error.rs                                   36                36     0.00%          10                10     0.00%          36                36     0.00%           0                 0         -
pulseengine-security/src/lib.rs                                    168               168     0.00%          14                14     0.00%         112               112     0.00%           0                 0         -
pulseengine-security/src/middleware.rs                             621               621     0.00%          38                38     0.00%         403               403     0.00%           0                 0         -
pulseengine-security/src/profiles.rs                               336               336     0.00%          30                30     0.00%         292               292     0.00%           0                 0         -
pulseengine-security/src/utils.rs                                  368               368     0.00%          28                28     0.00%         197               197     0.00%           0                 0         -
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                            48437             44939     7.22%        3824              3504     8.37%       36290             33356     8.08%           0                 0         -

📋 Full Report: View on Codecov

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 28, 2026

Codecov Report

❌ Patch coverage is 44.44444% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
mcp-protocol/src/error.rs 0.00% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 28, 2026

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 avrabe merged commit cf18e7c into main Mar 28, 2026
21 of 22 checks passed
@avrabe avrabe deleted the refactor/rmcp-migration branch March 28, 2026 20:05
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.

1 participant