A Model Context Protocol (MCP) server for managing and querying a SQLite database of news articles
Built with FastMCP, this server exposes its capabilities to any MCP-compatible client — including AI orchestrators, agents, and assistants.
| Tool | Description |
|---|---|
get_schema |
Retrieve the full schema of the SQLite database (tables, columns, types, constraints) |
get_data_from_table |
Query rows from the new_details table with optional WHERE, ORDER BY, LIMIT, and OFFSET support |
prepare_query |
Convert natural-language questions into SQL queries using an LLM (OpenAI, Groq, or DeepSeek) |
post_into_table_details |
Insert a new news article record into the database |
The server manages a single table called new_details:
| Column | Type | Constraints |
|---|---|---|
id |
INTEGER | PRIMARY KEY, AUTOINCREMENT |
timestamp |
TEXT | NOT NULL |
source |
TEXT | NOT NULL |
news |
TEXT | NOT NULL |
header |
TEXT | NOT NULL |
keywords |
TEXT | NOT NULL |
- Python 3.10+
pip
cd mcp_serverpython -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activatepip install -r requirements.txtcp .env.example .envEdit .env to set your preferred LLM provider credentials:
# LLM Provider
LLM_PROVIDER=openai
# At least one of these API keys:
OPENAI_API_KEY=sk-...
DEEPSEEK_API_KEY=...
GROQ_API_KEY=...
# Toggle providers on/off
USE_OPENAI=true
USE_DEEPSEEK=false
USE_GROQ=false
# Optional: model overrides
OPENAI_MODEL=gpt-4o-mini
GROQ_MODEL=llama3-8b-8192Start the server with stdio transport (default for MCP):
python server.pyAlternatively, run it directly via the FastMCP CLI:
fastmcp run server.pyOnce the server is running, any MCP client can discover and invoke the following tools:
Returns the full database schema as a human-readable string.
{
"name": "get_schema",
"arguments": {}
}Query data from the new_details table.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
where_clause |
string | No | null |
SQL WHERE clause (e.g., source = 'Times of India') |
limit |
int | No | 50 |
Max rows to return (max 500) |
offset |
int | No | 0 |
Row offset for pagination |
order_by |
string | No | id DESC |
ORDER BY clause |
Convert a plain-English question into a SQLite query using the configured LLM.
| Parameter | Type | Required | Description |
|---|---|---|---|
user_question |
string | Yes | Natural-language question for the DB |
Insert a new news article.
| Parameter | Type | Required | Description |
|---|---|---|---|
source |
string | Yes | News source name (e.g., "BBC", "Times of India") |
news |
string | Yes | Article content or summary |
header |
string | Yes | Article headline/title |
keywords |
string | Yes | Comma-separated keywords |
timestamp |
string | No | ISO-format timestamp (defaults to current UTC) |
{
"mcpServers": {
"news-sqlite-server": {
"command": "python",
"args": ["/absolute/path/to/mcp_server/server.py"]
}
}
}{
"mcpServers": {
"news-sqlite-server": {
"command": "python",
"args": ["/absolute/path/to/mcp_server/server.py"]
}
}
}mcp_server/
├── data/ # SQLite database directory (auto-created)
├── venv/ # Virtual environment
├── .env # Environment variables (not committed)
├── .env.example # Example environment config
├── instructions.md # Original design instructions
├── requirements.txt # Python dependencies
├── server.py # MCP server implementation
├── image/
│ └── Coverimage.png # Cover image
└── README.md # This file
- FastMCP – Framework for building MCP servers.
- OpenAI Python SDK – LLM integration (also used for Groq and DeepSeek via compatible endpoints).
- python-dotenv – Environment variable management.
- httpx – HTTP client for LLM API calls.
This project is part of a larger research backend. See the root project for license details.
