AI News Search and Newsletter in Python
There is a quiet moment in many people’s “AI journey” where chat windows stop being enough.
You’re no longer impressed by “Explain transformers in simple terms”.
You want something more practical:
- “Look up this week’s AI news and summarise it for my blog readers.”
- “Draft a newsletter based on real headlines, not hallucinated ones.”
- “Help me keep my weekly content consistent, even when I’m tired.”
MCP tools — small, purpose-built functions an AI agent can call directly — are where this need is answered.
In this post, we’ll build a small but complete example:
An MCP-style Python service that:
- searches the web for AI-related news, and
- uses a local model (via Ollama) to draft an AI newsletter.
We’ll keep the code simple and the explanations gentle.
You do not need to be a backend expert for this.
We’ll create a tiny HTTP service using FastAPI with two main endpoints:
-
/search_ai_news
– Takes a topic and a time window (e.g. “AI”, “last 3 days”).
– Queries a news API to fetch recent AI headlines and summaries.
-
/newsletter
– Uses the search results.
– Calls a local LLM via Ollama.
– Returns a warm, human-readable newsletter draft aimed at your readers.
This FastAPI service can:
- be called directly (with
curl or Python),
- be wrapped as a genuine MCP tool once you add an MCP server on top (more on that in Step 7),
- and slot into your Obsidian + GitHub Pages workflow.
Think of it as your first “practical AI helper” that actually does work for your blog.
A quick note on naming: the Model Context Protocol (MCP) is an open protocol that lets AI applications discover and call external tools through a standard interface. What we’re building here is “MCP-style” in spirit — a small, well-defined tool boundary — but it is a plain FastAPI REST service, not an actual MCP server. Real MCP servers speak JSON-RPC over stdio or Streamable HTTP, as defined in the MCP specification. Step 7 shows exactly where the gap is and how to close it.
Prerequisites: Python, Ollama, and a News API Key
You’ll need:
We’ll call the model "llama3" in the code, but you can change it.
Step 1 — Project layout
🔒 Subscribe to keep reading.
Step 2 — Configuration with environment variables
🔒 Subscribe to keep reading.
Step 3 — A tiny client for the news API
🔒 Subscribe to keep reading.
Step 4 — A tiny client for Ollama (local LLM)
🔒 Subscribe to keep reading.
Step 5 — Wiring everything with FastAPI
🔒 Subscribe to keep reading.
Step 6 — Using it directly (without MCP yet)
🔒 Subscribe to keep reading.
Step 7 — Where MCP comes in
🔒 Subscribe to keep reading.
🔒 Subscribe to keep reading.
Step 9 — Integrating the MCP Tool with an Obsidian and Jekyll Blogging Workflow
🔒 Subscribe to keep reading.
🔒 Subscribe to keep reading.
References
🔒 Subscribe to keep reading.
Practical Upgrade Path
🔒 Subscribe to keep reading.
You've hit a Deep Dive tutorial.
I spend dozens of hours researching, coding, and breaking things to write these guides. This content is free, but reserved for my subscriber community. Drop your email below to unlock this guide (and all past/future deep dives):
Full content temporarily unavailable — refresh in a moment
Already a subscriber? Use the magic link from your last newsletter, or reset your password.
Log in to unlock
New subscribers get an inbox mail: Set a password to unlock articles. The form does not log you in — use the same email afterwards.