Posts

Model Context Protocol

  Model Context Protocol (MCP): A Beginner's Guide Introduction As Large Language Models (LLMs) such as ChatGPT, Claude, and Gemini become more capable, users expect them to interact with the outside world. They should be able to access databases, read files, query APIs, send emails, and work with enterprise applications. Without a standard way of connecting AI models to these external systems, every AI application would require custom integrations for every service. This is where the Model Context Protocol (MCP) comes in. MCP provides a standardized way for AI models to communicate with external tools and resources, making integrations simpler, reusable, and easier to maintain. What is MCP? Model Context Protocol (MCP) is an open protocol that enables AI models to communicate with external tools, APIs, databases, files, and other services through a standardized interface. Think of MCP as the USB-C of AI integrations . Just as USB-C provides a common way to connect many different...

Agent AI And MCP (Model Context Protocol)

  Building My First AI Agent Using MCP and Gemini – Understanding the Complete Flow When I first started learning AI Agents and the Model Context Protocol (MCP), I found plenty of tutorials that showed how to write the code, but very few explained why each piece exists and how everything works together . This article explains a simple AI Agent built using: Node.js Google Gemini Model Context Protocol (MCP) By the end, you'll understand: What an AI Agent actually is How MCP fits into the architecture Why the LLM doesn't need to see tool implementations How tool selection really works What We Are Building Our project contains only two files. app.js server.js Although the project is small, it demonstrates the same basic architecture used by many production AI agents. The flow looks like this: User │ ▼ app.js │ ┌───────────┴────────────┐ ▼ ▼ Gemini LLM ...

Thread , Runnable and ExecutorService

Image
  Previous approach to create a thread.  1.  Directly create an object of Thread Class after overriding the public void run() method of Thread class and call the start method to initiate the thread package com.executor; public class OldThread implements Runnable { private String task ; public OldThread() { super (); } public OldThread(String task ) { super (); this . task = task ; } @Override public void run(){ System. out .println( " Old thread runnable " + this . task ); try { Thread. sleep (2000); } catch (InterruptedException e ) { e .printStackTrace(); } System. out .println( this . task + " completed." ); } } 2. Implement the Runnable interface  and override the public void method and pass the reference of Runnable Object reference  into Thread(Runnable) constructor. call the start method to initiate the thread package com.executor; public cl...

ExecutorService with newFixedThreadPool example

The Executor Framework provides different types of executors. Some of them are .. SingleThreadExecutor FixedThreadPool(n) CachedThreadPool ScheduledExecutor Java ExecutorService is an interface in java. It allow in maintaining the thread pool and assign the tasks. Threads execute asynchronously. package com.threads.example; import java.util.ArrayList; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; /** this is just name of the class. we are using the Callable interface for creating the task */ public class CallableExample { public static void main(String[] args ) throws InterruptedException, ExecutionException { /** Getting the number of cpu core and creating the thread pool according to cpu count */ int c = Runtime. getRuntime ().availableProcessors(); ExecutorSe...

Java Record : new way to create a class

Records were introduced in Java 14. They were added as a preview feature in Java 14 and became a standard feature starting from Java 16.  In Java 14, records were available as a preview feature, which means they were not considered final and could undergo changes based on developer feedback. However, the concept and basic functionality of records remained the same when they became a standard feature in Java 16. Record is class like construct. public record Person (String name, int age) { // You can also add custom methods here if needed } In the example above, we've defined a Person record with two components: name and age . The record keyword automatically generates the following for you: A constructor that takes arguments for all the components. Getter methods for each component (e.g., getName() and getAge() ). equals() , hashCode() , and toString() methods, which are based on the record's components. In Java, a record is a new feature in...