
ta
toy assitant agent for tidb slow log
Repository Info
About This Server
toy assitant agent for tidb slow log
Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.
Documentation
TiDB SQL Optimization Agent
An intelligent AI agent system for analyzing and optimizing slow queries in TiDB clusters. This project aims to automate the process of SQL query optimization using AI-driven analysis and recommendations.
Overview
The TiDB SQL Optimization Agent is designed to address the challenges of managing slow SQL queries in large-scale TiDB deployments. It automatically analyzes slow query logs, identifies performance bottlenecks, and provides optimization suggestions or automatic optimizations when possible.
Key Features
- Automated slow query log analysis
- AI-driven SQL optimization recommendations
- Integration with TiDB observability data
- Automatic optimization execution (with safeguards)
- Performance impact analysis and rollback capabilities
- Structured optimization reports
Architecture
The system consists of several key components:
- AI Agent: Implements the ReAct (Reasoning + Acting) paradigm for intelligent decision-making
- MCP Server: Model Context Protocol server that provides standardized interfaces to various data sources
- Slow Query Analysis: Processes and analyzes slow query logs from S3 storage
- Optimization Engine: Generates and validates SQL optimization suggestions
Prerequisites
- Python 3.10 or higher
- TiDB cluster with slow query logging enabled
- Access to required data sources (S3, Prometheus metrics, etc.)
- Necessary permissions for SQL optimization operations
Installation
- Clone the repository:
git clone https://github.com/yourusername/tidb-optimizer.git
cd tidb-optimizer
- Install uv (if not already installed):
curl -LsSf https://astral.sh/uv/install.sh | sh
- Create virtual environment and install dependencies:
uv venv
source .venv/bin/activate # On Windows, use `.venv\Scripts\activate`
uv pip install -e .
Configuration
Create a .env file from example
Usage
uv run src/agents/sql_workflow.py
Project Structure
.
├── src/ # Source code
├── sql/ # SQL-related resources
├── tmp/ # Temporary files
├── design.md # Detailed design documentation
├── pyproject.toml # Project configuration and dependencies
├── uv.lock # Lock file for dependency versions
└── README.md # This file
Dependencies
Key dependencies include:
- mcp >= 0.3.0
- openai >= 1.70.0
- fastapi >= 0.103.1
- sqlalchemy >= 2.0.40
- agno >= 1.2.6
- [See pyproject.toml for complete list]
Development
[Development instructions will be added based on contribution guidelines]
Quick Start
Clone the repository
git clone https://github.com/just1900/taInstall dependencies
cd ta
npm installFollow the documentation
Check the repository's README.md file for specific installation and usage instructions.
Repository Details
Recommended MCP Servers
Discord MCP
Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.
Knit MCP
Connect AI agents to 200+ SaaS applications and automate workflows.
Apify MCP Server
Deploy and interact with Apify actors for web scraping and data extraction.
BrowserStack MCP
BrowserStack MCP Server for automated testing across multiple browsers.
Zapier MCP
A Zapier server that provides automation capabilities for various apps.