Understanding MCP

Setting Up Your MCP Development Environment

5 min read

Let's set up everything you need to build and test MCP servers.

Prerequisites

Before starting, ensure you have:

  • Python 3.10+ or Node.js 18+
  • Claude Desktop (for testing)
  • A code editor (VS Code recommended)

Installing the MCP SDK

Official MCP SDKs are available for Python, TypeScript, C#, Java, Kotlin, and Swift. Community SDKs exist for Rust, Go, and other languages. In this course we'll use Python and TypeScript, but the concepts translate directly to any SDK.

Python SDK

# Create a virtual environment
python -m venv mcp-env
source mcp-env/bin/activate  # On Windows: mcp-env\Scripts\activate

# Install the MCP SDK
pip install mcp

TypeScript SDK

# Create a new project
mkdir my-mcp-server && cd my-mcp-server
npm init -y

# Install the MCP SDK
npm install @modelcontextprotocol/sdk

Your First MCP Server (Python)

Create a file called server.py:

from mcp.server import Server
from mcp.server.stdio import stdio_server
from mcp.types import Tool, TextContent

# Create server instance
server = Server(name="hello-mcp")

# Define a simple tool
@server.list_tools()
async def list_tools():
    return [
        Tool(
            name="greet",
            description="Greet someone by name",
            inputSchema={
                "type": "object",
                "properties": {
                    "name": {"type": "string", "description": "Name to greet"}
                },
                "required": ["name"]
            }
        )
    ]

@server.call_tool()
async def call_tool(name: str, arguments: dict):
    if name == "greet":
        return [TextContent(type="text", text=f"Hello, {arguments['name']}!")]
    raise ValueError(f"Unknown tool: {name}")

# Run the server
async def main():
    async with stdio_server() as (read, write):
        await server.run(read, write)

if __name__ == "__main__":
    import asyncio
    asyncio.run(main())

Configuring Claude Desktop

Add your server to Claude Desktop's config file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "hello-mcp": {
      "command": "python",
      "args": ["/path/to/server.py"]
    }
  }
}

Testing Your Server

  1. Restart Claude Desktop
  2. Open a new conversation
  3. Ask Claude: "Use the greet tool to say hello to Alice"
  4. Claude will invoke your MCP server!

Common Setup Issues

IssueSolution
Server not appearingCheck config path, restart Claude
Python not foundUse full path: /usr/bin/python3
Permission deniedCheck file permissions

Next, let's dive into building real MCP servers with tools and resources. :::

Quiz

Module 1 Quiz: MCP Fundamentals

Take Quiz
Was this lesson helpful?

Sign in to rate

FREE WEEKLY NEWSLETTER

Stay on the Nerd Track

One email per week — courses, deep dives, tools, and AI experiments.

No spam. Unsubscribe anytime.