<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ravishka Madushan on Medium]]></title>
        <description><![CDATA[Stories by Ravishka Madushan on Medium]]></description>
        <link>https://medium.com/@ravishkamadushan?source=rss-c1ef63feeeb0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*A3hDoiGKMPzIl1gFQg249g.jpeg</url>
            <title>Stories by Ravishka Madushan on Medium</title>
            <link>https://medium.com/@ravishkamadushan?source=rss-c1ef63feeeb0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 21:59:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ravishkamadushan/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[STOP Tab-Juggling: How I Used MCP to Turn My AI into Support Engineer]]></title>
            <link>https://medium.com/@ravishkamadushan/stop-tab-juggling-how-i-used-mcp-to-turn-my-ai-into-support-engineer-4d59b61dc54b?source=rss-c1ef63feeeb0------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d59b61dc54b</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[model-context-protocol]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Ravishka Madushan]]></dc:creator>
            <pubDate>Wed, 27 May 2026 10:25:28 GMT</pubDate>
            <atom:updated>2026-05-27T10:25:28.493Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U5pNT4HYYBebNFBzL-9ydg.png" /><figcaption>The Old Way Vs New Way</figcaption></figure><p>Every technical support engineer knows the “Investigation Ritual.”</p><p>A ticket comes in: <em>“User USR_99 is getting a 500 Internal Server Error during checkout.”</em> Your browser tabs immediately multiply. You open a database Client to verify the user’s account status. You open your terminal to grep through raw server logs, or find yourself endlessly filtering through Kibana, Splunk, or Grafana dashboards trying to isolate the issue. You open your internal documentation to check for known errors. By the time you’ve gathered the context, chunks of your SLA time have vanished, your focus is fragmented, and the ticket is still In Progress.</p><p>What if you could give your AI coding assistant direct, secure “eyes” into your system? What if you could just paste the user ID into your IDE chat and say: <em>“Troubleshoot this user”</em> — and the AI handled the database queries and log scans for you?</p><p>This is exactly what the <strong>Model Context Protocol (MCP)</strong> does. Here is how I built a local custom troubleshooting agent in less lines of Python code.</p><h3>The Missing Link in AI Support: The “Context Gap”</h3><p>Large Language Models (like GPT or Claude) are incredibly intelligent, but when they sit inside your IDE or web browser, they are trapped in a clean room. They have no idea what is happening on your local machine, inside your database, or within your server log files.</p><p>Traditionally, we solved this by copy-pasting sensitive database rows and lines of logs directly into the chat box. It’s slow, it’s prone to human error, and it introduces data privacy risks.</p><p><strong>MCP changes the architecture.</strong> Introduced as an open standard, MCP acts like a universal adapter for AI. Instead of writing custom API code for every single AI model, you build a single “MCP Server” (a simple script), and any AI client that supports the protocol can instantly use it to fetch data securely.</p><h3>The Architecture: The Troubleshooting Trinity</h3><p>To understand how an AI can safely look into your logs, you need to understand the three components of MCP:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uw3XITO0i730zEjXNuI2nA.png" /></figure><ol><li><strong>The Host:</strong> The platform where you talk to the AI (e.g., VS Code or Cursor).</li><li><strong>The Brain (The Model):</strong> The LLM processing your language (e.g., GPT-5.4 running via GitHub Copilot).</li><li><strong>The Server:</strong> A small background application you write that acts as a gatekeeper to your data.</li></ol><p>When you ask a question, the Brain realizes it doesn’t have the data. It sends a standardized request to your Server. Your server grabs the local database data and log lines, filters out any noise, and feeds a clean text summary back to the AI.</p><h3>Building the 5-Minute “LogFinder” Server</h3><p>Using Python and the fastmcp library, we can build a simple support server that handles database querying and log parsing simultaneously.</p><p>1. The Code (debug_server.py)</p><pre>from fastmcp import FastMCP<br>import sqlite3<br>import os<br>import re<br><br># Initialize our MCP Server<br>mcp = FastMCP(&quot;LogFinder&quot;)<br><br>def sanitize_logs(text: str) -&gt; str:<br>    &quot;&quot;&quot;Helper to scrub sensitive data before the AI sees it.&quot;&quot;&quot;<br>    text = re.sub(r&#39;[\w\.-]+@[\w\.-]+&#39;, &#39;[EMAIL_HIDDEN]&#39;, text)<br>    # This catches anything starting with &#39;password=&#39; OR &#39;token=&#39;<br>    text = re.sub(r&#39;(password|token)=\S+&#39;, r&#39;\1=[REDACTED]&#39;, text)<br>    return text<br><br>@mcp.tool()<br>def troubleshoot_identifier(identifier: str) -&gt; str:<br>    &quot;&quot;&quot;Queries the user database and scans local system logs for a specific ID.&quot;&quot;&quot;<br>    context = &quot;&quot;<br>    <br>    # Part 1: The Database Query<br>    try:<br>        conn = sqlite3.connect(&quot;production_replica.db&quot;)<br>        cursor = conn.cursor()<br>        cursor.execute(&quot;SELECT name, plan_tier, status FROM users WHERE id = ?&quot;, (identifier,))<br>        db_result = cursor.fetchone()<br>        conn.close()<br>        <br>        if db_result:<br>            name, tier, status = db_result<br>            context += f&quot;DB Record Found: Account {name} | Tier: {tier} | Status: {status}\n\n&quot;<br>        else:<br>            context += f&quot;DB Record: Identifier {identifier} not found.\n\n&quot;<br>    except Exception as e:<br>        context += f&quot;Database Connection Error: {str(e)}\n\n&quot;<br><br>    # Part 2: The Log Search<br>    log_file = &quot;server.log&quot;<br>    matching_logs = []<br>    <br>    if os.path.exists(log_file):<br>        with open(log_file, &quot;r&quot;) as f:<br>            for line in f:<br>                if identifier in line:<br>                    matching_logs.append(line.strip())<br>                    <br>    if matching_logs:<br>        context += &quot;Recent Log Occurrences:\n&quot; + &quot;\n&quot;.join(matching_logs[-5:])<br>    else:<br>        context += &quot;Log Search: No matching log lines found.&quot;<br><br>    return sanitize_logs(context)<br><br>if __name__ == &quot;__main__&quot;:<br>    mcp.run()</pre><p>2. Plugging it into VS Code</p><p>To let GitHub Copilot see this tool, we simply open our global mcp.json configuration file in VS Code and register our new script:</p><pre>{<br>  &quot;servers&quot;: {<br>    &quot;LogFinder&quot;: {<br>      &quot;type&quot;: &quot;stdio&quot;,<br>      &quot;command&quot;: &quot;python&quot;,<br>      &quot;args&quot;: [&quot;C:/Users/SupportEngineer/Documents/debug_server.py&quot;]<br>    }<br>  }<br>}</pre><h3>What the Support Workflow Looks Like Now</h3><p>Once you toggle <strong>Agent Mode</strong> on in your VS Code Copilot Chat and check your custom tool in the configuration menu, your day-to-day workflow completely transforms.</p><p>Instead of manual queries, you type:</p><blockquote>Agent, troubleshoot user ID ‘USR_99’.</blockquote><p>Behind the scenes, the AI sees the troubleshoot_identifier tool, runs your script, parses the output, and responds natively.</p><blockquote>I found user ‘Alice Smith’ in the database. Her account status is ‘Active’ on the Premium Tier. However, looking at the server logs, her identifier triggered an HTTP 500 DatabaseTimeoutError at 10:42 AM due to an unindexed query in the checkout module. Here is the patch required to fix that query…</blockquote><p>Not only did it find the problem; because it has a developer’s reasoning engine, it can instantly pivot to writing the exact code fix or database index you need to resolve the issue.</p><h3>Security Best Practices: Building a Safe Sandbox</h3><p>When bringing an AI tool close to internal infrastructure, security isn’t just an afterthought — it’s the entire foundation. Because MCP runs locally using standard I/O streams (stdio), your data stays on your machine. However, to make this enterprise-safe, you should implement three core guardrails:</p><ol><li><strong>Enforce Read-Only Database Access:</strong> Never connect your MCP server using a database user that has write or admin permissions. Use a dedicated database user restricted strictly to SELECT privileges. Better yet, target a local database replica or staging environment to ensure zero impact on live traffic.</li><li><strong>Sanitize Data Before It Leaves:</strong> Your Python script acts as a localized firewall. Implement strict Regex filters (like the sanitize_logs function above) to automatically scrub out PII(Personally Identifiable Information), emails, tokens before the text payload is sent to the LLM.</li><li><strong>Truncate and Cap Outputs:</strong> Never let your script return 10,000 lines of raw text. Cap your log arrays (e.g., using matching_logs[-5:]) to give the AI just enough context to solve the problem without leaking unnecessary data into your chat history.</li></ol><h3>Conclusion</h3><p>MCP is shifting AI away from being an isolated chat widget and turning it into an interconnected operational agent. By putting a small, secure Python gatekeeper between your data and your IDE, you eliminate context switching entirely. For technical support, the days of manual tab-juggling are officially numbered.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d59b61dc54b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>