Elena' s AI Blog

Build Your First MCP Tool: AI News Search and Newsletter in Python

20 Sep 2026 (updated: 16 Nov 2026) / 23 minutes to read

Elena Daehnhardt

Generated by Midjourney. Prompt: Abstract glowing neural network representing superintelligent AI.


TL;DR:
  • - Build a FastAPI service in Python with two endpoints: `/search_ai_news` (queries the NewsAPI `/v2/everything` endpoint) and `/newsletter` (calls a local Ollama model to draft a newsletter).
  • - This "MCP-style" service is not yet a real MCP server — wrap it with the FastMCP framework's `FastMCP` class to make it genuinely callable by an MCP client over stdio or Streamable HTTP.
  • - Ends with a small Python agent script that calls the service and saves a ready-to-edit newsletter draft for your Obsidian vault.

Previous: Part 9 — Connecting Codex CLI, Cursor, and Antigravity via MCP

Next: Part 15 — A Gentle Introduction to MCP

Where this fits:MCP Explore the AI Landscape →

Build Your First MCP Tool

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:

  1. searches the web for AI-related news, and
  2. 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.


What You’re Building: An MCP-Style FastAPI News and Newsletter Tool

We’ll create a tiny HTTP service using FastAPI with two main endpoints:

  1. /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.

  2. /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:

  • Basic Python knowledge (functions, virtualenv, running scripts).
  • Python 3.10+ recommended.
  • A terminal that doesn’t scare you completely.
  • A news API key. In this example, we’ll assume something like NewsAPI or a similar REST news provider. (You can adapt to Tavily, SerpAPI, etc.)
  • Ollama installed and running locally.
  • A model pulled in Ollama, for example:

    ollama pull llama3
    

We’ll call the model "llama3" in the code, but you can change it.


Still in this guide

  • Step 1 — Project layout
  • Step 2 — Configuration with environment variables
  • Step 3 — A tiny client for the news API
  • Step 4 — A tiny client for Ollama (local LLM)
  • Step 5 — Wiring everything with FastAPI
  • Step 6 — Using it directly (without MCP yet)
  • Step 7 — Where MCP comes in
  • Step 8 — Example: calling the tool from a small “agent” script
  • Step 9 — Integrating the MCP Tool with an Obsidian and Jekyll Blogging Workflow
  • Key Takeaways: Building Your First MCP Tool
  • References
  • Practical Upgrade Path

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):

Already a subscriber? Use the magic link from your last newsletter, or reset your password.

New subscribers get an inbox mail: Set a password to unlock articles. The form does not log you in — use the same email afterwards.

desktop bg dark

About Elena

Elena, a PhD in Computer Science, simplifies AI concepts and helps you use machine learning.

Citation
Elena Daehnhardt. (2026) 'Build Your First MCP Tool: AI News Search and Newsletter in Python', daehnhardt.com, 20 September 2026. Available at: https://daehnhardt.com/blog/2026/09/20/build-your-first-mcp-tool/
All Posts