Skip to content

Add custom MCP server URL support in Node.js SDK#129

Merged
pontemonti merged 19 commits intomainfrom
copilot/add-custom-mcp-url-support
Jan 26, 2026
Merged

Add custom MCP server URL support in Node.js SDK#129
pontemonti merged 19 commits intomainfrom
copilot/add-custom-mcp-url-support

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 29, 2025

Custom MCP Server URL Support Implementation Plan

  • Update getMCPServerConfigsFromManifest() to respect custom URLs when provided in ToolingManifest.json
  • Update documentation/comments to reflect support for custom URLs in manifest
  • Add tests to validate custom URL functionality
  • Address code review feedback (remove unused variables, improve type safety)
  • Run security checks (0 vulnerabilities found)
  • Revert unnecessary optional url field change
  • Improve test assertions to validate full URLs
  • Add mcpServerUniqueName fallback logic
  • Replace 'any' type with proper interface
  • Fix test environment variable handling
  • Add ESM support flag to test scripts
  • Use cross-env for cross-platform compatibility
  • Add test coverage for headers field

Implementation Complete

This PR adds support for custom MCP server URLs in the Node.js SDK, replicating the functionality from the .NET SDK PR #147.

Changes Made:

  1. Modified McpToolServerConfigurationService.ts:
    • The getMCPServerConfigsFromManifest() method now checks for custom URLs in manifest entries before falling back to default URL building
    • Added support for mcpServerUniqueName as fallback when mcpServerName is not provided (matching .NET implementation)
    • Replaced any type with proper MCPServerManifestEntry interface for type safety
    • Added validation to throw error if neither name field is provided
    • Preserves custom headers from manifest entries
  2. Added MCPServerManifestEntry interface in contracts.ts:
    • Properly types manifest entries with optional mcpServerName, mcpServerUniqueName, url, and headers fields
    • Separates the manifest entry type from the returned MCPServerConfig type for clarity
  3. Enhanced documentation: Updated JSDoc comments with examples showing how to use custom URLs and the fallback behavior
  4. Added comprehensive tests: Created 10 unit tests covering various scenarios including custom URLs, default URLs, mixed configs, edge cases, the mcpServerUniqueName fallback logic, error handling, and custom headers preservation. Tests validate full URLs using Utility.BuildMcpServerUrl() for precision.
  5. Fixed test environment handling: Updated test to use the same pattern as other tests in the repository for managing process.env
  6. Added ESM support: Updated test scripts to include NODE_OPTIONS=--experimental-vm-modules flag to properly handle ES module imports with .js extensions used by the @modelcontextprotocol/sdk package
  7. Cross-platform compatibility: Added cross-env package and updated all test scripts to use it for setting NODE_OPTIONS, ensuring tests work correctly on Windows, macOS, and Linux

Usage:

Users can now specify custom MCP server URLs and headers in their ToolingManifest.json:

{
  "mcpServers": [
    {
      "mcpServerName": "customServer",
      "url": "http://localhost:3000/custom-mcp",
      "headers": {
        "Authorization": "Bearer token123",
        "X-Custom-Header": "custom-value"
      }
    },
    {
      "mcpServerName": "mcp_MailTools"
    },
    {
      "mcpServerUniqueName": "mcp_OneDriveServer"
    }
  ]
}

The server name is determined by using mcpServerName if present, otherwise falling back to mcpServerUniqueName. Custom headers can be specified and will be preserved.

Backward Compatibility:

The changes are fully backward compatible. If the url field is not provided, the URL is automatically constructed using the server name as before.

Testing:

All 241 tests pass across all platforms, including the 10 new tests for custom MCP URL functionality.

Original prompt

This section details on the original issue you should resolve

<issue_title>Custom MCP server URLs are not supported in the SDK</issue_title>
<issue_description>Describe the bug
Custom MCP server URLs are not supported in the SDK.

Proposed solution:
This PR needs to be replicated for the Node.js SDK as well: microsoft/Agent365-dotnet#147
</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 29, 2025 18:40
Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>
…pe safety

Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for custom MCP server URLs in SDK Add custom MCP server URL support in Node.js SDK Dec 29, 2025
Copilot AI requested a review from pontemonti December 29, 2025 18:47
Comment thread packages/agents-a365-tooling/src/contracts.ts
Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>
Comment thread tests/tooling/McpToolServerConfigurationService.test.ts Outdated
Comment thread packages/agents-a365-tooling/src/McpToolServerConfigurationService.ts Outdated
Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>
Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>
Comment thread packages/agents-a365-tooling/src/McpToolServerConfigurationService.ts Outdated
Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread packages/agents-a365-tooling/src/McpToolServerConfigurationService.ts Outdated
Comment thread tests/tooling/McpToolServerConfigurationService.test.ts
…vice.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@pontemonti pontemonti enabled auto-merge (squash) January 21, 2026 17:38
tmlsousa
tmlsousa previously approved these changes Jan 22, 2026
Comment thread packages/agents-a365-tooling/src/contracts.ts Outdated
Comment thread packages/agents-a365-tooling/src/McpToolServerConfigurationService.ts Outdated
Removed commented-out MCP server configuration.
@pontemonti pontemonti merged commit aa91fee into main Jan 26, 2026
7 checks passed
@pontemonti pontemonti deleted the copilot/add-custom-mcp-url-support branch January 26, 2026 21:10
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.

Custom MCP server URLs are not supported in the SDK

6 participants