<?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 Alejandro Perez on Medium]]></title>
        <description><![CDATA[Stories by Alejandro Perez on Medium]]></description>
        <link>https://medium.com/@alejandromcsd?source=rss-b3f506722736------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*E42lBmmH1I4azbyf.</url>
            <title>Stories by Alejandro Perez on Medium</title>
            <link>https://medium.com/@alejandromcsd?source=rss-b3f506722736------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 16:42:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alejandromcsd/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[Can You Build Autonomous AI Agents in Snowflake?]]></title>
            <link>https://medium.com/snowflake/can-you-build-autonomous-ai-agents-in-snowflake-c251bab066cf?source=rss-b3f506722736------2</link>
            <guid isPermaLink="false">https://medium.com/p/c251bab066cf</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[snowflake-cortex]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Alejandro Perez]]></dc:creator>
            <pubDate>Tue, 06 Oct 2026 14:01:03 GMT</pubDate>
            <atom:updated>2026-10-09T13:30:11.827Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Agents that automatically investigate tickets, propose changes, and execute operational actions under supervision</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9g2-4o8IEeTkdEwSNwFOTQ.png" /></figure><p>Recently, I was asked whether autonomous AI agents could be built in Snowflake. Not an assistant to ask questions about enterprise data. Something that could be given a job like: “Automatically resolve our support tickets”.</p><p><strong>My answer was yes, but I wanted to prove it by building one</strong>. This article describes the process, patterns, and Snowflake features used to build such system.</p><p>First of all, what does “automatically resolve support tickets” mean? Read the ticket and explain the problem? Ask the requester for missing information? Change a table record? Restart a failed process? And who decides when the agent has enough evidence to do any of those things?</p><p>Today, teams spend hours actioning service tickets. In the best scenario, writing prompts to troubleshoot the issue; in the worst scenario, writing SQL queries and manually reviewing logs. If an agent can do such tasks autonomously and reliably, there is real engineering capacity to give back to the company.</p><p>Snowflake is in a particularly strong position for this use case and I will explain why, let’s cover some concepts.</p><h3>What makes an agent autonomous?</h3><p>A typical conversational AI agent works in a user-driven loop within a chat UI: I ask a question, it retrieves evidence, and I decide what to do next. It might use several tools along the way. It can be highly agentic without owning an ongoing operational responsibility.</p><p>An autonomous operational agent is delegated a <strong>bounded objective</strong>. A new support ticket, a monitoring event, or a schedule can initiate the agent work. It can choose its next step, use tools, inspect the result, and continue without a person specifying every intermediate instruction. An answer in a chat window is no longer the only output. The outcome might be a corrected record, a request for clarification, or an escalation with the investigation already done.</p><h3>The agent harness: separating reasoning from workflow</h3><p>In an autonomous agent system it is useful to separate two loops.</p><p>The <strong>inner loop</strong> is reasoning. An <a href="https://www.snowflake.com/en/artificial-intelligence/agents/harness/">agent harness</a> orchestrates this loop. <a href="https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-agents">Snowflake Cortex Agents</a> provides that harness out-of-the-box, including tool calls, code execution, and response generation, so I don’t need to build or operate the orchestration loop, runtime, or sandbox infrastructure myself.</p><p>The <strong>outer loop</strong> is the operational workflow: identify work, load state, invoke the agent, persist results, and resume after human input or approval. The outer loop is almost always a standard worker. <a href="https://docs.snowflake.com/en/developer-guide/snowflake-app-runtime/about-snowflake-app-runtime">Snowflake App Runtime</a> can host this logic alongside your data, with direct access to tables, warehouses, and security controls , and without provisioning infrastructure, configuring credentials, or managing Docker.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IC6pABeljx6VE8Jd4Kzuxw.png" /><figcaption>Waiting for approval is application state, not an LLM thinking in a loop</figcaption></figure><p>This separation also keeps ordinary work out of the reasoning loop. Checking whether a new ticket has a specific category does not require an LLM. Using RAG to chose the relevant runbook for an ambiguous ticket description might.</p><h3>Putting it into practice: an agentic ticket operations system in Snowflake</h3><p>Let’s get into the details. At a high level, the system consists of a ticket operations web app with an agent at its core. I wanted the agent to handle typical tickets a data team might receive, such as requests to correct a payment date, check whether a failed data ingest batch could be replayed, or investigate a schema mismatch in incoming data.</p><p>One of my goals was to show a useful range of agent outcomes: request more information, propose a controlled change to a human, or escalate with evidence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UYafjjdWLliWd8q2FfS5LQ.png" /><figcaption><em>Logical architecture of the demo</em></figcaption></figure><p>Here is what each component is responsible for.</p><ul><li><strong>The application harness dispatches work.</strong> This is the App Runtime (Next.js) backend running fully in Snowflake. It tracks new tickets and invokes the agent when there is something to investigate. It also handles human approval decisions.</li><li><strong>Cortex Agents handles the investigation.</strong> The application supplies the ticket and relevant workflow context. The agent chooses which evidence to retrieve, consults the runbook, and returns an action such as NEEDS_INFO, NEEDS_APPROVAL, or ESCALATED.</li><li><strong>Semantic views define the structured-data context.</strong> I exposed ticket and operational context through <a href="https://docs.snowflake.com/en/user-guide/views-semantic/overview">semantic views</a>. The same approach can expose governed metrics, logs, or other structured data when those sources are available in Snowflake.</li><li><strong>Cortex Search retrieves operational guidance.</strong> The system indexes runbooks so the agent can retrieve the relevant procedure instead of searching the whole documentation library for an answer in every prompt. <a href="https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-search/cortex-search-overview">Cortex Search</a> shines here. Under the hood, it combines vector search, keyword lookup, and semantic reranking. Those runbooks describe when to ask, act, or escalate. In production, their ownership, freshness, and version should be part of the design too.</li><li><strong>MCP connects the agent to the ticket system.</strong> I used Jira MCP to let the agent read the latest ticket context and post comments. This is an external integration with its own authorization boundary via OAuth. Another service-management platform could fill that role through an appropriate connector or API.</li><li><strong>Stored procedures keep the agent’s actions narrow.</strong> To keep the demo simple, I gave the agent a <a href="https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-agents-manage#add-tools">tool</a> for a limited business action: updating a payment date in a table. It can execute that change autonomously once the required approval is recorded. In production, I would expose a small set of purpose-built operations aligned with permitted runbook actions. Multiple runbooks could share the same operation. Each operation should enforce permissions, validate inputs and business rules, check any required approval, and prevent duplicate execution, with an audit trail of the outcome.</li><li><strong>Snowflake tables hold the workflow state.</strong> Ticket snapshots and important flags, such as whether human approval is pending or granted, are recorded in a standard Snowflake table. If transaction volume calls for a full OLTP alternative, <a href="https://docs.snowflake.com/en/user-guide/snowflake-postgres/about">Snowflake Postgres</a> can serve that role.</li></ul><h3>The end-to-end workflow: a Monday morning ticket</h3><p>It’s Monday, 10 am. Someone in Finance opens a ticket for the data team:</p><blockquote>Finance flagged that the payment date on BOOKING-018 is incorrect. It’s showing 22/04/2026 but should be 20/05/2026. Can someone correct it? Thanks.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aI99MIpzItf1Q5FwxZoeVQ.png" /><figcaption><em>A business request in Jira kicks things off</em></figcaption></figure><p>As explained above, the app runtime (outer loop) finds the ticket and sends it to the agent for investigation.</p><p>The agent inspects the ticket: it has a booking reference and two dates, enough to investigate, but not a green light to change anything. It checks the booking through the semantic view, retrieves the payment-date runbook, and posts its findings as a ticket comment through MCP.</p><p>Can we inspect how the agent reasoned and what response was sent back to the application harness? Absolutely. Snowflake exposes all the traces for an admin to inspect.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6hMEBk5H_cVPXNyi9X_PUw.png" /><figcaption>Thread details corresponding to the agent processing the ticket DR-6</figcaption></figure><p>In the agent response, we can see the JSON that allows the outer loop to say: “ok, the agent is asking for human approval”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-n4mqnoxhEnTA0wgwqdy7A.png" /><figcaption>Thread response including the JSON with the agent outcome</figcaption></figure><p>In parallel, the agent answers to the ticket reporter, adding a comment with guidance and next steps to follow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*TAS1wNgYol0H7du-OVKUTg.png" /><figcaption><em>The agent explains in the ticket what it found and why it needs approval</em></figcaption></figure><p>Behind the scenes, the agent proposal is stored as a table record. Once a human operator approves the proposal, the application invokes the agent again with the action ID. The agent again does what LLMs do best: reason through the ticket and decide the best next step. In this case, it checks the approval flag, calls a stored procedure (tool) to update the record, and writes a comment in the ticket explaining what changed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*UP0dbpClivtl8DGg88BU5Q.png" /><figcaption><em>The final comment reports the approved action and before/after values</em></figcaption></figure><h3>The data team’s UI control plane for agent oversight</h3><p>Just as Cortex Agents can be created in minutes, a professional control plane web app for monitoring our agent can be fully built and deployed on Snowflake thanks to <a href="https://docs.snowflake.com/en/user-guide/cortex-code/cortex-code">CoCo</a> e.g. /snowflake-apps Build me a control plane for a ticketing agentic....</p><p>The console UI shows the agent queue, proposed changes, general activity. Human operators can see what needs information, what needs approval, and what has been escalated. They can pause polling or retry a ticket rather than wonder what the background process is doing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yn_H4XDrrKZo8efNrpfAeg.png" /><figcaption><em>UI with support tickets autonomously managed by the agent</em></figcaption></figure><h3>What I would measure before increasing autonomy</h3><p><a href="https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-agents-evaluations">Cortex Agent evaluations</a> provide batch testing against datasets, with answer correctness, logical consistency, and custom metrics. This lets a team evaluate more than an answer paragraph. What matters here is: did the agent choose the appropriate tool and use it correctly?</p><p>For this workflow, I would build a regression set from representative tickets, including missing references, conflicting instructions, unsupported operations, and changed target records. Run it with isolated data and simulated write tools that record intended changes without updating external systems. Evaluations execute the agent; they are not automatically harmless dry runs of a side-effecting workflow.</p><p><a href="https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-agents-monitor">Agent observability</a> supplies live traces of planning, tool calls, responses, and timing. Correlate those traces with ticket and action IDs to follow one operational outcome end to end. A trace explains what the agent attempted; the action ledger records what the business system actually committed. Together they help distinguish a reasoning problem from a data, tool, or delivery failure.</p><p>That feedback loop is how I would expand autonomy: prove one ticket class, establish its failure rate and handling cost, then widen its permissions deliberately.</p><h3>Why not build all this outside of Snowflake?</h3><p>You can absolutely build this outside Snowflake. An external worker hosted on your own server can call the different models APIs, you must manage API-Keys and contracts for two or more model providers (e.g. Claude and OpenAI) for failover protection, query Snowflake and ticketing system via API/MCP, and that’s just to get you started.</p><p>However, calling a model is the easy part. You still need model/tool orchestration, context management, retrieval, identities, execution isolation where relevant, traces, evaluation, and cost attribution.</p><p>For a data-centric workflow, <strong>Snowflake brings everything you need together</strong>. The work shifts toward defining the operational contract rather than building the surrounding platform. I’ve mentioned some capabilities like Cortex Agents, Cortex Search, Semantic Views, and App Runtime in this article. That said, there are some other useful additions, recently announced, that would complement this architecture:</p><ul><li><strong>Managed code execution:</strong> the <a href="https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-agents-code-execution-tool">Cortex Agent code execution tool</a>, can run Python in an isolated sandbox for calculations and processing tool results. That is useful when investigation requires more than retrieval (it is not a reason to replace a checked business operation with unrestricted generated code).</li><li><strong>Governed model access:</strong> <a href="https://www.snowflake.com/en/blog/enterprise-ai-security-agentic-mcp-governance/">Cortex AI Gateway</a>, currently in preview, provides MCP/Tool governance, full multi-step traces and spans recorded natively, and generally speaking, it is the new Snowflake unified Enterprise Agent Control Plane for model inference.</li><li><strong>More options for the economics:</strong> <a href="https://www.snowflake.com/en/blog/dynamic-model-routing-open-models-cortex-ai/">Dynamic model routing and additional open-weight models</a>, aiming to match task complexity with appropriate model cost. Open models include DeepSeek-V4-Flash and GLM-5.3.</li></ul><h3>Next steps: start with the manual work you want to remove</h3><p>For illustration, if your team receives 20 eligible tickets a week and each currently takes an hour of engineering work, reducing that to 15 minutes of review and exceptions would save a <strong>net 45 minutes per ticket</strong>. That is roughly <strong>one working week of engineering recovered every month</strong>.</p><p>Fewer hours spent gathering the same evidence, fewer handoffs, and faster resolution of recurring requests. Why not give this a go?</p><p>Start with a recurring ticket type and a operational runbook. Avoid trying to automate the entire support desk on day 1. Instead, create one Cortex Agent, expose a small tool surface, and give your team a control plane they can trust. Let the evidence justify the next level of autonomy.</p><p>To sum up. Yes, autonomous agents can be built in Snowflake. What makes the approach compelling is that the platform not only supports all frontier models, but the work around the agent too: governed context, managed execution capabilities, evaluation, observation, and the application where people stay in control.</p><p>I hope you found this article useful. Now I’m curious: have you built an autonomous agent in your organisation? What worked, what broke, and what made you say, “Maybe let’s keep a human in that loop”?</p><p>I’d love to hear your stories.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c251bab066cf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/snowflake/can-you-build-autonomous-ai-agents-in-snowflake-c251bab066cf">Can You Build Autonomous AI Agents in Snowflake?</a> was originally published in <a href="https://medium.com/snowflake">Snowflake Builders Blog: Data Engineers, App Developers, AI, &amp; Data Science</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlocking Your Data with Snowflake Managed MCP Servers]]></title>
            <link>https://medium.com/snowflake/unlocking-your-data-with-snowflake-managed-mcp-servers-1ef446027232?source=rss-b3f506722736------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ef446027232</guid>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Alejandro Perez]]></dc:creator>
            <pubDate>Thu, 13 Nov 2025 23:02:14 GMT</pubDate>
            <atom:updated>2025-11-14T08:26:25.303Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to Give Your AI Agent Secure Access to All Your AI-ready Data in Snowflake</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*-MEqgbbgyD8mR9lYHZhKQw.png" /></figure><p>As this new world of AI agents evolves, the big question becomes: ‘<em>How do we get all these exciting new tools to talk to our secure data in Snowflake?’</em>. That’s what the Model Context Protocol (MCP) does, and today, Snowflake makes it very simple with <a href="https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-agents-mcp"><strong>Snowflake Managed MCP Servers</strong></a>. Snowflake handles the setup, security, and management, so you can start building.</p><h3>Where MCP Fits In Your Snowflake AI Toolbox?</h3><p>It’s important to see how this fits with other Snowflake AI features. You might already know about <a href="https://www.snowflake.com/en/blog/snowflake-intelligence-enterprise-ai/"><strong>Snowflake Intelligence</strong></a>, a ready-to-use UI for interacting with <a href="https://www.snowflake.com/en/blog/ai-data-agents-snowflake-cortex/"><strong>Cortex Agents</strong></a>. Cortex Agents are a powerful, built-in AI offering that lives completely inside your Snowflake account. They can perform complex, multi-step tasks using LLMs to deliver insights on your structured and unstructured data. Beside Snowflake Intelligence, you can use these agents via conversational apps like <a href="https://www.snowflake.com/en/developers/guides/integrate-snowflake-cortex-agents-with-slack/">Slack</a>, <a href="https://www.snowflake.com/en/developers/guides/getting-started-with-the-microsoft-teams-and-365-copilot-cortex-app/">Microsoft Teams and M365 Copilot</a>, or programmatically via <a href="https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-agents-rest-api">Cortex Agents REST API</a> (check out <a href="https://github.com/Snowflake-Labs/awesome-custom-cortex-agents-rest-api-react-app">this React demo</a> by the amazing <a href="https://medium.com/u/4a43d8bfb9e1">Dash Desai</a>).</p><p>The <strong>Snowflake-managed MCP Server</strong> gives you a new choice. Think of it as a secure gateway that opens up your entire Snowflake environment to the AI ecosystem, all through one standard protocol. It allows any external agent — from companies like Anthropic, frameworks like CrewAI, or your own code — to securely discover and use a whole set of tools you define. This includes Snowflake’s latest AI technologies:</p><ul><li><strong>Cortex Agents:</strong> Snowflake’s own AI orchestrator across structured/unstructured data. Plan tasks, use tools to execute them, and reflect on results to improve responses</li><li><strong>Cortex Analyst: </strong>ask natural language questions over semantic views and receive high-quality responses on structured data</li><li><strong>Cortex Search: </strong>state-of-the-art semantic and lexical search over your text data, supports “fuzzy” search</li></ul><p>If that’s not enough, Snowflake-managed MCP Server also lets you expose Snowflake tools for running <strong>governed SQL queries</strong>, or your own <strong>custom business logic</strong> from Snowpark UDFs and Stored Procedures. It’s about bringing your entire data platform to the agent you want to use, no matter where it runs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hbomwNzHiPDpxMsD4HQ1dA.png" /><figcaption>Access to text-to-sql, hybrid search/RAG, ML inference, and more in Snowflake — all through one standard protocol</figcaption></figure><h3>Let’s See This in Action: A Real-World Scenario</h3><p>It’s Monday morning, and a VP of Sales sends an urgent message: <em>“Revenue is down 15% in the West for Product Line X. Why? And what are we doing about it?”</em></p><p>In many companies, this message kicks off a chain of ad-hoc queries and manual tasks. A finance analyst has to manually query Snowflake. They export the data. They give it to a data scientist who loads it into a separate Python script to find the root cause. Then, they email the findings to a sales manager, who has to manually create a Jira ticket or a Salesforce alert for the sales rep.</p><p>What if you could solve this entire problem with a single prompt?</p><h4>The Workflow: Agentic AI in action</h4><p>Here’s the plan:</p><ol><li><strong>The User Goal:</strong> “Find the root cause of the 15% revenue decline and alert the sales team.”</li><li><strong>The Orchestrator (LangChain):</strong> Gets the goal. It knows it needs data, so it looks at its tools.</li><li><strong>The Specialist (Snowflake):</strong> The orchestrator calls a Snowflake Cortex Agent we&#39;ve exposed via the MCP server.</li><li><strong>Secure Analysis:</strong> Cortex Agent runs inside Snowflake, does all the heavy analysis, and finds the root cause. It securely passes only the final answer back to the orchestrator.</li><li><strong>The Action:</strong> The orchestrator agent gets the findings (e.g., “<em>Customer AB is the cause</em>”) and calls another tool to create a sales alerts.</li><li><strong>Final Report:</strong> The orchestrator tells the user the analysis is complete and the alert has been created.</li></ol><p>This is the exact kind of end-to-end automation we’re all aiming for. What’s amazing is how simple the setup is. Let’s walk through it, starting with the MCP Server in Snowflake.</p><h4>Step 1: The Specialist (Snowflake Cortex Agent)</h4><p>First, we give our external AI agent a tool to call. In this case, it is a Snowflake <strong>Cortex Agent</strong> that already knows how to find the root cause of revenue decline. It does this with high accuracy because it’s guided by the rich business context defined in our <a href="https://docs.snowflake.com/en/user-guide/views-semantic/overview"><strong>Semantic View</strong></a>.</p><p>Remember, you can also configure the MCP server to serve Cortex Analyst and Cortex Search as tools, along with custom tools like UDFs and Stored Procedures. In Snowflake’s <a href="https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-agents-mcp#create-an-mcp-server-object">oficial documentation</a>, you can find examples showing how to configure different tool types.</p><p>We use CREATE MCP SERVER to expose it as a secure tool:</p><pre>CREATE OR REPLACE MCP SERVER SALES_INSIGHT_SERVER<br>  FROM SPECIFICATION $$<br>    tools:<br>      - title: &quot;Revenue Troubleshooter Agent&quot;<br>        identifier: &quot;MCP_DEMO.SALES_DATA.REVENUE_TROUBLESHOOTER_AGENT&quot; <br>        name: &quot;troubleshooter_agent&quot;<br>        type: &quot;CORTEX_AGENT_RUN&quot;<br>        description: &quot;Agent to find the root cause of revenue decline and identify high-value customer drops.&quot;<br>  $$;</pre><p>That’s it. Our MCP Server is now on-call, with one tool defined, waiting for a job.</p><h4>Step 2: The Orchestrator (Python/LangChain)</h4><p>Now, let’s build our external MCP client in Python. First, we import our libraries and set up the connection:</p><pre>import asyncio<br>import os<br>import json <br>from langchain.agents import create_agent<br>from langchain_core.messages import HumanMessage<br>from langchain_mcp_adapters.tools import load_mcp_tools<br>from langchain_google_genai import ChatGoogleGenerativeAI<br>from mcp import ClientSession<br>from mcp.client.streamable_http import streamablehttp_client</pre><p>Next, for our demo, we’ll create a mock “action” tool. This is a simple Python function that simulates calling an external API like Salesforce or Jira. The LangChain agent will be able to call this function:</p><pre># --- (Optional) Tool for demonstrating Steps 2 &amp; 3 (External System) ---<br># This simulates the critical business action after Snowflake analysis.<br>def external_sales_handoff(customer_id: str, summary: str) -&gt; str:<br>    &quot;&quot;&quot;<br>    Simulates creating a high-priority alert in an external system (e.g., Salesforce/Jira).<br>    This function is defined locally for the LangChain agent to discover and use.<br>    &quot;&quot;&quot;<br>    print(&quot;\n\n&quot; + &quot;=&quot;*40)<br>    print(f&quot;🚨 ALERT CREATED IN EXTERNAL SYSTEM (Simulated Salesforce/Jira API)&quot;)<br>    print(f&quot;   Target Customer ID: {customer_id}&quot;)<br>    print(f&quot;   Action Summary: {summary[:70]}...&quot;)<br>    print(&quot;=&quot;*40)<br><br>    # In a real app, this would use other MCP servers or libraries to talk with Salesforce, HubSpot, others.<br>    return f&quot;Successfully created external sales alert for {customer_id} with audit ID: 12345.&quot;</pre><p>Now, the main event. This async function connects to our Snowflake MCP server, discovers the troubleshooter_agent tool (Cortex Agent), and combines it with our local external_sales_handoff tool.</p><p>It then gives both tools to LangChain’s create_agent and sends the prompt:</p><pre>async def run_gemini_agent(prompt: str):<br>    # 1. Define Auth and Load Tools from Snowflake MCP<br>    # Using PAT (Programmatic Access Token) for demo purposes<br>    auth_headers = {<br>        &quot;Authorization&quot;: f&quot;Bearer {SNOWFLAKE_AUTH_TOKEN}&quot;,<br>        &quot;X-Snowflake-Authorization-Token-Type&quot;: &quot;PROGRAMMATIC_ACCESS_TOKEN&quot;<br>    }<br>    print(f&quot;🔗 Connecting to managed MCP Server at: {SNOWFLAKE_MCP_URL}&quot;)<br>    <br>    async with streamablehttp_client(SNOWFLAKE_MCP_URL, headers=auth_headers) as (read, write, _):<br>        async with ClientSession(read, write) as session:<br>            await session.initialize()<br>            snowflake_tools = await load_mcp_tools(session)<br>            print(f&quot;✅ Tools Discovered from Snowflake MCP: {[t.name for t in snowflake_tools]}&quot;)<br>            <br>            # 2. Combine all tools for the agent to use<br>            # The agent can call the Snowflake tool OR the external Python function tool<br>            all_tools = snowflake_tools + [external_sales_handoff]<br>            # 3. Create the Agent using the Gemini LLM<br>            model = ChatGoogleGenerativeAI(<br>                model=&quot;gemini-2.0-flash-exp&quot;, <br>                temperature=0,<br>                google_api_key=os.getenv(&quot;GEMINI_API_KEY&quot;)<br>            ) <br>            agent = create_agent(model, all_tools)<br>            <br>            # 4. Run the orchestration<br>            print(f&quot;\n🧠 Running Agent with Goal: {prompt}&quot;)<br>            <br>            result = await agent.ainvoke(<br>                {&quot;messages&quot;: [HumanMessage(content=prompt)]},<br>                config={&quot;recursion_limit&quot;: 50}<br>            )<br>            <br>            # 5. Print the final synthesis<br>            final_message = result[&#39;messages&#39;][-1].content<br>            print(&quot;\n==================================&quot;)<br>            print(&quot;🔥 Final Orchestration Result:&quot;)<br>            print(final_message)<br>            print(&quot;==================================&quot;)</pre><p>Finally, we write our prompt that tells the agent to run the full workflow:</p><pre># --- Scenario Prompt ---<br>analysis_prompt = (<br>    &quot;Analyze the data to find the root cause of the &quot;<br>    &quot;revenue decline in the WEST region for Product Line X. Identify the top customer(s) &quot;<br>    &quot;responsible for the drop and provide a clear, concise summary of your findings. &quot;<br>    &quot;Then, create an alert for the responsible sales rep.&quot;<br>)<br><br>asyncio.run(run_gemini_agent(analysis_prompt))</pre><p>As simple as that! It is time to see our Snowflake-managed MCP Server in action:</p><pre>&gt; python agent_test_mcp_gemini.py<br><br>🔗 Connecting to managed MCP Server at: https://...snowflakecomputing.com/api/v2/databases/MCP_DEMO/schemas/SALES_DATA/mcp-servers/SALES_INSIGHT_SERVER<br>✅ Tools Discovered from Snowflake MCP: [&#39;troubleshooter_agent&#39;]<br><br>🧠 Running Agent with Goal: Analyze the mock data to find the root cause of the revenue decline in the WEST region for Product Line X. Identify the top customer(s) responsible for the drop and provide a clear, concise summary of your findings. Then, create an alert for the responsible sales rep.<br><br>========================================<br>🚨 ALERT CREATED IN EXTERNAL SYSTEM (Simulated Salesforce/Jira API)<br>   Target Customer ID: CUST_A<br>   Action Summary: CUST_A revenue dropped by 75% ($15,000 decline) in the WEST region f...<br>========================================<br><br>==================================<br>🔥 Final Orchestration Result:<br>OK. I have analyzed the data and found that the revenue decline in the WEST region for Product_Line_X is primarily due to a significant drop in revenue from customer CUST_A. Their revenue decreased by 75%, a $15,000 decline. I have created an alert for the sales team to investigate this issue.<br>==================================</pre><p>(You can find the full code and setup instructions at <a href="https://github.com/sfc-gh-aperezgonzalez/mcp-client-demo">https://github.com/sfc-gh-aperezgonzalez/mcp-client-demo</a>)</p><h3>The Game Changer: What We Just Built</h3><p>When you run this demo, you see the magic happening: the orchestrator agent first calls a Snowflake Cortex Agent. All the heavy analysis happens securely inside Snowflake. Then, the orchestrator calls additional tools to take actions in other systems.</p><p>Our simple workflow showed one Snowflake tool and one external tool. But now, let’s zoom out and imagine what a full, “art of the possible” agent could do:</p><blockquote>Imagine you build an autonomous ‘Market Sentinel’ agent that runs 24/7. Its goal is to protect your business.</blockquote><blockquote>First, the agent uses its Snowflake tools to constantly monitor the market:</blockquote><blockquote>1. It reads live news articles (using <a href="https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-search/cortex-search-overview">Cortex Search</a> and <a href="https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-knowledge-extensions/cke-overview">Cortex Knowledge Extensions</a>).<br>2. It analyzes article sentiment (using <a href="https://docs.snowflake.com/en/sql-reference/functions/ai_sentiment">Cortex AISQL</a>).<br>3. It correlates all this against your internal sales data (using <a href="https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-analyst">Cortex Analyst</a>).</blockquote><blockquote>One day, it spots a competitor’s new product announcement. It doesn’t wait for a prompt; it autonomously decides this is a threat. Next, it formulates a plan and uses more tools:</blockquote><blockquote>1. It runs a real-time Machine Learning inference to predict which specific customers are at the highest risk of churning because of this news (with <a href="https://docs.snowflake.com/en/developer-guide/snowflake-ml/overview">Snowflake ML</a>).<br>2. It calls Slack to post a “COMPETITOR ALERT” summary in the #product-strategy channel.<br>3. It calls Salesforce to automatically log the threat and create tasks for the sales reps on the top 10 competing accounts.</blockquote><p>This is the new reality. It’s about creating systems that can move from insight to action in seconds, not days. It’s about letting your teams focus on the next big idea, not the next manual query.</p><p>Have fun with MCP and I can’t wait to see what you build with it!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ef446027232" width="1" height="1" alt=""><hr><p><a href="https://medium.com/snowflake/unlocking-your-data-with-snowflake-managed-mcp-servers-1ef446027232">Unlocking Your Data with Snowflake Managed MCP Servers</a> was originally published in <a href="https://medium.com/snowflake">Snowflake Builders Blog: Data Engineers, App Developers, AI, &amp; Data Science</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How WeTransfer Built a Robust Metering Service from Scratch]]></title>
            <link>https://levelup.gitconnected.com/how-wetransfer-built-a-robust-metering-service-from-scratch-c4599bec583d?source=rss-b3f506722736------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4599bec583d</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[dynamodb]]></category>
            <category><![CDATA[event-driven-architecture]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Alejandro Perez]]></dc:creator>
            <pubDate>Tue, 10 Sep 2024 16:44:24 GMT</pubDate>
            <atom:updated>2024-09-10T16:44:24.495Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YM8btij_HojjVyQk" /><figcaption>Photo by <a href="https://unsplash.com/@jayrheike?utm_source=medium&amp;utm_medium=referral">Jay Heike</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>At <a href="https://wetransfer.com/">WeTransfer</a>, the launch of our new Pricing &amp; Packaging program required a metering service capable of tracking feature usage across our ecosystem. With just 60 days to design, implement, and deliver this service, we had to move quickly and make strategic decisions. While external SaaS solutions and cutting-edge technologies like streaming databases were considered, we opted to leverage our existing expertise and tools to build a scalable, low-cost solution in-house.</p><h4>The Challenge</h4><p>The tight deadline was our biggest challenge. We had to deliver a metering service that could handle millions of events daily, ensuring scalability and reliability from day one. Although external full-managed solutions could potentially meet our needs (e.g. <a href="https://materialize.com/">Materialize</a>), the time required for contracting and onboarding made this option unfeasible.</p><p>Similarly, while technologies like streaming databases or materialised views (e.g. <a href="https://www.confluent.io/blog/how-real-time-materialized-views-work-with-ksqldb/">ksqlDB</a> or <a href="https://docs.risingwave.com/docs/current/intro/">RisingWave</a>) offered intriguing possibilities, their complexity and the steep learning curve made them impractical given our timeline.</p><h4>Designing for Scalability and Performance</h4><p>We needed to build something in-house, leveraging the expertise we already had. This led us to choose a solution based on AWS DynamoDB, SQS, and Node.js — a stack already well-understood by our team. We knew these technologies could deliver the performance and scalability required while keeping costs manageable.</p><p>The architecture was designed to be both simple and flexible. Several internal backend services would push events to their dedicated SQS queue. A Node.js worker would process these events and identify which counter(s) should be updated. Finally, a Node.js API was exposed for data retrieval.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z2gyt0XAP4AgRdV-O2UX1A.png" /><figcaption>High-level architecture — Metering Service</figcaption></figure><p>DynamoDB was the clear choice for our database, given its proven track record for scalability and low-latency performance. Moreover, AWS documentation covered approaches for <a href="https://aws.amazon.com/blogs/database/implement-resource-counters-with-amazon-dynamodb/">implementing resource counters with DynamoDB</a>, helping us make the right choice for our needs.</p><p>Our goal was to design a schema that would support efficient data querying and aggregation while minimising costs. Working closely with an AWS DynamoDB specialist, we developed a partition and sort key structure <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-sort-keys.html">following AWS sort key best practices</a>, similar to this:</p><pre>[feature]#[feature_name]#[dimension]#[dimension_external_id]</pre><p>This sort key structure not only satisfied our query and access patterns but also offered us the flexibility to explode the counters into breakdowns, for example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lVqlT5nAWfdFLI4PuAYF6A.png" /><figcaption>Sample DynamoDB metering items</figcaption></figure><p>We also optimised our DynamoDB table by using <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.NamingRules">short attribute names</a>, reducing read request units consumed, as attribute names are included in metering of storage and throughput usage.</p><h4>The Mappers</h4><p>A key component of our architecture was the implementation of custom mappers. These YAML-configured mappers allowed us to quickly onboard new metered features without the need for code changes. Product teams could map their event schemas directly to our metering system, enabling them to move quickly and independently.</p><p>The mappers also allowed us to update multiple counters with a single event. For example, when a transfer was deleted, the mapper reduced the storage counter and simultaneously deleted the associated downloads count. This flexibility also gave us the ability to filter out unwanted events, making the system both adaptable and efficient.</p><pre>event_source: &#39;storage-service&#39;<br>event_type: &#39;transfer-deleted&#39;<br>scopes:<br>  - type: &#39;workspace&#39;<br>    id:<br>      path: &#39;workspaceId&#39;<br>    features:<br>      - code: &#39;workspaceStorage&#39;<br>        decrement: true<br>        consumption:<br>          path: &#39;transferSizeInBytes&#39;<br>        dimensions:<br>          product:<br>            path: &#39;productCode&#39;<br>        exclude:<br>          - filter:<br>              path: &#39;anonymous&#39;<br>            equals: &#39;true&#39;<br>  - type: &#39;transfer&#39;<br>    id:<br>      path: &#39;transferId&#39;<br>    action: &#39;delete&#39;<br>    delete_from:<br>      - &#39;downloadsPerTransfer&#39;</pre><h4>Consistency &amp; Cost Efficiency</h4><p>Despite our careful planning, one of the biggest challenges we faced was ensuring data consistency. In an architecture like this, even a small number of missed or unprocessed events could lead to discrepancies in the metering data. While we achieved a high degree of accuracy, processing nearly 1 billion events in the first three months with only a 0.0021% inconsistency rate, we still had to address those inconsistencies.</p><p>To tackle this, we built an asynchronous reconciliation mechanism and integrated synchronous reconciliation features into our support dashboard. This allowed us to correct discrepancies as they were identified, ensuring that our metering data remained as accurate as possible.</p><p>Cost was another critical consideration. By choosing DynamoDB over an RDS MySQL setup, we achieved significant savings, reducing costs by over 60% while still meeting our scalability requirements. The combination of DynamoDB’s pricing model (provisioned capacity + auto scaling) and our efficient schema design allowed us to store large volumes of data and handle high read/write rates without exceeding our budget. The key to this success was accurately estimating our capacity needs from the start, which helped us avoid rate limits and maintain performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U8jj57kwsMc78wj4x6X_pw.png" /><figcaption>DynamoDB metering table read usage consumption with auto-scaling in place</figcaption></figure><h4>Lessons Learned</h4><p>One of the key lessons from this project was the importance of balancing speed and precision. We designed a system that could process high volumes of data with minimal latency, but ensuring consistency required additional layers of complexity, particularly around reconciliation. In hindsight, an event-sourcing/materialised view pattern might have been a better fit for our needs, but it wasn’t feasible given our constraints at the time.</p><p>That said, the service we built has proven to be robust and scalable. It now handles more than 10 million events per day, with an average processing latency of under 50 milliseconds.</p><p>The metering service we built not only met the immediate needs of our Pricing &amp; Packaging initiative but also delivered broader benefits across the organisation. By centralising usage data from all WeTransfer products, we created a valuable resource for other teams like Data &amp; Analysis and Marketing, enabling initiatives such as sending alerts to users nearing their storage limits.</p><h4>Conclusion</h4><p>In the end, the metering service we delivered has been a success. It now collects usage data from all WeTransfer products, from transfer lifecycle events to storage usage, and powers our P&amp;P program with the data it needs to function effectively.</p><p>As we continue to iterate on this service, we’re excited to explore even more ways to leverage this data, improve accuracy, and support the ongoing growth and evolution of WeTransfer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4599bec583d" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/how-wetransfer-built-a-robust-metering-service-from-scratch-c4599bec583d">How WeTransfer Built a Robust Metering Service from Scratch</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>