mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-23 14:04:18 +02:00
Update dependency management
This commit is contained in:
parent
ca7438f15c
commit
c5ae6f42ef
4 changed files with 33 additions and 5 deletions
12
README.md
12
README.md
|
|
@ -81,9 +81,21 @@ def calculate(x: int, y: int) -> int:
|
|||
FastMCP includes a development server with the MCP Inspector for testing your server:
|
||||
|
||||
```bash
|
||||
# Basic usage
|
||||
fastmcp dev your_server.py
|
||||
|
||||
# Load dependencies from current directory's pyproject.toml
|
||||
fastmcp dev your_server.py --uv-directory .
|
||||
|
||||
# Install additional packages
|
||||
fastmcp dev your_server.py --with pandas,numpy
|
||||
|
||||
# Combine both
|
||||
fastmcp dev your_server.py --uv-directory . --with pandas,numpy
|
||||
```
|
||||
|
||||
The `--with` flag automatically includes `fastmcp` and any additional packages you specify. The `--uv-directory` flag tells uv where to find your project's dependencies.
|
||||
|
||||
### Installing in Claude
|
||||
|
||||
To use your server with Claude Desktop:
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ app = typer.Typer(
|
|||
def _build_uv_command(
|
||||
file: Path,
|
||||
uv_directory: Optional[Path] = None,
|
||||
with_packages: Optional[list[str]] = None,
|
||||
) -> list[str]:
|
||||
"""Build the uv run command."""
|
||||
cmd = ["uv"]
|
||||
|
|
@ -33,7 +34,14 @@ def _build_uv_command(
|
|||
if uv_directory:
|
||||
cmd.extend(["--directory", str(uv_directory)])
|
||||
|
||||
cmd.extend(["run", str(file)])
|
||||
cmd.extend(["run", "--with", "fastmcp"])
|
||||
|
||||
if with_packages:
|
||||
for pkg in with_packages:
|
||||
if pkg:
|
||||
cmd.extend(["--with", pkg])
|
||||
|
||||
cmd.append(str(file))
|
||||
return cmd
|
||||
|
||||
|
||||
|
|
@ -148,6 +156,14 @@ def dev(
|
|||
resolve_path=True,
|
||||
),
|
||||
] = None,
|
||||
with_packages: Annotated[
|
||||
Optional[list[str]],
|
||||
typer.Option(
|
||||
"--with",
|
||||
help="Additional packages to install",
|
||||
multiple=True,
|
||||
),
|
||||
] = None,
|
||||
) -> None:
|
||||
"""Run a FastMCP server with the MCP Inspector."""
|
||||
file, server_object = _parse_file_path(file_spec)
|
||||
|
|
@ -158,11 +174,12 @@ def dev(
|
|||
"file": str(file),
|
||||
"server_object": server_object,
|
||||
"uv_directory": str(uv_directory) if uv_directory else None,
|
||||
"with_packages": with_packages,
|
||||
},
|
||||
)
|
||||
|
||||
try:
|
||||
uv_cmd = _build_uv_command(file, uv_directory)
|
||||
uv_cmd = _build_uv_command(file, uv_directory, with_packages)
|
||||
# Run the MCP Inspector command
|
||||
process = subprocess.run(
|
||||
["npx", "@modelcontextprotocol/inspector"] + uv_cmd,
|
||||
|
|
@ -227,8 +244,6 @@ def run(
|
|||
)
|
||||
|
||||
try:
|
||||
uv_cmd = _build_uv_command(file, uv_directory)
|
||||
|
||||
# Import and get server object
|
||||
server = _import_server(file, server_object)
|
||||
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ class FastMCP:
|
|||
|
||||
async def list_resources(self) -> list[MCPResource]:
|
||||
"""List all available resources."""
|
||||
|
||||
resources = self._resource_manager.list_resources()
|
||||
return [
|
||||
MCPResource(
|
||||
|
|
|
|||
2
uv.lock
generated
2
uv.lock
generated
|
|
@ -222,7 +222,7 @@ wheels = [
|
|||
|
||||
[[package]]
|
||||
name = "fastmcp"
|
||||
version = "0.1.dev4+g18aaf41.d20241129"
|
||||
version = "0.1.1.dev1+gca7438f.d20241130"
|
||||
source = { editable = "." }
|
||||
dependencies = [
|
||||
{ name = "httpx" },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue