feat: add UV runtime support in manifest v0.4

Add UV as a new server type for Python extensions that use UV runtime
for dependency management instead of bundling dependencies.

Schema changes (v0.4):
- Add "uv" to server.type enum
- Make mcp_config optional (not needed for UV type)
- UV extensions rely on pyproject.toml for dependencies

Documentation:
- Add UV runtime section to MANIFEST.md explaining benefits and usage
- Update README.md to recommend UV runtime for Python
- Add complete hello-world-uv example

Benefits of UV runtime:
- Cross-platform support (Windows/macOS/Linux, Intel/ARM)
- Small bundle size (~100 KB vs 5-10 MB)
- Handles compiled dependencies portably
- No user Python installation required

Example manifest:
{
  "manifest_version": "0.4",
  "server": {
    "type": "uv",
    "entry_point": "src/server.py"
  }
}

Co-authored-by: Joan <joan@anthropic.com>
This commit is contained in:
Joan Xie 2025-11-12 20:27:24 -08:00
commit d90365e626
No known key found for this signature in database
6 changed files with 913 additions and 4 deletions

View file

@ -0,0 +1,8 @@
.venv/
__pycache__/
*.pyc
.pytest_cache/
.mypy_cache/
*.egg-info/
server/lib/
server/venv/

View file

@ -0,0 +1,62 @@
# Hello World UV Runtime Example (Experimental)
> **Note:** UV runtime support is experimental and may change in future versions.
This example demonstrates a minimal MCP server using **UV runtime**.
## What is UV Runtime?
UV runtime lets Claude Desktop automatically manage Python and dependencies for your extension:
- Downloads the correct Python version for the user's platform
- Creates an isolated virtual environment
- Installs dependencies from `pyproject.toml`
- Works cross-platform (Windows, macOS, Linux) without user setup
## Structure
```
hello-world-uv/
├── manifest.json # server.type = "uv"
├── pyproject.toml # Dependencies listed here
├── .mcpbignore # Exclude build artifacts
└── src/
└── server.py # MCP server implementation
```
## Key Differences from Python Runtime
**UV Runtime** (this example):
- `server.type = "uv"`
- No bundled dependencies
- No `mcp_config` needed
- Small bundle size (~2 KB)
- Works on any platform
**Python Runtime** (traditional):
- `server.type = "python"`
- Must bundle dependencies in `server/lib/`
- Requires `mcp_config` with PYTHONPATH
- Larger bundle size
- Only works with pure Python (no compiled deps)
## Installing
```bash
mcpb pack
```
Install the generated `.mcpb` file in Claude Desktop.
## Testing Locally
```bash
# Install dependencies
uv sync
# Run server
uv run src/server.py
```
## Tools
- **say_hello** - Greets a person by name

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 B

View file

@ -0,0 +1,23 @@
{
"manifest_version": "0.4",
"name": "hello-world-uv",
"display_name": "Hello World (UV Runtime)",
"version": "1.0.0",
"description": "Simple MCP server using UV runtime",
"author": {
"name": "Anthropic"
},
"icon": "icon.png",
"server": {
"type": "uv",
"entry_point": "src/server.py"
},
"compatibility": {
"platforms": ["darwin", "linux", "win32"],
"runtimes": {
"python": ">=3.10"
}
},
"keywords": ["example", "hello-world", "uv"],
"license": "MIT"
}

View file

@ -0,0 +1,8 @@
[project]
name = "hello-world-uv"
version = "1.0.0"
description = "Simple MCP server using UV runtime"
requires-python = ">=3.10"
dependencies = [
"mcp>=1.0.0",
]

View file

@ -0,0 +1,65 @@
#!/usr/bin/env python3
"""Hello World MCP server using UV runtime."""
import asyncio
from mcp.server.models import InitializationOptions
import mcp.types as types
from mcp.server import NotificationOptions, Server
import mcp.server.stdio
server = Server("hello-world-uv")
@server.list_tools()
async def handle_list_tools() -> list[types.Tool]:
"""List available tools."""
return [
types.Tool(
name="say_hello",
description="Say hello to someone",
inputSchema={
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Name to greet",
}
},
"required": ["name"],
},
)
]
@server.call_tool()
async def handle_call_tool(
name: str, arguments: dict | None
) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
"""Handle tool calls."""
if name == "say_hello":
person_name = arguments.get("name", "World") if arguments else "World"
return [types.TextContent(type="text", text=f"Hello, {person_name}!")]
raise ValueError(f"Unknown tool: {name}")
async def main():
"""Run the server."""
async with mcp.server.stdio.stdio_server() as (read_stream, write_stream):
await server.run(
read_stream,
write_stream,
InitializationOptions(
server_name="hello-world-uv",
server_version="1.0.0",
capabilities=server.get_capabilities(
notification_options=NotificationOptions(),
experimental_capabilities={},
),
),
)
if __name__ == "__main__":
asyncio.run(main())