Beyond tools

Lecture 22

Dr. Benjamin Soltoff

Cornell University
INFO 4940/5940 - Fall 2025

November 13, 2025

Announcements

Announcements

TODO

Learning objectives

  • Create natural language interfaces to data with querychat
  • Define agentic AI
  • Utilize AI coding assistants to help with programming tasks
  • Introduce the Model Context Protocol (MCP)
  • Access MCP servers using Positron Assistant

Application exercise

ae-21

Instructions

  • Go to the course GitHub org and find your ae-21 (repo name will be suffixed with your GitHub name).
  • Clone the repo in Positron, install required packages using renv::restore() (R) or uv sync (Python), open the Quarto document in the repo, and follow along and complete the exercises.
  • Render, commit, and push your edits by the AE deadline – end of the day

How it works

  • Natural language chat powered by LLMs

  • Do not provide the LLM direct access to raw data

  • It can only read or filter data by writing SQL SELECT statements

    • Reliability
    • Transparency
    • Reproducibility
  • Leverages DuckDB for its SQL engine

querychat in R

library(shiny)
library(bslib)
library(querychat)

penguins_qc_config <- querychat_init(penguins)

ui <- page_sidebar(
  sidebar = querychat_sidebar("penguins"),
  # plots, tables, etc.
)

server <- function(input, output, session) {
  penguins_qc <- querychat_server("penguins", penguins_qc_config)

  output$table <- renderTable({
    penguins_qc$df()
  })
}

shinyApp(ui, server)

querychat in Python

import polars as pl
import querychat
from shiny import App, render, ui

penguins = pl.read_csv("data/penguins.csv")

penguins_qc_config = querychat.init(penguins, "penguins")

app_ui = ui.page_sidebar(
    querychat.sidebar("penguins"),
    # plots, tables, etc.
)

def server(input, output, session):
    penguins_qc = querychat.server("penguins", penguins_qc_config)

    @render.data_frame
    def data_table():
        return qc.df()

app = App(app_ui, server)

⌨️ 25_querychat

Instructions

  1. I’ve made a Shiny dashboard to explore Airbnb listings in Asheville, NC.

    • Spend 1-2 min: which Neighborhood has most private rooms?
  2. Work through the steps in the comments to use querychat.

  3. Spend a few minutes exploring the data and chatting with the app.
    Which area has the most private rooms?

08:00

Enhancing querychat

  • Provide an explicit user greeting
  • Augment the system prompt
    • Data description
    • Custom greeting
  • Use a different LLM provider/model

Agents

What’s an agent?

  • Agents are LLMs with a read tool and a write tool

  • The “you know it when you see it” definition: autonomous LLMs, long context, minimal intervention

AI coding assistants

Tools that use LLms to help developers write, debug, and understand code

  • GitHub Copilot
  • Claude Code
  • Gemini Code Assist
  • Positron Assistant

⌨️ Demo Positron Assistant

Instructions

  1. Enable Positron Assistant
  2. Configure LLM provider
  3. Use Positron Assistant to help with a coding task
12:00

TODO what coding task?

Shiny Assistant

Online tool to help you build Shiny apps using an LLM

Also built directly into Positron Assistant - use the @shiny tag in your prompt

MCP

Recall: Tools

a.k.a. functions, tool calling or function calling

  • Bring real-time or up-to-date information to the model

  • Let the model interact with the world

🤔 What other tools could be useful?

  • Get the weather
  • Search the Cornell course roster
  • ...

Who should write tools for GitHub?

MCP solves this problem! GitHub writes tools…

and lets you your models use them.

GitHub MCP Server

⌨️ 26_mcp

Instructions

Follow the instructions in README.R.md or README.py.md for this task.

  1. What MCP servers are out there?

  2. Set up context7 as an MCP server in Positron.

  3. Use context7 tools to answer a coding translation question.

06:00

Implementing MCP in your own

Enables R/Python to be both MCP client and server

Wrap-up

Recap

  • Leverage LLMs to create natural language interfaces to data with querychat
  • Agents can use tools to interact with the world and perform tasks (semi-)autonomously
  • AI coding assistants can help you write and understand code
  • The Model Context Protocol (MCP) standardizes how LLMs can access tools

Acknowledgments