Skip to content

feat(mcp): remote servers and duplicate detection#131

Merged
gblanc-1a merged 9 commits intoAmadeusITGroup:mainfrom
wherka-ama:feature/mcp-remote-servers-duplicate-detection
Jan 28, 2026
Merged

feat(mcp): remote servers and duplicate detection#131
gblanc-1a merged 9 commits intoAmadeusITGroup:mainfrom
wherka-ama:feature/mcp-remote-servers-duplicate-detection

Conversation

@wherka-ama
Copy link
Member

Description

This PR adds comprehensive support for remote MCP servers (HTTP/SSE) and implements automatic duplicate detection to prevent conflicts when multiple collections define the same MCP server.

Key improvements:

  • Remote MCP servers can now be defined alongside stdio servers
  • Automatic duplicate detection ensures only one instance of each server is active
  • JSONC parser handles VS Code's mcp.json format (trailing commas, comments)
  • Comprehensive test coverage with 43 new tests

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📝 Documentation update
  • 🧪 Test coverage improvement

Related Issues

Relates to MCP integration improvements and collection schema enhancements.

Changes Made

Type System

  • Added isStdioServerConfig() and isRemoteServerConfig() type guards for proper server type discrimination
  • Updated McpServerDefinition to support union of stdio and remote server configs
  • Fixed type aliasing issue where remote servers were incorrectly treated as stdio-only

Core Functionality

  • Remote Server Support: Refactored McpConfigService.processServerDefinition() to handle both stdio and remote (HTTP/SSE) servers
  • Variable Substitution: Extended to support URLs and headers in remote servers (e.g., ${env:API_TOKEN})
  • Duplicate Detection: Added computeServerIdentity() to generate unique identities:
    • Stdio: stdio:{command}:{args|joined|by|pipe}
    • Remote: remote:{url}
  • Automatic Deduplication: Added detectAndDisableDuplicates() that:
    • Keeps first installed server enabled
    • Disables subsequent duplicates with descriptive messages
    • Re-enables a duplicate when the active server is removed
    • Maintains invariant: at least one active until all bundles removed
  • JSONC Parsing: Use jsonc-parser to handle VS Code's mcp.json format (trailing commas, comments)

Integration

  • Integrated duplicate detection into McpServerManager.installServers() lifecycle
  • Updated MarketplaceViewProvider to display both stdio (⚡) and remote (🌐) server types with appropriate details

Documentation

  • Author Guide (docs/author-guide/collection-schema.md): Added remote server examples and duplicate detection behavior
  • Contributor Guide (docs/contributor-guide/architecture/mcp-integration.md): Added algorithm details, flowchart, and type guard documentation
  • Design Document (.kiro/specs/mcp-remote-servers/design.md): Comprehensive design rationale and implementation details

Testing

Test Coverage

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing completed
  • All existing tests pass

43 new tests added:

  • McpConfigService.remoteServers.test.ts (22 tests): Type guards, remote server processing, variable substitution
  • McpConfigService.duplicateDetection.test.ts (16 tests): Identity computation, duplicate detection logic, edge cases
  • McpConfigService.duplicateLifecycle.test.ts (5 tests): Install multiple collections, gradual removal, invariant verification

Test Results:

  • All 2223 tests passing (2218 existing + 5 new lifecycle tests)
  • No regressions introduced

Manual Testing Steps

  1. Create collection with remote MCP server (HTTP/SSE)
  2. Install collection and verify server appears in VS Code's mcp.json
  3. Install second collection with same server (same URL or command+args)
  4. Verify duplicate is disabled with description noting the original
  5. Uninstall first collection
  6. Verify second collection's server becomes active
  7. Test JSONC parsing by adding trailing comma to mcp.json

Tested On

  • Linux
  • VS Code Insiders

Screenshots

N/A - Backend changes with no UI modifications (except MCP server display icons)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Documentation

  • JSDoc comments added/updated
  • Documentation updated:
    • docs/author-guide/collection-schema.md - Remote server examples, duplicate behavior
    • docs/contributor-guide/architecture/mcp-integration.md - Algorithm details, flowchart
    • .kiro/specs/mcp-remote-servers/design.md - Design document

Additional Notes

Breaking Change

The McpServerDefinition type now includes remote server configurations. Existing code that assumes all MCP servers are stdio-based may need updates. However, the change is backward compatible for collection manifests - existing stdio servers continue to work without modification.

JSONC Parser

The switch to jsonc-parser fixes a critical bug where VS Code's mcp.json files with trailing commas or comments would fail to parse. This is a common issue since VS Code's JSON editor allows these by default.

Duplicate Detection Algorithm

The algorithm is designed to be transparent and predictable:

  1. Identity-based: Two servers are duplicates if they have the same identity (command+args for stdio, URL for remote)
  2. First-wins: The first installed server remains active
  3. Lifecycle-aware: When the active server is removed, a disabled duplicate is re-enabled
  4. Type-safe: Stdio and remote servers never conflict (different identity prefixes)

Reviewer Guidelines

Please pay special attention to:

  • Type safety: Verify type guards correctly discriminate stdio vs remote servers
  • Duplicate detection logic: Review computeServerIdentity() and detectAndDisableDuplicates() for edge cases
  • Test coverage: Ensure lifecycle tests cover all scenarios (install, uninstall, re-enable)
  • Documentation clarity: Verify author-facing docs explain duplicate behavior clearly
  • JSONC parsing: Confirm error handling for malformed JSON

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache License 2.0.

The generate-manifest.js script was not copying the mcp/mcpServers field
from collection YAML files to the generated deployment-manifest.yml.
This caused GitHub Release bundles to have no MCP server definitions,
resulting in the extension skipping MCP installation.

Changes:
- Extract mcpServers from collection.mcpServers or collection.mcp.items
- Include mcpServers in the deployment manifest when present
- Add logging for MCP servers count in build output
- Bump package version to 1.0.0 (first stable release with MCP support)

This matches the behavior of AwesomeCopilotAdapter which supports both
mcp.items (schema format) and mcpServers (manifest format).

Fixes MCP servers not being installed from GitHub Release bundles.
Collections will need to rebuild and republish releases for the fix
to take effect.
- Add type guards isStdioServerConfig() and isRemoteServerConfig() for proper
  discrimination between stdio (local process) and remote (HTTP/SSE) servers
- Refactor processServerDefinition() to handle both server types with variable
  substitution for URLs and headers
- Add computeServerIdentity() to compute unique identity for duplicate detection:
  - Stdio: command + args
  - Remote: url
- Add detectAndDisableDuplicates() to automatically disable duplicate servers
  while keeping the first installed active
- Integrate duplicate detection into McpServerManager.installServers()
- Use jsonc-parser for reading mcp.json to handle VS Code's JSONC format
  (trailing commas, comments)
- Update MarketplaceViewProvider to display both stdio and remote server types
- Add comprehensive TDD tests (43 new tests):
  - Type guard tests
  - Remote server processing tests
  - Duplicate detection tests
  - Lifecycle tests (install multiple, remove gradually)
- Update documentation:
  - author-guide/collection-schema.md: remote server examples, duplicate behavior
  - contributor-guide/architecture/mcp-integration.md: algorithm details, flowchart

BREAKING CHANGE: McpServerDefinition type now includes remote server configs
@wherka-ama wherka-ama force-pushed the feature/mcp-remote-servers-duplicate-detection branch from d869fa9 to d10a3b2 Compare January 27, 2026 14:37
@wherka-ama wherka-ama requested a review from dpomian January 27, 2026 16:04
Copy link
Contributor

@gblanc-1a gblanc-1a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I think we might need to add the mcp as part of the lockfile too to be aware of which package installed which mcp at some point.
  • I tried to generate a repository on my side with it to try doing a bit of QA with it but didn't manage to make it work in local. I probably miss something

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to add one HTTP mcp server as example and part of the scaffolding

Waldek Herka added 7 commits January 27, 2026 22:23
- Add jsonc-parser to production dependencies (Critical)
- Add HTML escaping to prevent XSS in MCP server display (High)
- Replace (config as any) casts with proper type narrowing using
  McpStdioServerConfig and McpRemoteServerConfig types (Medium)
- Add reEnableDuplicatesAfterRemoval() to automatically re-enable
  duplicate servers when the active server is uninstalled (Medium)

All 2377 tests passing.
…cards

- Fix type guard isRemoteServerConfig() to infer remote server when url
  is present without command (common in YAML configs without explicit type)
- Update isStdioServerConfig() to be consistent with remote detection
- Add MCP servers count to bundle card content breakdown display
- Add countMcpServers() helper to extract count from bundle/manifest data
- Show '🔌 MCP Servers' in marketplace bundle cards alongside other content

This fixes duplicate detection not working when YAML configs don't
explicitly set type: http/sse, and makes MCP servers visible to users
before installation.
Add OPTION 2 section with remote MCP server examples:
- HTTP endpoint with authentication headers
- SSE streaming endpoint
- GitHub Copilot MCP endpoint example

Renumber custom local server to OPTION 3.
- GitHubAdapter: attach mcpServers from manifest to bundle object
- GitLabAdapter: attach both prompts and mcpServers from manifest

This enables the marketplace to show MCP servers count in bundle cards
before installation, not just after.
Add MCP servers count with 🔌 icon to the bundle details page content
breakdown section, consistent with the marketplace tile display.
…pters

- AwesomeCopilotAdapter: extract mcpServers, attach to bundle, include in breakdown
- LocalAwesomeCopilotAdapter: same changes for local collections
- Update calculateBreakdown() to accept optional mcpServers parameter

This ensures MCP servers count is available in the pre-calculated breakdown
used by the marketplace for pre-installation display.
@gblanc-1a gblanc-1a merged commit 918ad08 into AmadeusITGroup:main Jan 28, 2026
14 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in Prompt Registry Jan 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants