DEV Community

How to build MCP Servers and Clients from Scratch

Developer Harsh on March 16, 2025

What is MCP Think of MCP as a USB C port on a laptop. With it, you can charge your laptop, perform data transfer, connect to other displ...
Collapse
 
helloarunyadav profile image
Arun Yadav • Edited

Open the terminal and navigate to your working environment.

Run the command:

pip install uv
mcp dev calculator.py
Enter fullscreen mode Exit fullscreen mode

If prompted, install the CLI by pressing ‘y’ or do it manually, then rerun the command.

Some people might get stuck here, but don’t worry—I’m here to help! Just replace server.py with calculator.py, and you’re good to go. 🚀

Collapse
 
developer_harsh profile image
Developer Harsh

Thanks for the addition, it will help many

Collapse
 
d04975d650beed571b profile image
Aliosh

"Traditional API" -> What would be a traditional API?

Are you referring to the HTTP protocol? MCP is a protocol and Http is another. An api can share the same interface, adaptable for any of these protocols. This is what I have done on my MCP server, with clean architecture: github.com/alioshr/memory-bank-mcp

Collapse
 
developer_harsh profile image
Developer Harsh

Yes HTTP Protocols / Custom API we design for products.

I will check the repo. Thanks for sharing 🙏

Collapse
 
manuel_alzolawrth_8983a profile image
Manuel Alzola Würth

Can FastMCP be used on a flask server?

Collapse
 
wenxuwan profile image
wenxuwan

Same question.

Collapse
 
developer_harsh profile image
Developer Harsh

Answered in previous comment

Collapse
 
developer_harsh profile image
Developer Harsh

FastMCP isn’t designed to be used directly within a Flask server.

However you can run them as separate services and facilitate communication between them to achieve the desired integration.

Collapse
 
wenxuwan profile image
wenxuwan

Thanks for your reply, now I converted the flask app to an asgi app via WsgiToAsgi and then mounted the asgi_flask app to the MCP's sse_app (s se_app is a Starlette app)

class SofaApp(FastMCP, Flask):
    def __init__(self):
        FastMCP.__init__(self, __name__)
        Flask.__init__(self, __name__)
        self.asgi_flask = WsgiToAsgi(self)
        self.sofa_app = self.sse_app()
        self.sofa_app.mount("/", self.asgi_flask)

Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
developer_harsh profile image
Developer Harsh

Great

Collapse
 
developer_harsh profile image
Developer Harsh • Edited

Read the better formatted version at Composio Blogs- Harsh

Collapse
 
artydev profile image
artydev

Thank you very much, I will try it for sure :-)

Collapse
 
john_charlie_23a7c4ea7d2f profile image
John Charlie

Amazing article! But what about creating our own MCP Client?

Collapse
 
developer_harsh profile image
Developer Harsh

For MCP client you can use Cursor, WindSurf, Warp, Composio. In case you want to create your own using mcp-client SDK. I will cover that in another blog:)