Skip to content

Commit 5afe15d

Browse files
committed
[mcp-client] Make HF_TOKEN optional
1 parent 29150f4 commit 5afe15d

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

packages/mcp-client/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@ The agent will load available MCP tools (by default, connecting to a filesystem
4444

4545
### Configuration (Environment Variables)
4646

47-
* `HF_TOKEN` (Required): Your Hugging Face API token.
47+
* `HF_TOKEN` (Optional): Your Hugging Face API token. Required if you use an Inference Provider on HF.
4848
* `MODEL_ID` (Optional): The model ID to use for the agent's inference. Defaults to `Qwen/Qwen2.5-72B-Instruct`.
4949
* `PROVIDER` (Optional): The inference provider. Defaults to `together`. See `@huggingface/inference` for available providers.
50-
* `EXPERIMENTAL_HF_MCP_SERVER` (Optional): Set to `true` to enable connection to an experimental Hugging Face MCP server (requires separate setup).
50+
* `ENDPOINT_URL` or `BASE_URL` (Optional): A custom base URL (local for instance) to call.
5151
5252
Example with custom model:
5353
5454
```bash
5555
export HF_TOKEN="hf_..."
56-
export MODEL_ID="mistralai/Mixtral-8x7B-Instruct-v0.1"
56+
export MODEL_ID="Qwen/Qwen2.5-72B-Instruct"
5757
pnpm agent
5858
```
5959

packages/mcp-client/cli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ async function main() {
6262
process.exit(0);
6363
}
6464

65-
if (!process.env.HF_TOKEN) {
66-
console.error(`a valid HF_TOKEN must be present in the env`);
65+
if (!ENDPOINT_URL && !process.env.HF_TOKEN) {
66+
console.error(`To use a remote inference provider, a valid HF_TOKEN must be present in the env`);
6767
process.exit(1);
6868
}
6969

packages/mcp-client/src/Agent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class Agent extends McpClient {
6666
}
6767
) & {
6868
model: string;
69-
apiKey: string;
69+
apiKey?: string;
7070
servers: (ServerConfig | StdioServerParameters)[];
7171
prompt?: string;
7272
}) {

packages/mcp-client/src/McpClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class McpClient {
5050
}
5151
) & {
5252
model: string;
53-
apiKey: string;
53+
apiKey?: string;
5454
}) {
5555
this.client = endpointUrl ? new InferenceClient(apiKey, { endpointUrl: endpointUrl }) : new InferenceClient(apiKey);
5656
this.provider = provider;

packages/mcp-client/test/McpClient.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe("McpClient", () => {
1010
const client = new McpClient({
1111
provider: "together",
1212
model: "Qwen/Qwen2.5-72B-Instruct",
13-
apiKey: process.env.HF_TOKEN ?? "",
13+
apiKey: process.env.HF_TOKEN,
1414
});
1515
expect(client).toBeDefined();
1616
expect(client.availableTools.length).toBe(0);

0 commit comments

Comments
 (0)