Skip to content

Instantly share code, notes, and snippets.

@Proteusiq
Created December 15, 2025 20:22
Show Gist options
  • Select an option

  • Save Proteusiq/606cc6bd53f7557c41039c0ed01a2109 to your computer and use it in GitHub Desktop.

Select an option

Save Proteusiq/606cc6bd53f7557c41039c0ed01a2109 to your computer and use it in GitHub Desktop.
using MCP
from os import environ
from smolagents import CodeAgent, LiteLLMModel, MCPClient
model = LiteLLMModel(
model_id="anthropic/claude-opus-4-5-20251101",
temperature=0.2,
api_key=environ.get("ANTHROPIC_API_KEY"),
)
if __name__ == "__main__":
MCP_URL = "http://127.0.0.1:9000/mcp"
MCP_TRANSPORT = "streamable-http"
MCP_TOKEN = "generatedtoken" # generated by auth services
with MCPClient(
server_parameters={
"url": MCP_URL,
"transport": MCP_TRANSPORT,
"headers": {"Authorization": f"Bearer {MCP_TOKEN}"},
},
structured_output=True,
) as tools:
agent = CodeAgent(
tools=tools,
model=model,
add_base_tools=True,
max_steps=5,
)
while True:
query = input("> ")
agent.run(query)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment