[releases/28.x] [MCP] Application should encode non-ASCII Company / ConfigurationName in generated MCP connection string#8415
Open
onbuyuka wants to merge 1 commit into
Open
Conversation
…#8311) The MCP connection string generated by `MCPConfigImplementation.BuildConnectionStringJson` writes `Company` and `ConfigurationName` verbatim into the JSON the customer copies into their MCP client. When either value contains non-ASCII characters (e.g., Polish ą, ę, ś, ć, ż, ź, ł, ó, ń, or German *München*) the resulting connection string cannot be sent as HTTP header values to the Server Runtime, because HTTP headers only support ASCII per the HTTP spec. This PR wraps non-ASCII `Company` and `ConfigurationName` values using the MCP encoding scheme negotiated with Server Runtime: `` =?base64?{base64-of-utf8-bytes}?= `` ASCII values are emitted unchanged so existing MCP client configurations keep working. Encoding is limited to `Company` and `ConfigurationName`: - `TenantId` is always a GUID - `EnvironmentName` is restricted to ASCII by SaaS provisioning - `MCPPrefix` / `MCPUrl` are hard-coded Labels Detection uses `Codeunit Regex` with `[^\x00-\x7F]`, mirroring the ASCII check already used for the ISO Code field on `Country/Region` in BaseApp. - This PR: [AB#636661](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/636661) (Application — AL connection-string generator) - Server Runtime counterpart: [AB#631087](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/631087) (resolved) - Server-side decoding tasks: [AB#634735](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/634735) (FTWSE), [AB#634736](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/634736) (Gateway), [AB#634737](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/634737) (NST), [AB#634738](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/634738) (Doc) - `src/System Application/App/MCP/app.json` — added `Base64 Convert` and `Regex` dependencies - `src/System Application/App/MCP/src/Configuration/Codeunits/MCPConfigImplementation.Codeunit.al` — added `EncodeForMCPHeaderIfNonAscii` and wired it into `BuildConnectionStringJson` - `src/System Application/Test Library/MCP/src/MCPConfigTestLibrary.Codeunit.al` — passthrough so the helper is reachable from tests - `src/System Application/Test/MCP/app.json` — added `Base64 Convert` dependency - `src/System Application/Test/MCP/src/MCPConfigTest.Codeunit.al` — 3 new connection-string tests + `#region` reorganization (no test bodies modified) 3 new tests in `MCP Config Test` (codeunit 130130): 1. `TestConnectionStringWithAsciiConfigNameIsNotEncoded` — ASCII configuration name appears verbatim, no `=?base64?` wrapper anywhere. 2. `TestConnectionStringWithNonAsciiConfigNameIsBase64Encoded` — non-ASCII configuration name (`'München-' + GUID`) is wrapped as `=?base64?<expected>?=` with the expected base64 computed via `Base64 Convert.ToBase64(name, TextEncoding::UTF8)`. 3. `TestEncodeForMCPHeaderIfNonAsciiHelper` — direct helper unit test covering both branches. All `MCP Config Test` tests pass locally after the change. Fixes [AB#636661](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/636661) --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Backport of bug #636661 to releases/28.x.
Fixes AB#637387
Original PR: #8311
Conflict resolution
app.json(both App and Test): Adjusted newBase64 ConvertandRegexdependencies (andMicrosoft User Feedback) to28.2.0.0to match the release branch.Test/MCP/src/MCPConfigTest.Codeunit.al: Kept theTestFindMissingObjectWarningsForQueryTooltest already present on 28.x (the cherry-picked side was empty at that location).