AI makes mistakes! Undisk makes recovery instant: every write is versioned, every file is reversible.
See it heal →
import asyncio
import os

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

UNDISK_API_KEY = os.environ["UNDISK_API_KEY"]

async def main():
    mcp_client = BasicMCPClient(
        "https://mcp.undisk.app/v1/mcp",
        headers={"Authorization": f"Bearer {UNDISK_API_KEY}"},
    )
    tool_spec = McpToolSpec(client=mcp_client)
    tools = await tool_spec.to_tool_list_async()

    agent = FunctionAgent(
        name="undisk_agent",
        description="Agent with access to Undisk MCP tools.",
        llm=OpenAI(model="gpt-4o-mini"),  # reads OPENAI_API_KEY from env
        tools=tools,
        system_prompt="Use Undisk tools for versioned file operations.",
    )

    response = await agent.run("List files at workspace root.")
    print(str(response))

asyncio.run(main())

Integration checklist

  • Verify model + MCP tool selection before running autonomous tasks.
  • Capture workspace and trace identifiers for every run.
  • Add guardrails around write-heavy tool calls in production agents.

Error handling pattern

import asyncio

async def guarded_tool_call(client, name, arguments):
    for attempt in range(3):
        try:
            return await client.call_tool(name, arguments)
        except Exception as err:
            text = str(err)
            if "RATE_LIMITED" in text and attempt < 2:
                await asyncio.sleep(2 ** attempt)
                continue
            raise

Operational guidance

This pattern works well for retrieval-and-write loops where you need auditable provenance and fast rollback.