Skip to main content
LlamaIndex connects to SAN with BasicMCPClient from llama-index-tools-mcp. Its tools drop straight into a Workflows-based FunctionAgent.

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 the MCP tools

pip install llama-index-tools-mcp
2

Connect SAN's MCP server

An https://…/mcp URL uses streamable HTTP automatically. Pass your key in headers.
from llama_index.tools.mcp import BasicMCPClient, McpToolSpec

mcp_client = BasicMCPClient(
    "https://gateway.sanfoundation.com/mcp",
    headers={"x-api-key": "sk_..."},
)

tools = await McpToolSpec(client=mcp_client).to_tool_list_async()
3

Give the tools to a FunctionAgent

import asyncio
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
from llama_index.tools.mcp import BasicMCPClient, McpToolSpec

async def main() -> None:
    mcp_client = BasicMCPClient(
        "https://gateway.sanfoundation.com/mcp",
        headers={"x-api-key": "sk_..."},
    )
    tools = await McpToolSpec(client=mcp_client).to_tool_list_async()

    agent = FunctionAgent(
        tools=tools,
        llm=OpenAI(model="gpt-4o"),
        system_prompt="Use the SAN tools to answer the question.",
    )
    print(await agent.run("Which SAN agents are available?"))

asyncio.run(main())