-
Notifications
You must be signed in to change notification settings - Fork 5
Add custom MCP server URL support in Node.js SDK #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>
…pe safety Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>
Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>
packages/agents-a365-tooling/src/McpToolServerConfigurationService.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>
Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>
packages/agents-a365-tooling/src/McpToolServerConfigurationService.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>
Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for custom MCP server URLs in the Node.js SDK, mirroring functionality from the .NET SDK. The implementation allows users to specify custom URLs in their ToolingManifest.json while maintaining backward compatibility with automatic URL construction.
Key Changes:
- Enhanced
getMCPServerConfigsFromManifest()to respect custom URLs when provided in manifest entries - Added
MCPServerManifestEntryinterface for proper typing of manifest entries, separating concerns fromMCPServerConfig - Implemented fallback logic to use
mcpServerUniqueNamewhenmcpServerNameis not provided, matching .NET implementation
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
packages/agents-a365-tooling/src/McpToolServerConfigurationService.ts |
Core implementation: checks for custom URLs in manifest before falling back to default URL building; adds name fallback logic and validation |
packages/agents-a365-tooling/src/contracts.ts |
Adds MCPServerManifestEntry interface to properly type manifest entries with optional fields |
tests/tooling/McpToolServerConfigurationService.test.ts |
Comprehensive test suite with 9 tests covering custom URLs, default URLs, mixed configs, edge cases, fallback logic, and error handling |
tests/package.json |
Adds NODE_OPTIONS flag to test scripts for ESM support needed by the MCP SDK package |
Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>
There was a problem hiding this 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
packages/agents-a365-tooling/src/McpToolServerConfigurationService.ts
Outdated
Show resolved
Hide resolved
…vice.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>
There was a problem hiding this 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
| * | ||
| * Each server entry can optionally include a "url" field to specify a custom MCP server URL. | ||
| * If the "url" field is not provided, the URL will be automatically constructed using the server name. | ||
| * The server name is determined by using "mcpServerName" if present, otherwise "mcpServerUniqueName". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be the other way around, i.e. use the unique name as default and if that does not exist then server name? Given that the unique name is usually used to construct the URL?
Actually, I'm wondering what is even the point of having a server name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the current behavior in the .NET SDK and how we have been parsing the tooling manifest files previously. The idea was to just have one property since mcpServerName and mcpServerUniqueName are supposed to be the same thing - so we were getting rid of mcpServerUniqueName and just used mcpServerName. We can revisit the contract later.
There was a problem hiding this 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.
Custom MCP Server URL Support Implementation Plan
getMCPServerConfigsFromManifest()to respect custom URLs when provided in ToolingManifest.jsonImplementation 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:
McpToolServerConfigurationService.ts:getMCPServerConfigsFromManifest()method now checks for custom URLs in manifest entries before falling back to default URL buildingmcpServerUniqueNameas fallback whenmcpServerNameis not provided (matching .NET implementation)anytype with properMCPServerManifestEntryinterface for type safetyMCPServerManifestEntryinterface incontracts.ts:mcpServerName,mcpServerUniqueName,url, andheadersfieldsMCPServerConfigtype for clarityUtility.BuildMcpServerUrl()for precision.process.envNODE_OPTIONS=--experimental-vm-modulesflag to properly handle ES module imports with.jsextensions used by the@modelcontextprotocol/sdkpackagecross-envpackage and updated all test scripts to use it for settingNODE_OPTIONS, ensuring tests work correctly on Windows, macOS, and LinuxUsage:
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
mcpServerNameif present, otherwise falling back tomcpServerUniqueName. Custom headers can be specified and will be preserved.Backward Compatibility:
The changes are fully backward compatible. If the
urlfield 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
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.