Skip to main content
Glama
rajeevchandra

SQL Query MCP Server

resources.py474 B
from sqlalchemy import inspect, text from db.connection import SessionLocal, engine from mcp.server.fastmcp import FastMCP mcp = FastMCP("postgres") @mcp.resource("table://list") def list_tables(): inspector = inspect(engine) return inspector.get_table_names() @mcp.tool("sql://query") def run_query(query: str) -> list[dict]: with SessionLocal() as session: result = session.execute(text(query)) return [dict(row._mapping) for row in result]

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/rajeevchandra/mcp-ollama-postgres'

If you have feedback or need assistance with the MCP directory API, please join our Discord server