This guide will show you how to build a SQL Agent that can create, modify, and manage databases using GibsonAI MCP Server and Agno.
What You’ll Build
- A SQL Agent powered by Agno that can:
- Create new databases and tables from natural language prompts.
- Modify existing schemas (add, remove, or update columns and tables).
- Deploy schema changes to serverless databases (e.g., MySQL).
- Inspect and query database schemas with conversational commands.
Key Concepts
- GibsonAI MCP Server: Turns natural language prompts into fully functional database schemas and exposes REST APIs for data access and CRUD operations.
- From Prompt to Database: You can go from describing a database in plain English to having a running schema with deployed APIs in minutes.
- Serverless Data APIs: Once your schema is created, GibsonAI provides instant endpoints (e.g.,
/query
for SQL operations or/{tablename}
for CRUD).
The GibsonAI MCP integration in Agno is available in the Agno repo: GibsonAI MCP Toolkit – agno/cookbook/tools/mcp/gibsonai.py
Prerequisites
Before starting, ensure you have:
- A GibsonAI account – Sign up at https://app.gibsonai.com.
- Python 3.9+ installed.
- OpenAI API key (you can get one from OpenAI).
Install UV Package Manager
UV is needed to run GibsonAI CLI.
Run:
curl -LsSf https://astral.sh/uv/install.sh | sh
Create a Python File
Create a new Python file (e.g.,
sql_agent.py
) and copy this code:import asyncio from textwrap import dedent from agno.agent import Agent from agno.models.openai import OpenAIChat from agno.tools.mcp import MCPTools async def run_gibsonai_agent(message: str) -> None: """Run the GibsonAI SQL Agent with the given message.""" async with MCPTools( "uvx --from gibson-cli@latest gibson mcp run", timeout_seconds=300, # Longer timeout for database operations ) as mcp_tools: agent = Agent( name="GibsonAIAgent", model=OpenAIChat(id="gpt-4o"), tools=[mcp_tools], description="SQL Agent for managing database projects and schemas", instructions=dedent("""\ You are a GibsonAI database assistant. Help users manage databases and schemas by creating tables, updating columns, and deploying schema changes. """), markdown=True, show_tool_calls=True, ) await agent.aprint_response(message, stream=True) # Example usage if __name__ == "__main__": asyncio.run( run_gibsonai_agent( "Create a database for a blog with users and posts tables." ) )
Example Prompts to Try
You can experiment with:
- "Show me the current schema for my project."
- "Add a 'products' table with name, price, and description."
- "Deploy schema changes to production."
- "Create a new database for a task management app."
Need help?
Join our Discord Server to ask questions or see what others are doing with GibsonAI.