Member-only story
MCP Developer Quick Start
Introduction
MCP is an open protocol that standardizes how applications provide context to LLMs. Think of MCP like a USB-C port for AI applications. Just as USB-C provides a standardized way to connect your devices to various peripherals and accessories, MCP provides a standardized way to connect AI models to different data sources and tools.
Prerequisites
- A Linux or macOS system
- Python 3.8 or later installed
- pip package manager installed
Installation
Build Virtual Env
For Python developers, it is always good to use virtual environment to isolate your different test environments.
gyliu513@Guangyas-MacBook-Pro ~ % python3.10 -m venv mcp
gyliu513@Guangyas-MacBook-Pro ~ % source mcp/bin/activate
(mcp) gyliu513@Guangyas-MacBook-Pro ~ %
Install MCP
(mcp) gyliu513@Guangyas-MacBook-Pro ~ % pip install "mcp[cli]"
Create a sample server
Let’s create a simple MCP server that exposes a calculator tool and some data:
# demo.py
from mcp.server.fastmcp import FastMCP
# Create an MCP server
mcp = FastMCP("Demo")
# Add an addition tool
@mcp.tool()
def add(a: int, b: int) -> int:
"""Add two numbers"""
return a + b
# Add a dynamic greeting resource
@mcp.resource("greeting://{name}")
def…