-
Notifications
You must be signed in to change notification settings - Fork 164
feat: add experimental UV runtime support in manifest v0.4 #158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| .venv/ | ||
| __pycache__/ | ||
| *.pyc | ||
| .pytest_cache/ | ||
| .mypy_cache/ | ||
| *.egg-info/ | ||
| server/lib/ | ||
| server/venv/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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()) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we have wording that raw python support may be removed and steer people to uv?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, I'm going to mark uv as experimental in case this ends up being the wrong call (for whatever reason, e.g. mcp sdk no longer requires built dependencies?) and we want to backtrack to a bundled approach. Will update if/when we formalize!