Skip to main content
MCP

[Hands-on] Building an MCP Server

(100% locally)

Avi Chawla
Avi Chawla
👉

TODAY'S ISSUE

TODAY’S DAILY DOSE OF DATA SCIENCE

[Hands-on] Building an MCP Server (100% locally)

Lately, there has been a lot of buzz around MCPs. We also covered it in a recent newsletter issue.

So today, let’s dive into the implementation.

Here's what we'll be doing:

Let's dive in!

But first, let's understand MCP using a translation analogy.

MCP analogy

Imagine you only know English.

To get info from a person who only knows:

  • French, you must learn French.
  • German, you must learn German.
  • And so on.

Learning even 5 languages will be a nightmare for you!

But what if you add a translator that understands all languages?

  • You talk to the translator.
  • It infers the info you want.
  • It picks the person to talk to.
  • It gets you a response.

The translator is like an MCP!

It lets you (Agents) talk to other people (tools) through a single interface.

In the context of Agents, integrating a tool/API demands reading docs, writing code—similar to learning a language.

To simplify this, platforms now offer MCP servers. Devs can plug them, and Agents can use their tools/APIs instantly.

Here's how Agents use it:

  • Agent realizes it needs more info.
  • It contacts the MCP server, which returns the relevant tool + expected input.
  • Agent prepares the function call.
  • MCP server runs it and returns the output.
  • Agent uses the output.

MCP server

​Local implementation

Next, let’s build an MCP server!

Launch an MCP server

First, we define an MCP server with the host URL and port.

Define tool

A tool exposed through an MCP server has two requirements:

  • It must be decorated with the "tool" decorator.
  • It must have a clear docstring.

Say through our MCP server, we want to expose a tool to count "r"s in a string.

Here’s the code for this tool👇

Integrate MCP server with Cursor

In this case, Cursor is an MCP host/client that will use the tools exposed by the MCP server.

To integrate the MCP server, go to Settings → MCP → Add new global MCP server.

In the JSON file, add what's shown below👇

Done! Your local MCP server is live and connected to Cursor!

Check this👇

Next, let's interact with the MCP server.

As shown in the video below, when asked to count the number "r"s in strawberry:

0:00
/0:10
  • It identified the MCP tool.
  • Prepared the input argument.
  • Invoked the tool.
  • Used the tool's output to generate a response.

MCP server

Integrating Firecrawl

Let's make this more practical and realistic by integrating ​Firecrawl's MCP server​ to utilize scraping tools.

To do this, go to Settings → MCP → Add new global MCP server.

In the JSON file, add what's shown below👇

Once done, you will find all the tools exposed by Firecrawl's MCP server your Agents can use!

Notice that we didn't write a line of Python code to integrate Firecrawl's tools. Instead, we just integrated the MCP server.

Next, let's interact with this MCP server.

As shown in the video, when asked to list the imports of CrewAI tools listed in my blog:

0:00
/0:29
  • It identified the MCP tool (scraper).
  • Prepared the input argument.
  • Invoked the scraping tool.
  • Used the tool's output to generate a response.

That was simple, wasn’t it?

👉 Over to you: Do you think MCP is more powerful than traditional API setup?

Thanks for reading!

Published on Mar 26, 2025