Skip to content

Commit 29150f4

Browse files
evalstatejulien-c
andauthored
Fix UrlConversion Test - remove sensitivity to environment variables (huggingface#1449)
Update to improve Environment Variable handling and ensure test is not sensitive to presence of token. --------- Co-authored-by: Julien Chaumond <[email protected]>
1 parent f04bd7d commit 29150f4

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

packages/mcp-client/cli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { stdin, stdout } from "node:process";
44
import { join } from "node:path";
55
import { homedir } from "node:os";
66
import type { StdioServerParameters } from "@modelcontextprotocol/sdk/client/stdio.js";
7-
import type { ServerConfig } from "./src/types";
87
import type { InferenceProviderOrPolicy } from "@huggingface/inference";
98
import { ANSI, urlToServerConfig } from "./src/utils";
109
import { Agent } from "./src";
1110
import { version as packageVersion } from "./package.json";
1211
import { parseArgs } from "node:util";
12+
import type { ServerConfig } from "./src/types";
1313

1414
const MODEL_ID = process.env.MODEL_ID ?? "Qwen/Qwen2.5-72B-Instruct";
1515
const PROVIDER = (process.env.PROVIDER as InferenceProviderOrPolicy) ?? "nebius";
@@ -49,7 +49,7 @@ if (urls?.length) {
4949
}
5050
for (const url of urls) {
5151
try {
52-
SERVERS.push(urlToServerConfig(url));
52+
SERVERS.push(urlToServerConfig(url, process.env.HF_TOKEN));
5353
} catch (error) {
5454
console.error(`Error adding server from URL "${url}": ${error.message}`);
5555
}

packages/mcp-client/src/utils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const ANSI = {
1515
RESET: "\x1b[0m",
1616
};
1717

18-
export function urlToServerConfig(urlStr: string, token?: string): ServerConfig {
18+
export function urlToServerConfig(urlStr: string, authToken?: string): ServerConfig {
1919
if (!urlStr.startsWith("http:") && !urlStr.startsWith("https:")) {
2020
throw new Error(`Unsupported URL format: ${urlStr}. Use http:// or https:// prefix.`);
2121
}
@@ -34,7 +34,6 @@ export function urlToServerConfig(urlStr: string, token?: string): ServerConfig
3434
}
3535

3636
// Check if we should include the token
37-
const authToken = token ?? process.env.HF_TOKEN;
3837
const shouldIncludeToken =
3938
!!authToken &&
4039
(hostname.endsWith(".hf.space") ||

0 commit comments

Comments
 (0)