Skip to content

[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
releases/28.xfrom
bugs/637387-backport
Open

[releases/28.x] [MCP] Application should encode non-ASCII Company / ConfigurationName in generated MCP connection string#8415
onbuyuka wants to merge 1 commit into
releases/28.xfrom
bugs/637387-backport

Conversation

@onbuyuka
Copy link
Copy Markdown
Contributor

@onbuyuka onbuyuka commented Jun 2, 2026

Summary

Backport of bug #636661 to releases/28.x.

Fixes AB#637387

Original PR: #8311

Conflict resolution

  • app.json (both App and Test): Adjusted new Base64 Convert and Regex dependencies (and Microsoft User Feedback) to 28.2.0.0 to match the release branch.
  • Test/MCP/src/MCPConfigTest.Codeunit.al: Kept the TestFindMissingObjectWarningsForQueryTool test already present on 28.x (the cherry-picked side was empty at that location).

…#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>
@onbuyuka onbuyuka requested review from a team as code owners June 2, 2026 08:45
@github-actions github-actions Bot added this to the Version 28.2 milestone Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant