Blog

  • Building an MCP Server to Let Claude Read My Blood Sugar

    Disclaimer!!! Think very carefully before you expose your data to any third party, this is doubly important with health data. Everything here is for fun and in no way should be construed as medical advice or indeed any sort of advice.

    Overview

    A few years back I was diagnosed with type 2 diabetes due to a series of lab errors. This BBC News link has more detail but long story short my h1bac was reported 5 points over its actual meaning I was officially a diabetic. This came as a surprise and brought with it a whole bunch of worry.

    Shortly after I got the news I was invited the local surgery to have a Libre 2 sensor explained and fitted. These are small round discs that stick a needle into your arm and report your blood sugar to an application on your phone.

    Abbott’s LibreView phone application dashboard is fine for glancing at trends, but I wanted to actually interrogate my data: correlate glucose spikes with meals, compare patterns across weeks, ask questions I hadn’t thought of yet. Most of all I wanted to have the data on my servers. But that’s for another blog post.

    MCP

    Model Context Protocol is Anthropic’s open standard for connecting AI assistants to external data sources. Instead of copying and pasting data into Claude, you can build a small server that lets Claude query your data directly.

    You define what data it can access and how it authenticates. Claude does the rest.

    For my glucose data, this meant I could ask questions like:

    • “What was my average blood sugar last week?”
    • “Show me a graph of my readings over the past 24 hours”
    • “What time of day do I typically see spikes?”

    Claude would fetch the live data, analyse it, and respond conversationally.

    The Implementation

    The server is surprisingly simple. Around 100 lines of Python, using the mcp library and a Python library called https://pypi.org/project/pylibrelinkup/ that uses unofficial LibreLinkUp API.

    The core structure:

    from mcp.server.fastmcp import FastMCP
    from pylibrelinkup import PyLibreLinkUp
    
    mcp = FastMCP("blood_sugar")
    
    @mcp.tool()
    def get_blood_sugar() -> dict:
        """Fetch current blood sugar reading from Libre sensor."""
        client = PyLibreLinkUp(
            username=os.getenv("API_USERNAME"),
            password=os.getenv("API_PASSWORD")
        )
        return client.get_current()
    
    @mcp.tool()
    def get_blood_sugar_history() -> dict:
        """Fetch blood sugar history from Libre sensor."""
        client = PyLibreLinkUp(...)
        return client.get_history()

    What Can You Do With It?

    Once connected, the interactions become genuinely useful:

    Simple queries: “What’s my blood sugar right now?” returns the current reading with trend direction.

    Analysis: “Draw a graph of my blood sugar over the past 24 hours” Claude then fetches the history, generates a visualisation, and displays it inline.

    Pattern recognition: “When do I typically see my highest readings?” – Claude analyses the timestamps and identifies patterns.

    The key insight is that this isn’t just a dashboard replacement. It’s a conversational interface to my health data. I can ask follow-up questions, request different visualisations, or explore correlations without switching contexts.

    Why Build This?

    Partly curiosity. MCP is new and I wanted to understand how it worked.

    Partly practical. I genuinely wanted better access to my glucose data, and the official tools were lacking in interpretation.

    But mostly, I think there’s something interesting happening here. We’re moving from “apps that display your data” to “assistants that understand your data”. The interface isn’t a dashboard anymore.

    For health data specifically, this matters. I don’t always know what questions to ask. A dashboard shows me what its designers anticipated. A conversational interface can explore the unexpected.

    Try It Yourself

    The code is on GitHub: github.com/chrishannam/gcm-mcp

    You’ll need:

    • A Freestyle Libre 2 Plus sensor
    • A LibreLinkUp account connected to your sensor
    • Claude Desktop with MCP support
    • Python and uv for dependency management

    Setup takes about a few minutes and some Python knowledge is a bit of a must currently. The README walks through the configuration.

    What’s Next?

    I’m planning to extend this to pull in other health data – blood pressure from my Withings cuff, weight trends, maybe even correlations with my running data from Strava.

    The broader vision is a personal health assistant that actually knows my data, can spot patterns across multiple sources, and helps me make sense of it all. Not a replacement for medical advice, but a tool for understanding my own body better.

    If you’re sitting on interesting personal data and want to make it conversational, MCP is worth exploring but obviously take care as it’s your data and in no way a replacement for trained medical professional.

    Chris Hannam is a software engineer with 20+ years of Python experience, currently based in Northern England. He’s interested in health tech, data engineering, and building tools that make complex information accessible.

    Twenty Twenty-Five

    Designed with WordPress