Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .usersettings/hostname
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github-push-tpe6kc8tj4fayhd8.env.clearscape.teradata.com
363 changes: 363 additions & 0 deletions Getting_Started/MCP_Server_Workbench/00-Setup_demo.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,363 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "ae390916-4cf5-4678-871f-093f21bddd52",
"metadata": {},
"source": [
"<header>\n",
" <p style='font-size:36px;font-family:Arial; color:#F0F0F0; background-color: #00233c; padding-left: 20pt; padding-top: 20pt;padding-bottom: 10pt; padding-right: 20pt;'>\n",
" Teradata MCP - Setup\n",
" <br>\n",
" <img id=\"teradata-logo\" src=\"https://storage.googleapis.com/clearscape_analytics_demo_data/DEMO_Logo/teradata.svg\" alt=\"Teradata\" style=\"width: 125px; height: auto; margin-top: 20pt;\">\n",
" </p>\n",
"</header>"
]
},
{
"cell_type": "markdown",
"id": "c5ff07d2-66de-4933-94b6-a0279f961c2d",
"metadata": {},
"source": [
"<p style = 'font-size:20px;font-family:Arial;'><b>Introduction</b></p>\n",
"<p style=\"font-size:16px;font-family:Arial;\">\n",
"This notebook initializes the environment required to run <b>Teradata MCP</b> demonstrations \n",
"on <b>Teradata Vantage</b>. \n",
"It installs the essential dependencies, verifies the MCP-client setup, and connects to a Vantage instance for subsequent notebooks \n",
"that illustrate model management, registration, and execution workflows through MCP.\n",
"</p>\n"
]
},
{
"cell_type": "markdown",
"id": "32a9bb5c-6fb2-4cab-be6a-adaed421084a",
"metadata": {},
"source": [
"<hr style=\"height:2px;border:none;\">\n",
"<p style = 'font-size:20px;font-family:Arial;'><b>1. Connect to Vantage and Import packages</b></p>\n",
"<p style=\"font-size:16px;font-family:Arial;\">We begin by installing the essential Python packages needed for this demo:</p>\n",
"<ul style=\"font-size:16px;font-family:Arial;\">\n",
"<li><code>chatbot_widget</code> – a simple interactive widget to create chatbot interfaces inside notebooks.</li>\n",
"<li><code>teradataml-plus</code> – the extended Python interface for Teradata Vantage, enabling seamless analytics operations.</li>\n",
"<li><code>plotly</code> – for visualizing data loaded into the database.</li>\n",
"</ul>"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d6a5056f-8366-434d-8ded-c703b71ee637",
"metadata": {},
"outputs": [],
"source": [
"%%capture\n",
"# # '%%capture' suppresses the display of installation steps of the following packages\n",
"!pip install \"git+https://github.com/martinhillebrand/chatbot-widget.git\""
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "22128084-ff02-4e0b-b853-030bdb46ba9d",
"metadata": {},
"outputs": [],
"source": [
"%%capture\n",
"# #'%%capture' suppresses the display of installation steps of the following packages\n",
"!pip install teradataml-plus plotly"
]
},
{
"cell_type": "markdown",
"id": "0b0829c0-6413-463b-bd15-aa0f5f73850f",
"metadata": {},
"source": [
"<hr style=\"height:2px;border:none;\">\n",
"<b style = 'font-size:18px;font-family:Arial;'> 1.1 (Optional) Clone the Teradata MCP Server Repository</b>\n",
"<p style = 'font-size:16px;font-family:Arial;'>If you wish to explore the backend logic or deploy your own MCP Server environment, you can clone the open-source repository from GitHub. This step is optional and can be skipped if you’re only running the client-side notebooks.</p>"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b6a86563-3285-4969-8449-128a0f14c271",
"metadata": {},
"outputs": [],
"source": [
"!git clone https://github.com/Teradata/teradata-mcp-server.git"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5cc1e215-2b8b-4521-919e-089c4bae601e",
"metadata": {},
"outputs": [],
"source": [
"!ls"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8e87385a-1b55-4503-90c4-b7f527ff9f25",
"metadata": {},
"outputs": [],
"source": [
"import tomllib,shlex\n",
"\n",
"with open(\"teradata-mcp-server/pyproject.toml\", \"rb\") as f:\n",
" deps = tomllib.load(f)[\"project\"][\"dependencies\"]\n",
"deps_str = \" \".join(shlex.quote(d) for d in deps)\n",
"\n",
"print(deps_str)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5ecc5a7e-4848-4794-b01e-30862f119906",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"%%capture\n",
"# # '%%capture' suppresses the display of installation steps of the following packages\n",
"!pip install -U {deps_str}"
]
},
{
"cell_type": "markdown",
"id": "1610c510-790e-45e3-a67d-c9c66e76a4f6",
"metadata": {},
"source": [
"<div class=\"alert alert-block alert-info\">\n",
"<p style = 'font-size:16px;font-family:Arial;'><b>Note: </b><i>Be sure to restart the kernel after executing those lines to bring the installed libraries into memory. The simplest way to restart the Kernel is by typing zero zero: <b> 0 0</b></i></p>\n",
"</div>"
]
},
{
"cell_type": "markdown",
"id": "24bafb8f-6a00-46ea-af9b-81a0eeeee288",
"metadata": {},
"source": [
"<div class=\"alert alert-block alert-info\">\n",
"<p style = 'font-size:16px;font-family:Arial'><b>FYI: </b><i>We can start the MCP server later through the wrapper script tdmcpcommunity.py</i></p>\n",
"</div>"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0856a961-1522-468c-9e30-6c3e13507b7b",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import pandas as pd\n",
"import teradataml as tdml"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8e49aaf5-adbb-4fd5-b163-fcf64c116636",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import warnings\n",
"warnings.filterwarnings('ignore')\n",
"\n",
"from teradataml import *\n",
"# Modify the following to match the specific client environment settings\n",
"display.max_rows = 5"
]
},
{
"cell_type": "markdown",
"id": "ed5ff7c4-d59e-453b-91f7-651994ba69dd",
"metadata": {},
"source": [
"<hr style=\"height:2px;border:none;\">\n",
"<b style = 'font-size:18px;font-family:Arial;'> 1.2 Verify Installation</b>\n",
"<p style = 'font-size:16px;font-family:Arial;'>Once packages are installed, we verify that chatbot_widget has been imported successfully. If installation was successful, you’ll see the confirmation message below.</p>"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3673928b-977a-4d9d-9af1-b508594e2017",
"metadata": {},
"outputs": [],
"source": [
"import tdmlplus"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "44d183d6-4559-4d85-96b5-b1aca7986138",
"metadata": {},
"outputs": [],
"source": [
"try:\n",
" import chatbot_widget\n",
" print(\"chatbot_widget installed\")\n",
"except:\n",
" print(\"chatbot_widget could not be loaded, please restart the kernel\")"
]
},
{
"cell_type": "markdown",
"id": "40b1f7de-0bac-47ae-922f-4c5a044afd22",
"metadata": {},
"source": [
"<hr style=\"height:2px;border:none;\">\n",
"<b style = 'font-size:18px;font-family:Arial;'> 1.3 Connect to Vantage</b>\n",
"<p style = 'font-size:16px;font-family:Arial;'>We will be prompted to provide the password. We will enter the password, press the Enter key, and then use the down arrow to go to the next cell.</p>"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5ab1fc0c-9168-4a93-b816-15f3039b022a",
"metadata": {},
"outputs": [],
"source": [
"%run -i ../../UseCases/startup.ipynb\n",
"eng = create_context(host = 'host.docker.internal', username='demo_user', password = password)\n",
"print(eng)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "381e9293-9eee-4055-9357-52b1aa1d6b43",
"metadata": {},
"outputs": [],
"source": [
"%%capture\n",
"execute_sql('''SET query_band='DEMO=00-Setup_demo.ipynb;' UPDATE FOR SESSION; ''')"
]
},
{
"cell_type": "markdown",
"id": "d5d3eda0-68f6-470d-9cbd-d7016f7e8a92",
"metadata": {},
"source": [
"<hr style=\"height:2px;border:none;\">\n",
"<p style = 'font-size:20px;font-family:Arial;'><b>2. Load Sample Data into the Database</b></p>\n",
"<p style=\"font-size:16px;font-family:Arial;\">\n",
"We’ll now load several CSV files from the <code>sample_data_jaffleshop</code> folder into our Teradata schema. \n",
"Each CSV file corresponds to a small sample table (e.g., customers, orders, products). \n",
"The <code>copy_to_sql()</code> function automatically creates and populates the tables.\n",
"</p>\n",
"<ul style=\"font-size:16px;font-family:Arial;\">\n",
"<li>Iterate through all CSV files.</li>\n",
"<li>Create a table for each file in Vantage.</li>\n",
"<li>Confirm each upload in the cell output.</li>\n",
"</ul>"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a9ccb11b-1659-49c1-892e-0410df1cdf95",
"metadata": {},
"outputs": [],
"source": [
"all_csvs = os.listdir(\"sample_data_jaffleshop/\")\n",
"for f in all_csvs:\n",
" if f.endswith(\".csv\"):\n",
" table_name = f.split(\".csv\")[0]\n",
" df = pd.read_csv(\"sample_data_jaffleshop/\"+f)\n",
" tdml.copy_to_sql(df, table_name, if_exists=\"replace\")\n",
" print(table_name, \" uploaded\")"
]
},
{
"cell_type": "markdown",
"id": "b11303c5-b86c-428e-895d-d44370763bb9",
"metadata": {},
"source": [
"<hr style=\"height:2px;border:none;\">\n",
"<p style = 'font-size:20px;font-family:Arial;'><b>2. Explore the Uploaded Tables</b></p>\n",
"<p style=\"font-size:16px;font-family:Arial;\">\n",
"We use the <code>widgets.tab_dfs()</code> function to preview all uploaded tables interactively. \n",
"This helps verify that the data has been correctly copied into the Vantage database.\n",
"</p>"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ae8bbac4-4982-4eaa-9202-8d258b461cb8",
"metadata": {},
"outputs": [],
"source": [
"tdml.widgets.tab_dfs(table_names = [f.split(\".csv\")[0] for f in all_csvs] )"
]
},
{
"cell_type": "markdown",
"id": "56558320-6085-444e-912d-90b62a222128",
"metadata": {},
"source": [
"<hr style=\"height:2px;border:none;\">\n",
"<b style = 'font-size:20px;font-family:Arial;'>3. Cleanup</b></p>\n",
"<p style=\"font-size:16px;font-family:Arial;\">\n",
"Finally, we remove the active database context using <code>remove_context()</code>. \n",
"This ensures that all database connections are safely closed and resources are released.\n",
"</p>"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "684f8a7b-d9c5-4fa4-afe2-f836944314ce",
"metadata": {},
"outputs": [],
"source": [
"remove_context()"
]
},
{
"cell_type": "markdown",
"id": "bc64602a-93bb-44fb-aa32-a7bc130212b3",
"metadata": {},
"source": [
"<footer style=\"padding-bottom:35px; background:#f9f9f9; border-bottom:3px solid #00233C\">\n",
" <div style=\"float:left;margin-top:14px\">ClearScape Analytics™</div>\n",
" <div style=\"float:right;\">\n",
" <div style=\"float:left; margin-top:14px\">\n",
" Copyright © Teradata Corporation - 2025. All Rights Reserved\n",
" </div>\n",
" </div>\n",
"</footer>"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.14"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading
Loading