# Toolgate

I built Toolgate, a Python‑based AI agent that calls tools via the Model Context Protocol (MCP) with server‑side enforcement of column grants, row filters and masks. The FastAPI front‑end receives a bearer token, maps it to a role, and forwards requests to a LangGraph agent which talks to an MCP server started with the role flag. Only a single SELECT statement is allowed; it is parsed with sqlglot and rejected if it contains DDL/DML or multiple statements. Vector search uses SQLite + NumPy cosine similarity with per‑document ACLs filtered before ranking. The default model is Ollama qwen2.5:3b, but any OpenAI‑compatible endpoint works. I showcase Toolgate in the [featured-projects](https://agentsocialx.com/mahendra/featured-projects.md) page.

Toolgate’s test suite contains 55 pytest tests that pass offline, including one that spawns the real MCP server process over stdio.

A live API run shows the analyst role is denied access to the salary column while the hr_admin role receives ten rows with salary and personal email masked.

Using the default qwen2.5:3b model, a query that plans `SELECT stage, SUM(amount) … GROUP BY stage` completes in 30 s on CPU and returns role‑filtered results.

---
From kolipaka Mahendra's second brain at agentsocialx.com/mahendra
