Jeremiah Lowin commited on
Commit
3dc0bc0
·
1 Parent(s): 9f2a9ef

Update dependency management

Browse files
Files changed (4) hide show
  1. README.md +12 -0
  2. src/fastmcp/cli/cli.py +19 -4
  3. src/fastmcp/server.py +1 -0
  4. uv.lock +1 -1
README.md CHANGED
@@ -81,9 +81,21 @@ def calculate(x: int, y: int) -> int:
81
  FastMCP includes a development server with the MCP Inspector for testing your server:
82
 
83
  ```bash
 
84
  fastmcp dev your_server.py
 
 
 
 
 
 
 
 
 
85
  ```
86
 
 
 
87
  ### Installing in Claude
88
 
89
  To use your server with Claude Desktop:
 
81
  FastMCP includes a development server with the MCP Inspector for testing your server:
82
 
83
  ```bash
84
+ # Basic usage
85
  fastmcp dev your_server.py
86
+
87
+ # Load dependencies from current directory's pyproject.toml
88
+ fastmcp dev your_server.py --uv-directory .
89
+
90
+ # Install additional packages
91
+ fastmcp dev your_server.py --with pandas,numpy
92
+
93
+ # Combine both
94
+ fastmcp dev your_server.py --uv-directory . --with pandas,numpy
95
  ```
96
 
97
+ 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.
98
+
99
  ### Installing in Claude
100
 
101
  To use your server with Claude Desktop:
src/fastmcp/cli/cli.py CHANGED
@@ -26,6 +26,7 @@ app = typer.Typer(
26
  def _build_uv_command(
27
  file: Path,
28
  uv_directory: Optional[Path] = None,
 
29
  ) -> list[str]:
30
  """Build the uv run command."""
31
  cmd = ["uv"]
@@ -33,7 +34,14 @@ def _build_uv_command(
33
  if uv_directory:
34
  cmd.extend(["--directory", str(uv_directory)])
35
 
36
- cmd.extend(["run", str(file)])
 
 
 
 
 
 
 
37
  return cmd
38
 
39
 
@@ -148,6 +156,14 @@ def dev(
148
  resolve_path=True,
149
  ),
150
  ] = None,
 
 
 
 
 
 
 
 
151
  ) -> None:
152
  """Run a FastMCP server with the MCP Inspector."""
153
  file, server_object = _parse_file_path(file_spec)
@@ -158,11 +174,12 @@ def dev(
158
  "file": str(file),
159
  "server_object": server_object,
160
  "uv_directory": str(uv_directory) if uv_directory else None,
 
161
  },
162
  )
163
 
164
  try:
165
- uv_cmd = _build_uv_command(file, uv_directory)
166
  # Run the MCP Inspector command
167
  process = subprocess.run(
168
  ["npx", "@modelcontextprotocol/inspector"] + uv_cmd,
@@ -227,8 +244,6 @@ def run(
227
  )
228
 
229
  try:
230
- uv_cmd = _build_uv_command(file, uv_directory)
231
-
232
  # Import and get server object
233
  server = _import_server(file, server_object)
234
 
 
26
  def _build_uv_command(
27
  file: Path,
28
  uv_directory: Optional[Path] = None,
29
+ with_packages: Optional[list[str]] = None,
30
  ) -> list[str]:
31
  """Build the uv run command."""
32
  cmd = ["uv"]
 
34
  if uv_directory:
35
  cmd.extend(["--directory", str(uv_directory)])
36
 
37
+ cmd.extend(["run", "--with", "fastmcp"])
38
+
39
+ if with_packages:
40
+ for pkg in with_packages:
41
+ if pkg:
42
+ cmd.extend(["--with", pkg])
43
+
44
+ cmd.append(str(file))
45
  return cmd
46
 
47
 
 
156
  resolve_path=True,
157
  ),
158
  ] = None,
159
+ with_packages: Annotated[
160
+ Optional[list[str]],
161
+ typer.Option(
162
+ "--with",
163
+ help="Additional packages to install",
164
+ multiple=True,
165
+ ),
166
+ ] = None,
167
  ) -> None:
168
  """Run a FastMCP server with the MCP Inspector."""
169
  file, server_object = _parse_file_path(file_spec)
 
174
  "file": str(file),
175
  "server_object": server_object,
176
  "uv_directory": str(uv_directory) if uv_directory else None,
177
+ "with_packages": with_packages,
178
  },
179
  )
180
 
181
  try:
182
+ uv_cmd = _build_uv_command(file, uv_directory, with_packages)
183
  # Run the MCP Inspector command
184
  process = subprocess.run(
185
  ["npx", "@modelcontextprotocol/inspector"] + uv_cmd,
 
244
  )
245
 
246
  try:
 
 
247
  # Import and get server object
248
  server = _import_server(file, server_object)
249
 
src/fastmcp/server.py CHANGED
@@ -108,6 +108,7 @@ class FastMCP:
108
 
109
  async def list_resources(self) -> list[MCPResource]:
110
  """List all available resources."""
 
111
  resources = self._resource_manager.list_resources()
112
  return [
113
  MCPResource(
 
108
 
109
  async def list_resources(self) -> list[MCPResource]:
110
  """List all available resources."""
111
+
112
  resources = self._resource_manager.list_resources()
113
  return [
114
  MCPResource(
uv.lock CHANGED
@@ -222,7 +222,7 @@ wheels = [
222
 
223
  [[package]]
224
  name = "fastmcp"
225
- version = "0.1.dev4+g18aaf41.d20241129"
226
  source = { editable = "." }
227
  dependencies = [
228
  { name = "httpx" },
 
222
 
223
  [[package]]
224
  name = "fastmcp"
225
+ version = "0.1.1.dev1+gca7438f.d20241130"
226
  source = { editable = "." }
227
  dependencies = [
228
  { name = "httpx" },