Appendix: file list

The public workshop code has this shape:

agents-mcp/
|-- README.md
|-- main.py
|-- notebook.ipynb
|-- notebook-groq.ipynb
|-- pyproject.toml
|-- uv.lock
|-- .vscode/
|   `-- mcp.json
`-- mcp_faq/
    |-- README.md
    |-- main.py
    |-- pyproject.toml
    `-- search_tools.py

main.py in the root project is only the uv init placeholder. The workshop code is in the notebooks and in mcp_faq/.

Main dependency commands

Main notebook project:

uv init
uv add jupyter openai minsearch requests toyaikit
uv add openai-agents pydantic-ai

MCP server project:

mkdir mcp_faq
cd mcp_faq
uv init
uv add fastmcp minsearch requests toyaikit

Optional PydanticAI MCP extra for separate scripts:

uv add "pydantic-ai[mcp]" openai toyaikit

Environment variables

The examples use these environment variables:

export OPENAI_API_KEY="sk-..."
export ANTHROPIC_API_KEY="..."
export GROQ_API_KEY="..."

Only OPENAI_API_KEY is required for the main OpenAI path. Anthropic and Groq are optional provider examples.

Final mcp_faq/main.py

The final server initializes tools and runs FastMCP over SSE:

import requests
from minsearch import AppendableIndex
from fastmcp import FastMCP
from toyaikit.tools import wrap_instance_methods

from search_tools import SearchTools

def init_index():
    docs_url = "https://github.com/alexeygrigorev/llm-rag-workshop/raw/main/notebooks/documents.json"
    docs_response = requests.get(docs_url)
    documents_raw = docs_response.json()

    documents = []

    for course in documents_raw:
        course_name = course["course"]

        for doc in course["documents"]:
            doc["course"] = course_name
            documents.append(doc)

The second half creates the index, registers tools, and starts SSE:

    index = AppendableIndex(
        text_fields=["question", "text", "section"],
        keyword_fields=["course"]
    )

    index.fit(documents)
    return index

def init_tools():
    index = init_index()
    return SearchTools(index)

def init_mcp():
    mcp = FastMCP("Demo")
    agent_tools = init_tools()
    wrap_instance_methods(mcp.tool, agent_tools)
    return mcp

if __name__ == "__main__":
    mcp = init_mcp()
    mcp.run(transport="sse")

Run it from mcp_faq/:

uv run python main.py

The SSE endpoint is:

http://localhost:8000/sse

Questions & Answers (0)

Sign in to ask questions