Skip to main content

smolagents

Connect a smolagents agent from Hugging Face to Leadovaro using MCPClient with Streamable HTTP transport. smolagents' MCP client discovers all available tools and exposes them to a CodeAgent.

Prerequisites​

  • Python 3.11+
  • A Leadovaro account at app.leadovaro.com with a configured toolkit
  • A Leadovaro token and an Anthropic API key

Installation​

pip install "smolagents[mcp]" litellm python-dotenv

Environment Variables​

LEADOVARO_URL=/_sites/app.leadovaro.com/hub/mcp?profile=your-toolkit
LEADOVARO_TOKEN=your-leadovaro-token
ANTHROPIC_API_KEY=your-anthropic-key
Get Your Credentials

How to generate a Leadovaro token and configure toolkit URL parameters

Connecting to Leadovaro​

Pass a single config dict to MCPClient with the transport key set to "streamable-http" (hyphen, not underscore):

import os
from dotenv import load_dotenv
from smolagents import CodeAgent, LiteLLMModel
from smolagents.mcp_client import MCPClient

load_dotenv()

mcp_client = MCPClient(
{
"transport": "streamable-http", # hyphen required — not streamable_http
"url": os.environ["LEADOVARO_URL"],
"headers": {"Authorization": f"Bearer {os.environ['LEADOVARO_TOKEN']}"},
}
)
tools = mcp_client.get_tools()
print(f"{len(tools)} tools loaded")

model = LiteLLMModel(model_id="anthropic/claude-sonnet-4-6")
agent = CodeAgent(tools=tools, model=model)
note

The transport key must be "streamable-http" with a hyphen. Using "streamable_http" with an underscore will fail. Pass a flat dict to MCPClient — not a nested {"server_name": {...}} structure.

Running the Agent​

result = agent.run("What events do I have today?")
print(result)

# Always disconnect when done
mcp_client.disconnect()

Production Configuration​

For production agents, lock to a specific toolkit using the profile URL parameter:

LEADOVARO_URL=/_sites/app.leadovaro.com/hub/mcp?profile=your-production-toolkit

Reference Implementation​

smolagents-reference-implementation-leadovaro

Complete implementation with FastAPI chat UI and deployment guide

Next Steps​