Back to course

Daily Repetition 3: The 'SQL Query' Tool

Model Context Protocol (MCP) Server Engineering

Daily Repetition: Tool #3

Today we connect to a database. Use SQLite for simplicity.

Implementation

  1. Install sqlite3 or better-sqlite3.
  2. Create a tool query_db that takes a sql string.
  3. Return the results as a JSON string in the tool output.

Assignment: Create a table users, insert a row, and use the tool to fetch it.