Practical AI Logo
Courses
Setting Up Your First MCP Server
2h 30min
Beginner
Author: George K.
Overview

You'll set up a complete Python environment for building MCP (Model Context Protocol) servers and ship your first working server with tools and prompts.


Environment requirements

  • - Python 3.11 or higher
  • - Terminal / command-line access
  • - LM Studio
Learning Outcomes
  • Verify and configure a Python environment for MCP development
  • Install the MCP SDK and all required dependencies
  • Scaffold and run an MCP server from scratch
  • Expose custom tools and prompts through your server
  • Connect an MCP client and test your server interactively
Steps

Step 1: Verify Python Installation

MCP requires Python 3.11 or higher. Run the following in your terminal and confirm the output shows 3.11+. If you need to update, visit python.org and download the latest stable release.

python --version

Step 2: Install MCP Dependencies

Install the MCP SDK and supporting packages. Each covers a distinct concern: the SDK for the protocol, httpx for async HTTP calls, FastAPI for remote transport, and python-dotenv for environment config.

pip install mcp httpx fastapi python-dotenv

Step 3: Create Your First Server

Create server.py and instantiate a FastMCP app. At minimum you need a name and a transport — start with stdio for local testing before moving to HTTP.

transport="stdio"

Step 4: Define Tools and Prompts

Decorate Python functions to expose them as callable tools, and use prompt decorators for reusable prompt templates. Type annotations on arguments become the tool's input schema automatically.

@mcp.tool()
@mcp.prompt()

Step 5: Configure the MCP Client

Open LM Studio, navigate to the MCP section, and add a new server entry pointing to your server file. Set the transport and provide the Python executable path. Save and restart the client.

server.py
stdio

Step 6: Test Your Server Interactively

With the client connected, invoke one of your tools from the chat interface. You should see the function execute and the result returned inline. Use the MCP inspector for lower-level debugging without a full client.

mcp dev server.py
All done! Let's check again what we've done in this course:
What's next?

Next Mini Course

Connecting External APIs to MCP – Building a Trello IntegrationLearn how to connect your MCP server to external services like Trello, create tools that interact with real APIs, handle authentication with API keys, and build intelligent workflows that let AI assistants create and manage tasks on your boards.

Further Reading