<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Cursor AI on Jafforge Blog</title><link>http://jafforge.com/tags/cursor-ai/</link><description>Recent content in Cursor AI on Jafforge Blog</description><generator>Hugo -- 0.146.0</generator><language>en-us</language><lastBuildDate>Thu, 03 Jul 2025 00:00:00 +0000</lastBuildDate><atom:link href="http://jafforge.com/tags/cursor-ai/index.xml" rel="self" type="application/rss+xml"/><item><title>The Power of MCP for AI Tools</title><link>http://jafforge.com/posts/power-of-mcp-for-ai-tools/</link><pubDate>Thu, 03 Jul 2025 00:00:00 +0000</pubDate><guid>http://jafforge.com/posts/power-of-mcp-for-ai-tools/</guid><description>An intro to the Model Context Protocol: how it lets AI tools like Cursor query a Postgres database in natural language, with a full integration walkthrough.</description><content:encoded><![CDATA[<h2 id="introduction">Introduction</h2>
<p>A major trend in the world of AI tools right now is something called the Model Context Protocol (MCP). After researching and implementing it in one of my sample projects, I wanted to share an overview of MCP in this blog post.</p>
<h2 id="what-is-model-context-protocol">What is Model Context Protocol</h2>
<p>Model Context Protocol (MCP) is a flexible standard that allows AI tools to connect not just to databases, but to a wide range of resources such as APIs, file systems, document stores, and even real-time event streams. Its goal is to make it easy for AI applications to interact with all sorts of data and services using a common approach, so you can add new capabilities without a lot of extra work. While MCP can power integrations with web services, files, and custom plugins, in this post I&rsquo;ll focus specifically on how it can be used to connect AI tools to databases, since that&rsquo;s where I&rsquo;ve found it most immediately useful and impactful. Another great feature is that it enables users who aren&rsquo;t familiar with writing queries to perform various operations on a database. Based on your request, it will automatically generate and execute the appropriate query directly on the database.</p>
<h2 id="first-thing-first-we-need-a-database">First thing first, we need a database</h2>
<p>To showcase this example, we need to create a database. We&rsquo;ll create a Postgres database and deploy it on our machine using the Coolify platform, which we covered in this article: <a href="https://jafforge.com/posts/coolify/">https://jafforge.com/posts/coolify/</a>. This allows us to deploy a database in just two clicks.</p>
<p><img alt="Database Creation" loading="lazy" src="/posts/power-of-mcp-for-ai-tools/postgres_database.png"></p>
<p>Since this is a demo database, we&rsquo;ll create it with standard data and enable public access.</p>
<p><img alt="Database Creation" loading="lazy" src="/posts/power-of-mcp-for-ai-tools/publicly_available.png"></p>
<p><strong>Disclaimer:</strong> Public access is not recommended for production apps, but it&rsquo;s acceptable for this example to showcase how it works.</p>
<h2 id="database-ready">Database Ready</h2>
<p>Now that our database is ready, we&rsquo;ll use DBeaver to connect and add some dummy data.</p>
<p><img alt="Database Creation" loading="lazy" src="/posts/power-of-mcp-for-ai-tools/connection.png"></p>
<p>After connecting, we&rsquo;ll run the following query to create the table:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sql" data-lang="sql"><span style="display:flex;"><span><span style="color:#66d9ef">CREATE</span> <span style="color:#66d9ef">TABLE</span> users (
</span></span><span style="display:flex;"><span>    id SERIAL <span style="color:#66d9ef">PRIMARY</span> <span style="color:#66d9ef">KEY</span>,
</span></span><span style="display:flex;"><span>    name VARCHAR(<span style="color:#ae81ff">100</span>),
</span></span><span style="display:flex;"><span>    email VARCHAR(<span style="color:#ae81ff">100</span>) <span style="color:#66d9ef">UNIQUE</span>,
</span></span><span style="display:flex;"><span>    city VARCHAR(<span style="color:#ae81ff">100</span>),
</span></span><span style="display:flex;"><span>    address VARCHAR(<span style="color:#ae81ff">150</span>),
</span></span><span style="display:flex;"><span>    age INT,
</span></span><span style="display:flex;"><span>    is_active BOOLEAN,
</span></span><span style="display:flex;"><span>    created_at <span style="color:#66d9ef">TIMESTAMP</span> <span style="color:#66d9ef">DEFAULT</span> <span style="color:#66d9ef">CURRENT_TIMESTAMP</span>
</span></span><span style="display:flex;"><span>);
</span></span></code></pre></div><p>Next, let&rsquo;s insert some dummy data:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sql" data-lang="sql"><span style="display:flex;"><span><span style="color:#66d9ef">INSERT</span> <span style="color:#66d9ef">INTO</span> users (name, email)
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">VALUES</span> 
</span></span><span style="display:flex;"><span>  (<span style="color:#e6db74">&#39;Diana Prince&#39;</span>, <span style="color:#e6db74">&#39;diana.prince@example.com&#39;</span>),
</span></span><span style="display:flex;"><span>  (<span style="color:#e6db74">&#39;Ethan Hunt&#39;</span>, <span style="color:#e6db74">&#39;ethan.hunt@example.com&#39;</span>),
</span></span><span style="display:flex;"><span>  (<span style="color:#e6db74">&#39;Frodo Baggins&#39;</span>, <span style="color:#e6db74">&#39;frodo.baggins@example.com&#39;</span>),
</span></span><span style="display:flex;"><span>  (<span style="color:#e6db74">&#39;Grace Hopper&#39;</span>, <span style="color:#e6db74">&#39;grace.hopper@example.com&#39;</span>),
</span></span><span style="display:flex;"><span>  (<span style="color:#e6db74">&#39;Hank Moody&#39;</span>, <span style="color:#e6db74">&#39;hank.moody@example.com&#39;</span>),
</span></span><span style="display:flex;"><span>  (<span style="color:#e6db74">&#39;Isla Fisher&#39;</span>, <span style="color:#e6db74">&#39;isla.fisher@example.com&#39;</span>),
</span></span><span style="display:flex;"><span>  (<span style="color:#e6db74">&#39;Jack Sparrow&#39;</span>, <span style="color:#e6db74">&#39;jack.sparrow@example.com&#39;</span>),
</span></span><span style="display:flex;"><span>  (<span style="color:#e6db74">&#39;Katniss Everdeen&#39;</span>, <span style="color:#e6db74">&#39;katniss.e@example.com&#39;</span>),
</span></span><span style="display:flex;"><span>  (<span style="color:#e6db74">&#39;Luke Skywalker&#39;</span>, <span style="color:#e6db74">&#39;luke.skywalker@example.com&#39;</span>),
</span></span><span style="display:flex;"><span>  (<span style="color:#e6db74">&#39;Maria Hill&#39;</span>, <span style="color:#e6db74">&#39;maria.hill@example.com&#39;</span>),
</span></span><span style="display:flex;"><span>  (<span style="color:#e6db74">&#39;Neo Anderson&#39;</span>, <span style="color:#e6db74">&#39;neo.anderson@example.com&#39;</span>),
</span></span><span style="display:flex;"><span>  (<span style="color:#e6db74">&#39;Olivia Wilde&#39;</span>, <span style="color:#e6db74">&#39;olivia.wilde@example.com&#39;</span>),
</span></span><span style="display:flex;"><span>  (<span style="color:#e6db74">&#39;Peter Parker&#39;</span>, <span style="color:#e6db74">&#39;peter.parker@example.com&#39;</span>),
</span></span><span style="display:flex;"><span>  (<span style="color:#e6db74">&#39;Quentin Beck&#39;</span>, <span style="color:#e6db74">&#39;quentin.beck@example.com&#39;</span>),
</span></span><span style="display:flex;"><span>  (<span style="color:#e6db74">&#39;Rachel Green&#39;</span>, <span style="color:#e6db74">&#39;rachel.green@example.com&#39;</span>),
</span></span><span style="display:flex;"><span>  (<span style="color:#e6db74">&#39;Steve Rogers&#39;</span>, <span style="color:#e6db74">&#39;steve.rogers@example.com&#39;</span>),
</span></span><span style="display:flex;"><span>  (<span style="color:#e6db74">&#39;Tony Stark&#39;</span>, <span style="color:#e6db74">&#39;tony.stark@example.com&#39;</span>),
</span></span><span style="display:flex;"><span>  (<span style="color:#e6db74">&#39;Uma Thurman&#39;</span>, <span style="color:#e6db74">&#39;uma.thurman@example.com&#39;</span>),
</span></span><span style="display:flex;"><span>  (<span style="color:#e6db74">&#39;Viktor Reznov&#39;</span>, <span style="color:#e6db74">&#39;viktor.reznov@example.com&#39;</span>),
</span></span><span style="display:flex;"><span>  (<span style="color:#e6db74">&#39;Wanda Maximoff&#39;</span>, <span style="color:#e6db74">&#39;wanda.maximoff@example.com&#39;</span>);
</span></span></code></pre></div><p>Now let&rsquo;s check the database to see if all the data was saved correctly.</p>
<p><img alt="Table in DBeaver" loading="lazy" src="/posts/power-of-mcp-for-ai-tools/users_table.png"></p>
<p>Everything looks good. Now let&rsquo;s proceed with adding this database to Cursor AI via MCP. (I&rsquo;m using Cursor AI since I&rsquo;m currently experimenting with it, but the logic is similar for all AI tools that support MCP.)</p>
<h2 id="adding-postgres-via-mcp-to-cursor">Adding postgres via MCP to Cursor</h2>
<p>First, open Cursor IDE, go to Settings, and navigate to Tools and Integration.</p>
<p><img alt="Tools &amp; Integrations" loading="lazy" src="/posts/power-of-mcp-for-ai-tools/tools_integration.png"></p>
<p>Add a new MCP server and fill in all the details.</p>
<p><img alt="Postgres Connection" loading="lazy" src="/posts/power-of-mcp-for-ai-tools/postgres_connection.png"></p>
<p><strong>Note:</strong> For the connection, you can either provide a full connection string (including host, password, port, user, etc.) or specify a config object. Cursor supports both. For this example, I used a connection string.</p>
<p>Once saved, if all credentials are correct, Cursor will be able to access your database.</p>
<p>Let&rsquo;s retrieve the tables present</p>
<p><img alt="Connection Succesful" loading="lazy" src="/posts/power-of-mcp-for-ai-tools/init_query.png"></p>
<p>Now let&rsquo;s retrieve all users from users table
<img alt="Results" loading="lazy" src="/posts/power-of-mcp-for-ai-tools/results.png"></p>
<p>Next, let&rsquo;s showcase an example of filtering:
<img alt="Filtered" loading="lazy" src="/posts/power-of-mcp-for-ai-tools/filtered.png"></p>
<p><strong>Note:</strong> MCP Postgres connections only support read operations. The database is treated as a read-only model source.</p>
<h2 id="wrap-up">Wrap up</h2>
<p>As you can see, MCP is a really interesting concept that enables us to create new data sources for our AI agents. This technically allows both engineers and non engineers to use natural language to execute any possible query on a database without writing a single line of SQL.</p>
<p>I&rsquo;ve tested this on another project, and the Postgres MCP integration can even suggest improvements to your tables or queries, which can have a significant impact on large databases.</p>
<p>All in all, I expect that more and more tools will create their own versions of MCP servers that you can integrate into your favorite AI IDEs. You can even create your own MCP if you want!</p>
<p>That&rsquo;s all for now. Thank you for your attention!</p>
]]></content:encoded></item></channel></rss>