add --allow-http flag

This commit is contained in:
kissrobber 2025-04-16 13:34:48 +09:00 committed by Glen Maddern
parent 0596122962
commit a2064502b9
2 changed files with 13 additions and 1 deletions

View file

@ -104,6 +104,16 @@ To bypass authentication, or to emit custom headers on all requests to your remo
] ]
``` ```
* To allow HTTP connections in trusted private networks, add the `--allow-http` flag. Note: This should only be used in secure private networks where traffic cannot be intercepted.
```json
"args": [
"mcp-remote",
"http://internal-service.vpc/sse",
"--allow-http"
]
```
### Claude Desktop ### Claude Desktop
[Official Docs](https://modelcontextprotocol.io/quickstart/user) [Official Docs](https://modelcontextprotocol.io/quickstart/user)

View file

@ -299,6 +299,7 @@ export async function parseCommandLineArgs(args: string[], defaultPort: number,
const serverUrl = args[0] const serverUrl = args[0]
const specifiedPort = args[1] ? parseInt(args[1]) : undefined const specifiedPort = args[1] ? parseInt(args[1]) : undefined
const allowHttp = args.includes('--allow-http')
if (!serverUrl) { if (!serverUrl) {
log(usage) log(usage)
@ -308,7 +309,8 @@ export async function parseCommandLineArgs(args: string[], defaultPort: number,
const url = new URL(serverUrl) const url = new URL(serverUrl)
const isLocalhost = (url.hostname === 'localhost' || url.hostname === '127.0.0.1') && url.protocol === 'http:' const isLocalhost = (url.hostname === 'localhost' || url.hostname === '127.0.0.1') && url.protocol === 'http:'
if (!(url.protocol == 'https:' || isLocalhost)) { if (!(url.protocol == 'https:' || isLocalhost || allowHttp)) {
log('Error: Non-HTTPS URLs are only allowed for localhost or when --allow-http flag is provided')
log(usage) log(usage)
process.exit(1) process.exit(1)
} }