You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[MCP] Add local/remote endpoint inference support (#3121)
* allow endpoint url in tiny-agents
* nit
* explicitly fail if no model or base_url is provided
Co-authored-by: Lucain <[email protected]>
---------
Co-authored-by: Lucain <[email protected]>
Copy file name to clipboardExpand all lines: src/huggingface_hub/inference/_mcp/agent.py
+6-3Lines changed: 6 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -20,14 +20,16 @@ class Agent(MCPClient):
20
20
</Tip>
21
21
22
22
Args:
23
-
model (`str`):
23
+
model (`str`, *optional*):
24
24
The model to run inference with. Can be a model id hosted on the Hugging Face Hub, e.g. `meta-llama/Meta-Llama-3-8B-Instruct`
25
25
or a URL to a deployed Inference Endpoint or other local or remote endpoint.
26
26
servers (`Iterable[Dict]`):
27
27
MCP servers to connect to. Each server is a dictionary containing a `type` key and a `config` key. The `type` key can be `"stdio"` or `"sse"`, and the `config` key is a dictionary of arguments for the server.
28
28
provider (`str`, *optional*):
29
29
Name of the provider to use for inference. Defaults to "auto" i.e. the first of the providers available for the model, sorted by the user's order in https://hf.co/settings/inference-providers.
30
30
If model is a URL or `base_url` is passed, then `provider` is not used.
31
+
base_url (`str`, *optional*):
32
+
The base URL to run inference. Defaults to None.
31
33
api_key (`str`, *optional*):
32
34
Token to use for authentication. Will default to the locally Hugging Face saved token if not provided. You can also use your own provider API key to interact directly with the provider's service.
Copy file name to clipboardExpand all lines: src/huggingface_hub/inference/_mcp/mcp_client.py
+15-4Lines changed: 15 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -69,24 +69,34 @@ class MCPClient:
69
69
provider (`str`, *optional*):
70
70
Name of the provider to use for inference. Defaults to "auto" i.e. the first of the providers available for the model, sorted by the user's order in https://hf.co/settings/inference-providers.
71
71
If model is a URL or `base_url` is passed, then `provider` is not used.
72
+
base_url (`str`, *optional*):
73
+
The base URL to run inference. Defaults to None.
72
74
api_key (`str`, `optional`):
73
75
Token to use for authentication. Will default to the locally Hugging Face saved token if not provided. You can also use your own provider API key to interact directly with the provider's service.
74
76
"""
75
77
76
78
def__init__(
77
79
self,
78
80
*,
79
-
model: str,
81
+
model: Optional[str] =None,
80
82
provider: Optional[PROVIDER_OR_POLICY_T] =None,
83
+
base_url: Optional[str] =None,
81
84
api_key: Optional[str] =None,
82
85
):
83
86
# Initialize MCP sessions as a dictionary of ClientSession objects
0 commit comments