Skip to content

refactor(agent): unify external MCP config loading - #774

Closed
beruro wants to merge 1 commit into
developfrom
junyu/unify-mcp-config-loader
Closed

refactor(agent): unify external MCP config loading#774
beruro wants to merge 1 commit into
developfrom
junyu/unify-mcp-config-loader

Conversation

@beruro

@beruro beruro commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Problem

External MCP discovery and import each carried an identical JSON loader that inferred missing transport types and translated legacy http entries. Keeping those copies separate made it possible for detection to accept a config that import later interpreted differently.

Solution

Move external MCP normalization into one private external_import::mcp_config module used by both detection and import. The shared boundary preserves the existing behavior and error messages: missing type becomes stdio or streamableHttp based on url, legacy http becomes streamableHttp, explicit supported types remain unchanged, and files without an object-valued mcpServers map are treated as empty. Focused tests now pin those compatibility rules.

Potential risks

The risk is changing compatibility with third-party MCP JSON formats or error reporting. The implementation is a direct extraction of the two byte-for-byte-equivalent paths, and regression tests cover every normalization branch plus the empty-map fallback. It changes no persisted ORGII format, public API, or write path. Rollback is a single-commit revert.

Architecture audit

  • Covered module ownership, dependency direction, canonical MCP types, external wire normalization, detection/import parity, error semantics, and producing-boundary tests.
  • Intentionally skipped UI/rendering, FSM, initialization lifecycle, retained background work, and persistence migration layers because this pure loader refactor does not touch them.

Verification

  • cargo fmt --manifest-path src-tauri/Cargo.toml --all -- --check — passed.
  • cargo test -p agent_core external_import --lib — 25 passed, including the two new loader regressions.
  • Repository commit hook — scoped agent_core Cargo clippy passed.
  • cargo clippy -p agent_core --all-targets -- -D warnings — the full dependency-inclusive command was blocked by the pre-existing unchanged crates/orgtrack-core/src/sources/imported_history/window.rs:189 collapsible_else_if warning; no warning originated in this diff.
  • git diff --check — passed.
  • No TypeScript or UI files changed, so frontend typecheck and visual evidence are not applicable.

@beruro

beruro commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by #780, which preserves this change as an independent commit and has passed the consolidated CI suite. The source branch is retained for recovery.

@beruro beruro closed this Aug 11, 2026
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