Skip to content

Bracket an IPv6 host in the advertised local URL - #11

Merged
Erfouni merged 1 commit into
Erfouni:mainfrom
bfs2021:fix/ipv6-local-url
Oct 25, 2026
Merged

Erfouni merged 1 commit into
Erfouni:mainfrom
bfs2021:fix/ipv6-local-url

Conversation

@bfs2021

@bfs2021 bfs2021 commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Fixes #10.

Problem

With ACAD_MCP_HOST=::1, local_url() returned http://::1:8770/<secret>/mcp. That URL has no IPv6 brackets, and urllib.parse.urlsplit cannot read its port, so the advertised connector URL is unusable for an IPv6 bind.

Root cause

local_url() interpolated HOST straight into the authority. IPv6 literals need brackets before the port; IPv4 addresses and hostnames must not have them.

Fix

local_url() brackets the host only when it contains a colon. Everything else — port, secret path, IPv4 and hostname forms — is unchanged.

Testing

  • test_ipv6_host_is_bracketed_and_parses: ::1 with ACAD_MCP_SECRET_PATH=offline-fixture yields http://[::1]:8770/offline-fixture/mcp, and urlsplit reads back hostname ::1, port 8770 and path /offline-fixture/mcp.
  • test_ipv4_and_hostname_hosts_keep_their_shape: 127.0.0.1 and localhost keep the previous form and parse back to the same hostname.
  • ACAD_MCP_HOST joins the variables the test helper clears, so cases cannot leak in from the environment.
  • Without the change the IPv6 case fails (http://[::1]… vs http://::1…); with it, python -m unittest tests.test_config runs 16 tests, all passing. No AutoCAD or COM calls are involved.

With ACAD_MCP_HOST=::1, local_url() produced http://::1:8770/... which
urllib.parse.urlsplit cannot read a port from. Bracket the host when it
contains a colon; IPv4 and hostname addresses are unchanged.
@Erfouni
Erfouni merged commit 6943438 into Erfouni:main Oct 25, 2026
1 check passed
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.

Bracket IPv6 hosts in the advertised local connector URL

2 participants