Get to Know MCP

The Model Context Protocol (MCP) is released by Anthrophic is becoming the de facto for combining AI models to everything that it cannot directly access. So let me break it to you with the most simplest ways based on my understandings. What is the problem? As you may already know, an AI model struggles when they need to access any information or tools out of their pre-trained datasets. So developers have to write custom code for each API, tool or data source to give them that fine grained access. This made AI bridging to any custom tool or data source a bitter task to any dev. Anthrophic's solution Anthropic stepped in and introduced MCP aka the Model Context Protocol. It's a tool, resource and model agnostic protocol to establish connections between AI Models and any other tool or resource. They introduced this as an open standard which uses JSON-RPC 2.0 which is already used by many standard protocols like Language Server Protocol (LSP) and Etherium network. The most simplest explanation Think of it as a REST API for an AI to call and access information and tools it needs. Though they use completely different invoke and expose methods. Abstracted architecture of an MCP An Example Imagine you have your favorite spreadsheet application that you use regularly. You'd love to be able to tell an AI chatbot things like "create a budget spreadsheet" or "calculate the average of my quarterly sales" and have it actually do these tasks in your spreadsheet application. Here's how you could make this happen: Let's assume that this spreadsheet application has an API to control it's actions like insert data into cells, insert formulae and etc. Next, you can write a simple script using a programming language that sends commands to it's API. Now we need to connect our script to the AI, so it can send commands for the API for us. Instead of us writing a formula and sending, AI can read the spreadsheet, create a formula and write it to the spreadsheet. This is where MCP comes in!. We just need wrap our scripts into a the MCP supported function. That is called an MCP server. That has become fairly easy now due to the already available libraries for many programming languages. This is how you write an MCP server using official python SDK: from mcp.server.fastmcp import FastMCP # Create an MCP server mcp = FastMCP("my-spreadsheet-mcp-server") # Add a tool @mcp.tool() def writeToSpreadSheet(userString : str) -> str: """ Your logic or the script that access the spreatsheet API """ return "you can return what happened back to AI" # Add a resource @mcp.resource("://{name}") def accessSpreadSheets(name: str) -> str: """ Your logic or the script that access the spreatsheet API """ return "you can return what happened back to AI" here tools decorator tells the AI model that function access tool (like the spreadsheet program) and resource tells that it access a data source (like an actual spreadsheet file directly). After writing your mcp server. You can load it to an MCP client ( like claude desktop) to let an LLM access your MCP and do what you asks using the new capabilities of your MCP server. Using this method, you can give access to any data source, database, REST/RPC APIs or any other software to your choice of AI model. Wait, don't go and write another MCP server now!! There might be already an MCP server for your task that someone has written, so give it a try first. Here's list of MCP servers people have written as of now, https://github.com/punkpeye/awesome-mcp-servers References MCP official introduction by Anthropic - https://www.anthropic.com/news/model-context-protocol Python SDK for MCP -https://github.com/modelcontextprotocol/python-sdk JSON-RPC 2.0 spec - https://www.jsonrpc.org/specification

Apr 16, 2025 - 11:38
 0
Get to Know MCP

The Model Context Protocol (MCP) is released by Anthrophic is becoming the de facto for combining AI models to everything that it cannot directly access.

So let me break it to you with the most simplest ways based on my understandings.

What is the problem?

As you may already know, an AI model struggles when they need to access any information or tools out of their pre-trained datasets. So developers have to write custom code for each API, tool or data source to give them that fine grained access. This made AI bridging to any custom tool or data source a bitter task to any dev.

Anthrophic's solution

Anthropic stepped in and introduced MCP aka the Model Context Protocol. It's a tool, resource and model agnostic protocol to establish connections between AI Models and any other tool or resource.

They introduced this as an open standard which uses JSON-RPC 2.0 which is already used by many standard protocols like Language Server Protocol (LSP) and Etherium network.

The most simplest explanation

Think of it as a REST API for an AI to call and access information and tools it needs. Though they use completely different invoke and expose methods.

Abstracted architecture of an MCP



Model Context Protocol abstracted architecture

An Example

Imagine you have your favorite spreadsheet application that you use regularly. You'd love to be able to tell an AI chatbot things like "create a budget spreadsheet" or "calculate the average of my quarterly sales" and have it actually do these tasks in your spreadsheet application.

Here's how you could make this happen:
Let's assume that this spreadsheet application has an API to control it's actions like insert data into cells, insert formulae and etc.
Next, you can write a simple script using a programming language that sends commands to it's API.

Now we need to connect our script to the AI, so it can send commands for the API for us. Instead of us writing a formula and sending, AI can read the spreadsheet, create a formula and write it to the spreadsheet.

This is where MCP comes in!. We just need wrap our scripts into a the MCP supported function. That is called an MCP server.

That has become fairly easy now due to the already available libraries for many programming languages.

This is how you write an MCP server using official python SDK:

from mcp.server.fastmcp import FastMCP

# Create an MCP server
mcp = FastMCP("my-spreadsheet-mcp-server")


# Add a tool
@mcp.tool()
def writeToSpreadSheet(userString : str) -> str:
    """
    Your logic or the script that 
    access the spreatsheet API
    """
    return "you can return what happened back to AI"


# Add a resource
@mcp.resource("://{name}")
def accessSpreadSheets(name: str) -> str:
    """
    Your logic or the script that 
    access the spreatsheet API
    """
    return "you can return what happened back to AI"

here tools decorator tells the AI model that function access tool (like the spreadsheet program) and resource tells that it access a data source (like an actual spreadsheet file directly).

After writing your mcp server. You can load it to an MCP client ( like claude desktop) to let an LLM access your MCP and do what you asks using the new capabilities of your MCP server.

Using this method, you can give access to any data source, database, REST/RPC APIs or any other software to your choice of AI model.

Wait, don't go and write another MCP server now!!

There might be already an MCP server for your task that someone has written, so give it a try first.

Here's list of MCP servers people have written as of now,

https://github.com/punkpeye/awesome-mcp-servers

References