Merge 8d17ebc0bb
into 7eecc9ca3f
This commit is contained in:
commit
9f7c8a681b
2 changed files with 55 additions and 3 deletions
31
README.md
31
README.md
|
@ -34,7 +34,9 @@ All the most popular MCP clients (Claude Desktop, Cursor & Windsurf) use the fol
|
||||||
|
|
||||||
### Custom Headers
|
### Custom Headers
|
||||||
|
|
||||||
To bypass authentication, or to emit custom headers on all requests to your remote server, pass `--header` CLI arguments:
|
To bypass authentication, or to emit custom headers on all requests to your remote server, there are two options:
|
||||||
|
|
||||||
|
#### Option 1: Using `--header` CLI arguments
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
|
@ -72,6 +74,33 @@ To bypass authentication, or to emit custom headers on all requests to your remo
|
||||||
},
|
},
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Option 2: Using `--headerFile` to read headers from a file
|
||||||
|
|
||||||
|
You can also provide headers from a file using the `--headerFile` argument. The file should contain one header per line in the format `Name:Value`. Lines starting with `#` are treated as comments and ignored.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"remote-example": {
|
||||||
|
"command": "npx",
|
||||||
|
"args": [
|
||||||
|
"mcp-remote",
|
||||||
|
"https://remote.mcp.server/sse",
|
||||||
|
"--headerFile",
|
||||||
|
"/path/to/headers.txt"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Example headers file:
|
||||||
|
```
|
||||||
|
# Headers for MCP Remote
|
||||||
|
Authorization:Bearer my-token
|
||||||
|
X-Custom-Header:custom-value
|
||||||
|
```
|
||||||
|
|
||||||
### Flags
|
### Flags
|
||||||
|
|
||||||
* If `npx` is producing errors, consider adding `-y` as the first argument to auto-accept the installation of the `mcp-remote` package.
|
* If `npx` is producing errors, consider adding `-y` as the first argument to auto-accept the installation of the `mcp-remote` package.
|
||||||
|
|
|
@ -314,8 +314,8 @@ export function setupOAuthCallbackServerWithLongPoll(options: OAuthCallbackServe
|
||||||
Authorization successful!
|
Authorization successful!
|
||||||
You may close this window and return to the CLI.
|
You may close this window and return to the CLI.
|
||||||
<script>
|
<script>
|
||||||
// If this is a non-interactive session (no manual approval step was required) then
|
// If this is a non-interactive session (no manual approval step was required) then
|
||||||
// this should automatically close the window. If not, this will have no effect and
|
// this should automatically close the window. If not, this will have no effect and
|
||||||
// the user will see the message above.
|
// the user will see the message above.
|
||||||
window.close();
|
window.close();
|
||||||
</script>
|
</script>
|
||||||
|
@ -428,6 +428,29 @@ export async function parseCommandLineArgs(args: string[], usage: string) {
|
||||||
args.splice(i, 2)
|
args.splice(i, 2)
|
||||||
// Do not increment i, as the array has shifted
|
// Do not increment i, as the array has shifted
|
||||||
continue
|
continue
|
||||||
|
} else if (args[i] === '--headerFile' && i < args.length - 1) {
|
||||||
|
const filePath = args[i + 1]
|
||||||
|
try {
|
||||||
|
const fileContent = await fs.readFile(filePath, 'utf8')
|
||||||
|
const lines = fileContent.split('\n')
|
||||||
|
for (const line of lines) {
|
||||||
|
const trimmedLine = line.trim()
|
||||||
|
if (trimmedLine && !trimmedLine.startsWith('#')) {
|
||||||
|
const match = trimmedLine.match(/^([A-Za-z0-9_-]+):(.*)$/)
|
||||||
|
if (match) {
|
||||||
|
headers[match[1]] = match[2]
|
||||||
|
} else {
|
||||||
|
log(`Warning: ignoring invalid header in file: ${trimmedLine}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log(`Loaded headers from file: ${filePath}`)
|
||||||
|
} catch (error) {
|
||||||
|
log(`Error reading header file ${filePath}: ${error}`)
|
||||||
|
}
|
||||||
|
args.splice(i, 2)
|
||||||
|
// Do not increment i, as the array has shifted
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue