Skip to content

Instantly share code, notes, and snippets.

@labeveryday
Last active May 29, 2025 03:07
Show Gist options
  • Select an option

  • Save labeveryday/1d02c75b83e683da9ba6cf1f3feb16de to your computer and use it in GitHub Desktop.

Select an option

Save labeveryday/1d02c75b83e683da9ba6cf1f3feb16de to your computer and use it in GitHub Desktop.
Instructions to setup MCP with UV in Python

How to setup MCP with UV

This is a a pratical example of how to setup MCP with UV in Python

  1. Create dir and cd into it
  2. uv init hello-world --python 3.12.9
  3. source ./venv/bin/activate
  4. uv add "mcp[cli]"
  5. uv run mcp dev main.py
  6. Or npx @modelcontextprotocol/inspector uv --directory ./ "run" "main.py"

Sample main.py

from mcp.server.fastmcp import FastMCP

# Create an MCP server
mcp = FastMCP("Weather Service")


@mcp.tool()
def get_weather(location: str) -> str:
    """Get the current weather for a specified location."""
    return f"Weather in {location}: Sunny, 72°F"
  
# Run the server
if __name__ == "__main__":
    mcp.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment