Skip to main content
Skip to main content

How to build an OpenAI agent using ClickHouse MCP Server

In this guide, you'll learn how to build an OpenAI agent that can interact with ClickHouse's SQL playground using ClickHouse's MCP Server.

Example notebook

This example can be found as a notebook in the examples repository.

Prerequisites

  • You'll need to have Python installed on your system.
  • You'll need to have pip installed on your system.
  • You'll need an OpenAI API key

You can run the following steps either from your Python REPL or via script.

Install libraries

Install the required library by running the following commands:

Setup credentials

Next, you'll need to provide your OpenAI API key:

Initialize MCP Server and OpenAI agent

Now configure the ClickHouse MCP Server to point at the ClickHouse SQL playground, initialize your OpenAI agent and ask it a question: