<?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 Gaurav Rajpurohit on Medium]]></title>
        <description><![CDATA[Stories by Gaurav Rajpurohit on Medium]]></description>
        <link>https://medium.com/@gaurav.rajpurohit1997?source=rss-330e540681a5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Gaurav Rajpurohit on Medium</title>
            <link>https://medium.com/@gaurav.rajpurohit1997?source=rss-330e540681a5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 12:20:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gaurav.rajpurohit1997/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[MCP Servers Explained: What it is & Why it matter]]></title>
            <link>https://medium.com/@gaurav.rajpurohit1997/mcp-servers-explained-what-it-is-why-it-matter-e836d8df2a21?source=rss-330e540681a5------2</link>
            <guid isPermaLink="false">https://medium.com/p/e836d8df2a21</guid>
            <category><![CDATA[mcp-protocol]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[mcps]]></category>
            <category><![CDATA[mcp-client]]></category>
            <dc:creator><![CDATA[Gaurav Rajpurohit]]></dc:creator>
            <pubDate>Mon, 28 Sep 2026 07:41:16 GMT</pubDate>
            <atom:updated>2026-09-28T07:41:16.847Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xPiVtMsre1o3pDbu.png" /></figure><p>A while ago, connecting an AI assistant to another system usually meant building a custom integration. Want the AI to read data from Postgres? Build a Postgres integration. Want it to create Jira tickets? Build another integration. Want to move the same setup from one AI tool to another? In many cases, you had to do the work again. That is one of the problems the <strong>Model Context Protocol (MCP)</strong> is trying to solve.</p><p>Instead of every AI application having its own way of connecting to databases, APIs, files, and other services, MCP provides a common way for these systems to communicate.</p><p>We’ll start with the basics, look at how the different pieces fit together, and then get into what you actually need to build one.</p><h3><strong>So, what exactly is an MCP server?</strong></h3><p>The simplest way to think about MCP is as a standard interface between an AI application and external systems. The official MCP documentation often compares it to <strong>USB-C</strong>. USB-C gives different devices a common way to connect. You don’t need to invent a completely different connector every time you plug a new device into your laptop. MCP is trying to provide something similar for AI applications.</p><p>An AI application can use MCP to connect to things like:</p><ul><li>Databases</li><li>APIs</li><li>Files</li><li>Internal tools</li><li>Business systems</li><li>Development environments</li><li>Other external services</li></ul><p>An <strong>MCP server</strong> is the piece of software that exposes these capabilities to the AI application.</p><p>And there is an important point here:</p><blockquote><em>An MCP server is not an AI model.</em></blockquote><p>It doesn’t think. It doesn’t decide what the user wants. It doesn’t generate answers. It’s basically an adapter between the AI application and some external system.</p><p>For example, imagine you have an internal database containing customer information. Without MCP, you might build a custom integration specifically for one AI application. With MCP, you can create an MCP server that exposes the database in a standard way. An MCP-compatible application can then connect to that server and use the capabilities you’ve exposed.</p><h3>What can an MCP server expose?</h3><p>MCP servers generally expose three types of things:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5zMmd1qImgkXqzSh.png" /></figure><h3>1. Tools</h3><p>Tools are functions that the AI can call.</p><p>For example:</p><pre>create_ticket<br>run_query<br>send_email<br>get_customer<br>search_documents</pre><p>A tool usually performs some action.</p><p>For example, if the AI calls:</p><pre>create_ticket</pre><p>the MCP server might create an actual ticket in your issue-tracking system. Because tools can cause real changes, you need to think carefully about permissions and security.</p><h3>2. Resources</h3><p>Resources are different.</p><p>They represent data that can be read and provided to the application as context.</p><p>For example:</p><pre>A configuration file<br>A document<br>A database record<br>A log file<br>A schema</pre><p>The important thing is that resources are generally about <strong>reading information</strong>, rather than asking the model to perform an action.</p><h3>3. Prompts</h3><p>MCP can also expose reusable prompt templates.</p><p>For example, you might have a prompt called:</p><pre>review-code</pre><p>or:</p><pre>summarize-customer-history</pre><p>The user can intentionally select these prompts from the application.</p><h3>Host, Client, and Server</h3><p>This is probably the part of MCP that causes the most confusion at first.</p><p>You will hear three terms quite often:</p><p><strong>Host. Client. Server.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*AiTQdVyvNm493Zt8DapQog.png" /></figure><p>Let’s take them one at a time.</p><h3>The Host</h3><p>The <strong>host</strong> is the application the user is actually interacting with.</p><p>For example, it could be:</p><ul><li>Claude Code</li><li>Cursor</li><li>VS Code</li><li>ChatGPT</li><li>Your own AI application</li></ul><p>The host is responsible for the overall AI experience. It manages things such as the conversation, the user interface, and important security decisions.</p><p>Think of the host as the main application where everything is happening.</p><h3>The Client</h3><p>The <strong>client</strong> sits inside the host.</p><p>Its job is to communicate with an MCP server.</p><p>A client maintains a connection to a particular MCP server and handles the MCP protocol on behalf of the host.</p><p>Something like this:</p><pre>HOST APPLICATION<br>       ┌───────────────────────────┐<br>       │                           │<br>       │       Language Model      │<br>       │             │             │<br>       │             ▼             │<br>       │       ┌───────────┐       │<br>       │       │ MCP Client│       │<br>       │       └─────┬─────┘       │<br>       │             │             │<br>       └─────────────┼─────────────┘<br>                     │<br>                     │ MCP<br>                     ▼<br>              ┌──────────────┐<br>              │  MCP Server  │<br>              │              │<br>              │ Your tools   │<br>              └──────┬───────┘<br>                     │<br>                     ▼<br>              ┌──────────────┐<br>              │ Your systems │<br>              │ DB / API /   │<br>              │ Files        │<br>              └──────────────┘</pre><p>The model decides that it wants to use a particular capability.</p><p>The host handles the overall interaction.</p><p>The MCP client communicates with the MCP server.</p><p>And the MCP server talks to the actual system that needs to do the work.</p><h3>The MCP Server</h3><p>The server is the process that exposes your tools, resources, and prompts.</p><p>For example, suppose you’re building an MCP server for a company’s internal database.</p><p>Your server might expose tools such as:</p><pre>get_customer<br>search_orders<br>get_order_details</pre><p>When one of those tools is called, your MCP server performs the actual operation against the database.</p><p>The model doesn’t directly connect to your database.</p><p>Instead, the flow looks roughly like this:</p><pre>User<br>  │<br>  ▼<br>AI Application<br>  │<br>  ▼<br>Language Model<br>  │<br>  │ chooses a tool<br>  ▼<br>MCP Client<br>  │<br>  │ MCP request<br>  ▼<br>MCP Server<br>  │<br>  │<br>  ▼<br>Database / API / Files</pre><p>The response then travels back through the same chain.</p><p>This separation is useful because the AI application doesn’t need to know all the implementation details of your backend.</p><p>It only needs to understand what capabilities the MCP server provides and how to call them.</p><h3>A simple way to remember it</h3><p>If all of the terminology starts getting confusing, remember this:</p><pre>HOST<br>The application which user interacts  </pre><pre>        ↓</pre><pre>CLIENT<br>The connector inside the host</pre><pre>        ↓</pre><pre>MCP SERVER<br>Exposes tools, resources, and prompts</pre><pre>        ↓</pre><pre>YOUR SYSTEMS<br>Database, API, files, services, etc.</pre><h3>The Big 2026 Change: MCP Goes Stateless</h3><p>One of the biggest MCP changes in 2026 was the move toward a <strong>stateless request/response model</strong>.</p><p>The newer design makes requests more self-contained, including information such as protocol version, client identity, and capabilities. This makes it easier to run MCP servers behind regular load balancers.</p><p>New mechanisms such as <strong>server/discover</strong> help with capability discovery, while headers like <strong>Mcp-Method</strong> and <strong>Mcp-Name</strong> can help with routing and authorization.</p><p>The key idea is that <strong>the protocol can be stateless while the application can still maintain state</strong>. When state is needed, it can be represented explicitly — for example, by creating a handle and passing it between tool calls.</p><p><strong>How a tool call actually flows</strong></p><h3>How a tool call actually flows</h3><pre>1. User asks: &quot;What&#39;s broken in production?&quot;<br>                       │<br>                       ▼<br>2. Client fetches tools/list from each connected server<br>   (cacheable now, thanks to ttlMs)<br>                       │<br>                       ▼<br>3. Model reads the tool descriptions and picks one:<br>   name = &quot;search_errors&quot;<br>   args = { &quot;since&quot;: &quot;24h&quot; }<br>                       │<br>                       ▼<br>4. Client sends tools/call over JSON-RPC<br>   Headers:<br>   Mcp-Method: tools/call<br>   Mcp-Name: search_errors<br>                       │<br>                       ▼<br>5. Server executes against the real system,<br>   returns content<br>                       │<br>                       ▼<br>6. Result goes back into the model&#39;s context;<br>   the model writes the answer<br>   (or calls another tool)</pre><h3>How to use an existing MCP server</h3><p>Most hosts use a JSON config block. For a local stdio server:</p><pre>{<br>  &quot;mcpServers&quot;: {<br>    &quot;filesystem&quot;: {<br>      &quot;command&quot;: &quot;npx&quot;,<br>      &quot;args&quot;: [<br>        &quot;-y&quot;,<br>        &quot;@modelcontextprotocol/server-filesystem&quot;,<br>        &quot;/Users/you/projects&quot;<br>      ]<br>    }<br>  }<br>}</pre><p>For a remote HTTP server, you point at a URL instead and authenticate via OAuth, typically through the host&#39;s UI rather than a config file.</p><p>Restart the host, and the tools appear. Check the host&#39;s tool list to confirm the connection is live.</p><h3>Three things to do before connecting anything:</h3><ol><li><strong>Scope credentials tightly.</strong> A read-only token for a read-only server.</li><li><strong>Read the source for community servers.</strong> It runs with your access.</li><li><strong>Require human approval for writes.</strong> Most hosts support this. Turn it on.</li></ol><h3>Building a custom MCP server</h3><p><strong>Python</strong><br>Install with uv add &quot;mcp[cli]&quot; or pip install &quot;mcp[cli]&quot;. The cli extra adds the mcp command-line tool on top of the SDK. Note that v2 is the current stable line, and since pip install mcp now installs 2.x, keep a &lt;2 upper bound on your requirement until you&#39;ve migrated if you&#39;re on v1.<br>A complete server:</p><pre>from mcp.server import MCPServer<br><br>mcp = MCPServer(&quot;Demo&quot;)<br><br>@mcp.tool()<br>def add(a: int, b: int) -&gt; int:<br>    &quot;&quot;&quot;Add two numbers.&quot;&quot;&quot;<br>    return a + b<br><br>@mcp.resource(&quot;greeting://{name}&quot;)<br>def greeting(name: str) -&gt; str:<br>    &quot;&quot;&quot;Greet someone by name.&quot;&quot;&quot;<br>    return f&quot;Hello, {name}!&quot;</pre><p>That’s it. One tool, one templated resource. what we did not write: no JSON Schema (the type hints a: int, b: int are the schema), no request parsing, no validation code, no protocol handling.<br>Test it in the MCP Inspector:</p><pre>uv run mcp dev server.py</pre><p>Something more realistic</p><p>Toy examples teach syntax but hide the design problems. Here’s a support-ticket server closer to production shape:</p><pre>import httpx<br>from pydantic import Field<br>from typing import Annotated<br>from mcp.server import MCPServer<br><br>mcp = MCPServer(&quot;support-desk&quot;)<br>API = &quot;https://api.internal.example.com/v1&quot;<br><br>@mcp.tool(annotations={&quot;readOnlyHint&quot;: True})<br>async def search_tickets(<br>    query: Annotated[str, Field(description=&quot;Free-text search over subject and body&quot;)],<br>    status: Annotated[str, Field(description=&quot;open, pending, or closed&quot;)] = &quot;open&quot;,<br>    limit: Annotated[int, Field(description=&quot;Max results, 1-50&quot;, ge=1, le=50)] = 10,<br>) -&gt; str:<br>    &quot;&quot;&quot;Search support tickets. Use this before creating a ticket to avoid duplicates.&quot;&quot;&quot;<br>    async with httpx.AsyncClient() as http:<br>        r = await http.get(f&quot;{API}/tickets&quot;,<br>                           params={&quot;q&quot;: query, &quot;status&quot;: status, &quot;limit&quot;: limit})<br>        r.raise_for_status()<br>        tickets = r.json()[&quot;results&quot;]<br>    if not tickets:<br>        return f&quot;No {status} tickets matching &#39;{query}&#39;.&quot;<br>    return &quot;\n&quot;.join(<br>        f&quot;#{t[&#39;id&#39;]} [{t[&#39;priority&#39;]}] {t[&#39;subject&#39;]} - {t[&#39;assignee&#39;] or &#39;unassigned&#39;}&quot;<br>        for t in tickets<br>    )<br><br>@mcp.tool()<br>async def create_ticket(<br>    subject: Annotated[str, Field(description=&quot;One-line summary, under 80 chars&quot;)],<br>    body: Annotated[str, Field(description=&quot;Full description including repro steps&quot;)],<br>    priority: Annotated[str, Field(description=&quot;low, normal, high, or urgent&quot;)] = &quot;normal&quot;,<br>) -&gt; str:<br>    &quot;&quot;&quot;Create a support ticket. Always search first to check for duplicates.&quot;&quot;&quot;<br>    async with httpx.AsyncClient() as http:<br>        r = await http.post(f&quot;{API}/tickets&quot;,<br>                            json={&quot;subject&quot;: subject, &quot;body&quot;: body, &quot;priority&quot;: priority})<br>        r.raise_for_status()<br>        return f&quot;Created ticket #{r.json()[&#39;id&#39;]}&quot;</pre><p>Four things this demonstrates that the toy example doesn’t:<br><strong>Descriptions are your API design.</strong> &quot;Use this before creating a ticket to avoid duplicates&quot; is an instruction to the model, embedded in the schema. It works.<br><strong>Field(description=...) on every parameter.</strong> Registries like Glama and Smithery rank servers by Tool Description Quality Score, and the worst-scoring tool drags down the whole score, so every tool needs a clear description and parameters need Field(description=...).<br><strong>readOnlyHint on non-mutating tools.</strong> Use annotations={&quot;readOnlyHint&quot;: True} for tools that don&#39;t mutate anything, so hosts can auto-approve them and reserve confirmation dialogs for writes.<br><strong>Return text the model can reason over.</strong> A formatted list beats raw JSON. The model reads the output as prose.</p><h4>Building an MCP client</h4><p><strong>The same SDK builds clients. Serve your Python server over HTTP:</strong></p><pre>uv run mcp run server.py --transport streamable-http</pre><p>Then connect:</p><pre>import asyncio<br>from mcp import Client<br><br>async def main() -&gt; None:<br>    async with Client(&quot;http://localhost:8000/mcp&quot;) as client:<br>        result = await client.call_tool(&quot;add&quot;, {&quot;a&quot;: 1, &quot;b&quot;: 2})<br>        print(result.structured_content)  # {&#39;result&#39;: 3}<br>asyncio.run(main())</pre><p>A URL means Streamable HTTP, the transport you deploy. Client can also launch a local server as a stdio subprocess or take any custom transport.<br>You&#39;d write a client when you&#39;re building your own AI application rather than using an existing host. The loop is: connect, list tools, pass the tool schemas to your model, call whatever the model picks, feed the result back, repeat until the model stops asking for tools.</p><h3>Advantages</h3><p>MCP makes it easier to connect AI models with external tools and services through a common protocol. You can <strong>build a server once and use it with different MCP-compatible hosts</strong>, without rewriting the integration for every vendor.</p><p>It also keeps responsibilities separate: the MCP server handles your business logic, while the host handles the AI model. Tools are <strong>self-describing</strong>, so the model can discover available tools and their inputs at runtime.</p><p>MCP is also <strong>language agnostic</strong>, supporting languages such as TypeScript, Python, Go, and C#. It can work locally as well, which is useful when data needs to stay on the user’s machine.</p><h3>Disadvantages</h3><p>MCP comes with a few challenges. Every tool definition consumes part of the model’s context, so exposing too many tools can increase <strong>token usage and context-window costs</strong>.</p><p>MCP systems are also less predictable than traditional software because the <strong>model decides which tool to call and when</strong>.</p><p>Security is another major concern. An MCP server with access to production systems can become an attack surface, especially when prompt injection can influence tool usage. <strong>Least-privilege access is essential.</strong></p><p>The specification is also evolving quickly, so older tutorials may not always match the latest version. Debugging can be more complicated because problems can occur across the model, client, transport, server, or tool.</p><p>Sources</p><ul><li>MCP specification 2026–07–28 — <a href="https://modelcontextprotocol.io/specification/2026-07-28">https://modelcontextprotocol.io/specification/2026-07-28</a></li><li>“The 2026–07–28 Specification” — <a href="https://blog.modelcontextprotocol.io/posts/2026-07-28/">https://blog.modelcontextprotocol.io/posts/2026-07-28/</a></li><li>MCP roadmap — <a href="https://blog.modelcontextprotocol.io/posts/mcp-roadmap/">https://blog.modelcontextprotocol.io/posts/mcp-roadmap/</a></li><li>Python SDK — <a href="https://github.com/modelcontextprotocol/python-sdk">https://github.com/modelcontextprotocol/python-sdk</a></li><li>TypeScript SDK — <a href="https://github.com/modelcontextprotocol/typescript-sdk">https://github.com/modelcontextprotocol/typescript-sdk</a></li><li>Getting started docs — <a href="https://modelcontextprotocol.io/docs/2026-07-28/getting-started/intro">https://modelcontextprotocol.io/docs/2026-07-28/getting-started/intro</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e836d8df2a21" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to MongoDB: The NoSQL Powerhouse]]></title>
            <link>https://medium.com/@gaurav.rajpurohit1997/introduction-to-mongodb-the-nosql-powerhouse-e3819841bdd5?source=rss-330e540681a5------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3819841bdd5</guid>
            <dc:creator><![CDATA[Gaurav Rajpurohit]]></dc:creator>
            <pubDate>Tue, 02 Sep 2025 12:11:10 GMT</pubDate>
            <atom:updated>2025-09-02T13:53:10.302Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iWsHU_6Lw7Ss3zTt95gQZg.png" /></figure><p>In the era of big data and fast-paced application development, choosing the right database is crucial. <strong>MongoDB</strong>, a leading NoSQL database, has become the go-to choice for developers building scalable and flexible applications. In this blog, we’ll dive into what MongoDB is, why it’s popular, its core features, and how you can get started.</p><h3>What is MongoDB?</h3><p><strong>MongoDB</strong> is an <strong>open-source, document-oriented NoSQL database</strong> designed for high performance, high availability, and easy scalability. Unlike traditional relational databases that store data in tables and rows, MongoDB uses <strong>JSON-like documents</strong> (called BSON) with <strong>dynamic schemas</strong>, making data integration in modern applications seamless and fast.</p><h3>Why Choose MongoDB?</h3><p>Here’s why MongoDB stands out in the database ecosystem:</p><h3>1. Flexible Schema</h3><p>MongoDB doesn’t require a predefined schema. You can store documents with different structures in the same collection, which is ideal for agile development and rapid iterations.</p><h3>2. Scalability</h3><p>MongoDB supports <strong>horizontal scaling</strong> through <strong>sharding</strong>, allowing you to distribute data across multiple servers to handle large volumes efficiently.</p><h3>3. High Performance</h3><p>With in-memory computing, indexing, and aggregation framework, MongoDB provides excellent read and write performance for real-time applications.</p><h3>4. Powerful Query Language</h3><p>It supports a rich query language, including <strong>filtering, sorting, aggregation, and full-text search</strong>, making it a robust choice for complex data querying.</p><h3>5. Cloud Integration (MongoDB Atlas)</h3><p>MongoDB offers <strong>MongoDB Atlas</strong>, a fully-managed cloud database service, allowing developers to deploy, manage, and scale MongoDB clusters easily across AWS, Azure, or GCP.</p><h3>MongoDB Terms</h3><ul><li><strong>Databases:</strong> A database stores one or more collections of documents.​</li><li><strong>Collections:</strong> MongoDB stores documents in collections. Collections are analogous to tables in relational databases.​</li><li><strong>Documents:</strong> MongoDB stores data records as BSON documents &amp; similar to JSON objects. It is analogous to row in relational databases. These are composed of field-and-value pairs and have the following structure:​<br><em>{​ <br> field1: value1,​<br> field2: value2,​<br> ….​<br> fieldN: valueN​<br>}​</em></li><li><strong>Fields Names:</strong> These are strings analogous to column in relational databases.​</li></ul><h3>Real-World Use Cases</h3><ul><li><strong>E-commerce</strong> platforms for product catalogs and user profiles.</li><li><strong>Social media</strong> apps for storing user posts, comments, and metadata.</li><li><strong>Content management systems (CMS)</strong>.</li><li><strong>IoT</strong> and <strong>log data</strong> storage.</li><li><strong>Real-time analytics</strong> dashboards.</li></ul><h3>Getting Started with MongoDB</h3><p>Here’s a simple example to help you get started:</p><h3>Install MongoDB:</h3><ul><li>Use brew install mongodb-community@6.0 (Mac)</li><li>Or install via <a href="https://www.mongodb.com/try/download/community?utm_source=chatgpt.com">MongoDB’s official website</a></li></ul><h3>Basic Operations (Using Mongo Shell or Compass):</h3><pre>// Create or switch to a database<br>use myDatabase;<br>// Insert a document<br>db.users.insertOne({ name: &quot;Alice&quot;, age: 25, location: &quot;New York&quot; });<br>// Find documents<br>db.users.find({ age: { $gt: 20 } });<br>// Update a document<br>db.users.updateOne({ name: &quot;Alice&quot; }, { $set: { age: 26 } });<br>// Delete a document<br>db.users.deleteOne({ name: &quot;Alice&quot; });</pre><h3>MongoDB Tools:</h3><ul><li><strong>MongoDB Compass​:</strong> It is a powerful GUI for querying, aggregating, and analyzing your MongoDB data in a visual environment. It is free to use and can be run on macOS, Windows, and Linux.​</li><li><strong>MongoDB Atlas:</strong> It is a multi-cloud database service by the same people that build MongoDB. It makes easy to deploy and manage databases on-demand when and where you need them.</li></ul><h3>Integrating MongoDB with Node.js (Express)</h3><p>Now, let’s explore the MongoDB configuration with <strong>Node.js</strong> using <strong>Express</strong> and <strong>Mongoose.</strong></p><p><strong>Step 1: Set Up Your Node.js Project</strong></p><pre>mkdir mongo-node-demo<br>cd mongo-node-demo<br>npm init -y</pre><p><strong>Step 2: Install Dependencies</strong></p><pre>npm install express mongoose body-parser</pre><p><strong>Step 3: Create </strong><strong>index.js</strong></p><pre>const express = require(&#39;express&#39;);<br>const mongoose = require(&#39;mongoose&#39;);<br>const bodyParser = require(&#39;body-parser&#39;);<br>const app = express();<br>app.use(bodyParser.json());<br>// Connect to MongoDB<br>mongoose.connect(&#39;mongodb://localhost:27017/library&#39;, {<br> useNewUrlParser: true,<br> useUnifiedTopology: true,<br>}).then(() =&gt; console.log(&#39;MongoDB connected&#39;))<br> .catch(err =&gt; console.error(&#39;MongoDB error:&#39;, err));<br>// Define a Book model<br>const Book = mongoose.model(&#39;Book&#39;, {<br> title: String,<br> author: String<br>});<br>// Create a book<br>app.post(&#39;/books&#39;, async (req, res) =&gt; {<br> const book = new Book(req.body);<br> await book.save();<br> res.send(book);<br>});<br>// Get all books<br>app.get(&#39;/books&#39;, async (req, res) =&gt; {<br> const books = await Book.find();<br> res.send(books);<br>});<br>// Get a single book<br>app.get(&#39;/books/:id&#39;, async (req, res) =&gt; {<br> const book = await Book.findById(req.params.id);<br> res.send(book);<br>});<br>// Update a book<br>app.put(&#39;/books/:id&#39;, async (req, res) =&gt; {<br> const book = await Book.findByIdAndUpdate(req.params.id, req.body, { new: true });<br> res.send(book);<br>});<br>// Delete a book<br>app.delete(&#39;/books/:id&#39;, async (req, res) =&gt; {<br> await Book.findByIdAndDelete(req.params.id);<br> res.send({ message: &#39;Book deleted&#39; });<br>});<br>app.listen(3000, () =&gt; console.log(&#39;Server running on port 3000&#39;));</pre><p><strong>Step 4: Test your API</strong></p><p>Start the server:</p><pre>node index.js</pre><p>Use Postman or curl to test endpoints like:</p><ul><li>POST /books</li><li>GET /books</li><li>GET /books/:id</li><li>PUT /books/:id</li><li>DELETE /books/:id</li></ul><p>MongoDB offers seamless integration across different tech stacks, making it ideal for both enterprise and startup ecosystems. In this blog, we’ve seen how easy it is to configure MongoDB with <strong>Node.js</strong> using Mongoose.</p><p>Depending on your project needs and team expertise, you can choose the stack that fits best. With MongoDB in your toolkit, you’re set to build flexible, scalable, and high-performance applications.</p><h3>New features in MongoDB 8.0</h3><p>Let’s dive into the most impactful improvements that developers and organizations should know.</p><h3>1. Performance &amp; Observability Upgrades</h3><ul><li><strong>Smarter Profiling with workingMillis</strong><br> Version 8.0 upgrades the database profiler to log slow operations based on the time MongoDB actually spends processing them, filtering out idle time like queuing or waiting. This enables far more accurate tracking of slow-running queries. The profiler now logs a new metric—queues.execution.totalTimeQueuedMicros—to help distinguish processing delays from scheduling delays.</li></ul><h3>2. Aggregation Enhancements</h3><ul><li><strong>Binary Data Conversion</strong><br> A new $convert aggregation operator allows seamless conversion between strings and binary data (binData), along with a helper expression $toUUID for easier UUID transformations.</li><li><strong>Rank Behavior Aligned</strong><br> Changes in how null or missing fields are handled in $rank and $denseRank ensure consistency with the $sort operator—making rankings more intuitive and reliable.</li></ul><h3>3. Enhanced Security</h3><ul><li><strong>Queryable Encryption Supports Range Queries</strong><br> The newest release allows range queries ($lt, $gt, $lte, $gte) on encrypted fields—an impressive leap forward for secure data access without sacrificing flexibility.</li><li><strong>Standardized Audit Logs (OCSF Format)</strong><br> Audit log entries now support the OCSF schema — a standardized format for cybersecurity data — enabling seamless integration with monitoring and SIEM tools.</li></ul><h3>4. Operational Control &amp; Scalability</h3><ul><li><strong>Ingress Admission Control via Queuing</strong><br> A new ingress queue allows administrators to limit the number of incoming operations waiting to enter the database. You can now define thresholds for queued operations to prevent overload and better manage traffic flow.</li><li><strong>Advanced Bulk Writes Across Collections</strong><br> MongoDB 8.0 improves the bulkWrite API, enabling batch insert, update, and delete operations across multiple collections within a single command—providing greater efficiency for multi-collection tasks.</li></ul><h3>Tips for Using MongoDB Effectively</h3><ul><li><strong>Use indexes</strong> to speed up query performance.</li><li><strong>Embed documents</strong> for related data that’s frequently accessed together.</li><li><strong>Reference documents</strong> when data grows large and requires normalization.</li><li>Monitor performance using <strong>MongoDB Atlas</strong> dashboards or <strong>MongoDB Compass</strong>.</li></ul><h3>Conclusion</h3><p>MongoDB offers a fresh approach to data management with its document-oriented model and developer-friendly features. Whether you’re building a small startup app or a large-scale enterprise system, MongoDB provides the flexibility, scalability, and performance needed to thrive in today’s data-driven world.</p><p>Start with <a href="https://www.mongodb.com/cloud/atlas?utm_source=chatgpt.com">MongoDB Atlas</a> for a quick cloud setup, or install it locally to begin your NoSQL journey.</p><h3>Recommended Resources</h3><ul><li><a href="https://www.mongodb.com/docs/?utm_source=chatgpt.com">MongoDB Official Docs</a></li><li><a href="https://www.mongodb.com/cloud/atlas?utm_source=chatgpt.com">MongoDB Atlas Cloud</a></li><li><a href="https://www.mongodb.com/products/compass?utm_source=chatgpt.com">MongoDB Compass GUI</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3819841bdd5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>