Make sure you have Node.js installed, as the MCP server requires it:
Copy
pip install praisonaiagents mcp
2
Set up PostgreSQL
Ensure you have PostgreSQL running locally or specify your PostgreSQL connection URL.
3
Create a file
Create a new file postgres_agent.py with the following code:
Copy
from praisonaiagents import Agent, MCPimport os# PostgreSQL connection stringpostgres_url = "postgresql://localhost/mydb"# Use a single string command with PostgreSQL configurationpostgres_agent = Agent( instructions="""You are a helpful assistant that can interact with PostgreSQL databases. Use the available tools when relevant to manage database operations.""", llm="gpt-4o-mini", tools=MCP("npx -y @modelcontextprotocol/server-postgres", args=[postgres_url]))postgres_agent.start("List all tables in the database")