AI Hints
Home›MCP Tutorial›Packaging and Docker
MCP · Lesson 76 of 120

Packaging a Server

Uv and pyproject.

⏱ 2 min read▶ Video at 1:07:41🎓 Free
Watch this lesson in the MCP courseWatch on YouTube ↗Full MCP course

Sharing a server as a folder of files is fragile. A proper Python package lists its dependencies, and gives users one command to run it.

Packaging a Server
From the video: Packaging a Server
  • Folders are fragile
  • A package
  • One command

pyproject.toml

The project section names the package, and lists its dependencies, here the MCPSDK. Project scripts creates a command called northwind MCP, which calls the main function in our server. The build system section tells tools how to build it.

pyproject.tomltoml
[project]
name = "northwind-mcp"
version = "1.0.0"
requires-python = ">=3.11"
dependencies = ["mcp>=2.3"]

[project.scripts]
northwind-mcp = "northwind:main"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

northwind.py

In the server, main simply calls run. That's the function the script points to.

northwind.pypython
# ... tools, resources and prompts as before ...

def main():
    mcp.run()

if __name__ == "__main__":
    main()

Running it

Once it's published, UVX downloads and runs it in one step. Hosts can use UVX northwind MCP as the command. No folders, and no manual installs.

keyvalue
Runuvx northwind-mcp
Host commanduvx
Host argsnorthwind-mcp
Installsautomatic

Summary

Package your server with a pyproject file and a script entry, so users run it with one command. Next, Docker.

Key takeaways
  • pyproject.toml
  • project.scripts
  • uvx
Next up: Docker for MCP — a container