MCP url detection regex problem #17920

Closed
opened 2026-02-21 19:41:22 -05:00 by yindo · 0 comments
Owner

Originally created by @fengwk on GitHub (Sep 22, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.8.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

MCP cannot save urls with less than 2-level domain names, and only 1-level hostname are common when accessing between dockers.

http://vps-app-kk-circle.com:8080/mcp/ocr is ok
http://vps-app-kk-circle:8080/mcp/ocr is failed

Preliminary searches found that it might be related to this regex
mcp/modal.tsx

  const isValidUrl = (string: string) => {
    try {
      const urlPattern = /^(https?:\/\/)((([a-z\d]([a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}|((\d{1,3}\.){3}\d{1,3})|localhost)(\:\d+)?(\/[-a-z\d%_.~+]*)*(\?[;&a-z\d%_.~+=-]*)?/i
      return urlPattern.test(string)
    }
    catch (e) {
      return false
    }
  }
Image

✔️ Expected Behavior

Successfully saved hostname usage.

Actual Behavior

Cannot save only the hostname.

Originally created by @fengwk on GitHub (Sep 22, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.8.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce MCP cannot save urls with less than 2-level domain names, and only 1-level hostname are common when accessing between dockers. `http://vps-app-kk-circle.com:8080/mcp/ocr` is ok `http://vps-app-kk-circle:8080/mcp/ocr` is failed Preliminary searches found that it might be related to this regex `mcp/modal.tsx` ``` const isValidUrl = (string: string) => { try { const urlPattern = /^(https?:\/\/)((([a-z\d]([a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}|((\d{1,3}\.){3}\d{1,3})|localhost)(\:\d+)?(\/[-a-z\d%_.~+]*)*(\?[;&a-z\d%_.~+=-]*)?/i return urlPattern.test(string) } catch (e) { return false } } ``` <img width="1801" height="1806" alt="Image" src="https://github.com/user-attachments/assets/f9c67206-f43f-4e38-8d60-cdc67e9aa917" /> ### ✔️ Expected Behavior Successfully saved hostname usage. ### ❌ Actual Behavior Cannot save only the hostname.
yindo closed this issue 2026-02-21 19:41:22 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#17920