Understanding MCP

Setting Up Your MCP Development Environment

5 min read

Ten minutes of setup, and the rest of the course is writing server code rather than fighting your environment.

Prerequisites

  • A Python or Node.js runtime. Each SDK states its own minimum version, and those move — check the MCP SDK documentation for the current requirement rather than trusting a number written in a course.
  • Claude Desktop, which is what you will test against.
  • A code editor. Any will do.

Installing the MCP SDK

Official SDKs cover Python, TypeScript, C#, Java, Kotlin, and Swift, with community SDKs for Rust, Go, and others. This course uses Python for the examples and TypeScript where it differs meaningfully — the protocol is identical underneath, so the concepts port to whichever you pick.

Install the SDK

bash
# Isolate the project so SDK upgrades can't break other work
python -m venv mcp-env
source mcp-env/bin/activate       # Windows: mcp-env\Scripts\activate

# The SDK is on v2. Pin the major so a future v3 cannot rewrite your server overnight.
pip install 'mcp>=2,<3'

# Print the version you actually got, and keep it in your README
python -c "import importlib.metadata as m; print('mcp', m.version('mcp'))"

Your First MCP Server (Python)

Create a file called server.py:

from mcp.server import MCPServer

# The server name is what shows up in the host's logs and settings UI
mcp = MCPServer(name="hello-mcp")


@mcp.tool()
def greet(name: str) -> str:
    """Greet someone by name."""
    return f"Hello, {name}!"


if __name__ == "__main__":
    mcp.run()

That is the whole server. Three things are happening that are worth naming, because they are the reason this is shorter than you expected:

  • The type hints are the schema. name: str becomes the inputSchema the model reads. You do not hand-write JSON Schema unless you want to.
  • The docstring is the description. It is the text the model uses to decide whether to call your tool at all, so it is worth more care than the function body.
  • mcp.run() picks stdio by default, which is what Claude Desktop launches.

Run it before wiring anything up. A server that starts cleanly and exits on Ctrl-C has already ruled out half of the problems you would otherwise debug through the host:

python server.py

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!

When it doesn't work

Almost every first-run failure is one of four things, and they are distinguishable in under a minute. Work through it:

My server isn't showing up in Claude Desktop

Did you fully quit and reopen Claude Desktop after editing the config?

The one that catches everyone: on a stdio server, stdout is the protocol channel. A stray print() injects garbage into the JSON-RPC stream and the connection dies with no useful error. Log to a file, or to stderr, never to stdout.

Next: building a real server with tools and resources. :::

Quiz

Module 1 Quiz: MCP Fundamentals

Take Quiz
Was this lesson helpful?

Sign in to rate