Skip to main content
Hugging Face smolagents connects to SAN with a ToolCollection, which pulls SAN’s MCP tools into a CodeAgent or ToolCallingAgent.

Prerequisites

  • Python 3.10+
  • A SAN API key
    Create one in the API Quickstart if you don’t have one yet.

Quick Start

1

Install smolagents with the MCP extra

pip install "smolagents[mcp]"
2

Describe SAN's MCP server

Set the transport to streamable-http and pass your key in headers.
server = {
    "url": "https://gateway.sanfoundation.com/mcp",
    "transport": "streamable-http",
    "headers": {"x-api-key": "sk_..."},
}
3

Run an agent with SAN's tools

ToolCollection.from_mcp requires trust_remote_code=True. Open it as a context manager so the connection is closed for you.
from smolagents import ToolCollection, CodeAgent, InferenceClientModel

model = InferenceClientModel()

with ToolCollection.from_mcp(server, trust_remote_code=True) as tool_collection:
    agent = CodeAgent(
        tools=[*tool_collection.tools],
        model=model,
        add_base_tools=True,
    )
    agent.run("List the available SAN agents.")