Your First MCP Server: A Beginner's Hello World Tutorial 🌟

Welcome! This guide will help you create your very first MCP (Model Context Protocol) server that says "Hello World". By the end, you'll have your own server running that Claude can talk to!

What We're Building 🎯

We're going to create a simple server that:

  • Has a tool called "say_hello"
  • When Claude uses this tool, it responds with "Hello World!"
  • You can see this working right inside Claude Desktop

Think of it like teaching Claude a new skill - in this case, how to say hello!

Prerequisites πŸ“‹

You'll need:

  • A free Replit account (we'll show you how to sign up)
  • Claude Desktop installed on your computer
  • About 15-20 minutes of time

That's it! No coding experience needed.

Step 1: Set Up Your Replit Account πŸš€
  1. Go to replit.com
  2. Click "Sign up" in the top right
  3. You can sign up with Google, GitHub, or create a new account
  4. Once logged in, you'll see your dashboard
Step 2: Create Your MCP Server Project πŸ“
  1. On your Replit dashboard, click the big "+ Create" button
  2. Choose "Python" as your template (don't worry, we'll give you all the code!)
  3. Name your project something like
    my-first-mcp-server
  4. Click "Create"

You'll now see a code editor with a file called

main.py
.

Step 3: Add Your Server Code πŸ’»

Delete everything in

main.py
and paste this exact code:

from mcp.server.fastmcp import FastMCP

# Create your MCP server
mcp = FastMCP("My Hello World Server")

# Create a tool that says hello
@mcp.tool()
def say_hello(name: str = "World") -> str:
    """Say hello to someone"""
    return f"Hello, {name}! πŸ‘‹"

# Run the server
if __name__ == "__main__":
    mcp.run()

Don't worry about understanding every line - this code creates a simple server with one tool that says hello!

Step 4: Set Up Dependencies πŸ“¦
  1. Look for a file called
    pyproject.toml
    in the left sidebar.
  2. If you don't see it, click the "+" button next to "Files" and create a new file named
    pyproject.toml
    .
  3. Replace everything in
    pyproject.toml
    with:
[project]
name = "my-hello-world-server"
version = "0.1.0"
description = "My first MCP server"
requires-python = ">=3.10"
dependencies = [
    "mcp[cli]"
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
  1. Click the "Run" button at the top of Replit.

The first time you run it, Replit will install the necessary packages. You might see some text scrolling by - that's normal!

Step 5: Make Your Server Accessible 🌐

When your server runs, you should see something like:

MCP server running on stdio

Now we need to make it accessible from outside Replit:

  1. In Replit, look for the "Shell" tab (usually at the bottom).
  2. Type this command and press Enter:
  1. You should see a message saying your server is running.
  2. Look for a small window that pops up showing a URL (something like
    https://my-first-mcp-server.yourusername.repl.co
    ).
  3. Copy this URL - you'll need it in the next step!
Step 6: Connect to Claude Desktop πŸ”Œ

Now for the exciting part - connecting your server to Claude!

  1. Open Claude Desktop on your computer.
  2. Click on the Claude menu (on Mac) or File menu (on Windows).
  3. Select Settings.
  4. Click on Developer in the left sidebar.
  5. Click Edit Config.

This opens a configuration file. Replace everything in it with:

{
  "mcpServers": {
    "my-hello-world": {
      "url": "YOUR_REPLIT_URL_HERE/sse"
    }
  }
}
  1. Save the file (Cmd+S on Mac, Ctrl+S on Windows).
  2. Restart Claude Desktop (quit completely and open it again).
Step 7: Test Your Server! πŸŽ‰
  1. Open Claude Desktop.
  2. Look for a small hammer icon πŸ”¨ in the text input area.
  3. Click on it - you should see "say_hello" listed as an available tool!
  4. Try typing: "Can you say hello to me?"

Claude should use your tool and respond with a greeting!

You can also try:

  • "Say hello to Alice"
  • "Use the say_hello tool to greet the world"
Troubleshooting πŸ”§

If something isn't working:

Server not showing in Claude:

  • Make sure your Replit server is still running (the Shell should show it's active).
  • Double-check your Claude configuration file has the correct URL.
  • Try restarting Claude Desktop again.

Replit stopped running:

  • Click "Run" again in Replit.
  • Re-run the uvicorn command in the Shell.

Can't see the hammer icon:

  • Make sure you saved the configuration file.
  • Restart Claude Desktop completely (quit and reopen).
What You've Accomplished! πŸ†

Congratulations! You've just:

  • Created your first MCP server.
  • Deployed it online using Replit.
  • Connected it to Claude Desktop.
  • Gave Claude a new tool to use.

This is the foundation for building more complex MCP servers that can do amazing things like:

  • Search the web
  • Read and write files
  • Connect to databases
  • Interact with APIs
  • And much more!
Next Steps πŸšΆβ€β™€οΈ

Want to customize your server? Try these simple modifications:

  • Change the greeting:In your code, find the line with
    "Hello, {name}! πŸ‘‹"
    and change it to something else.
  • Add a new tool:Add this code after your first tool:
    @mcp.tool()
    def say_goodbye(name: str = "World") -> str:
        """Say goodbye to someone"""
        return f"Goodbye, {name}! See you later! πŸ‘‹"

Remember to restart your server in Replit after making changes!

Final Tips πŸ’‘
  • Keep your Replit tab open while using the server in Claude.
  • Your free Replit server might go to sleep after inactivity - just click "Run" again to wake it up.
  • Save your Replit project URL somewhere safe so you can find it again.