krasuschen commited on
Commit
7aac587
·
unverified ·
1 Parent(s): d5fbe48

fix fastmcp version ,python path valueError

Browse files

run fastmcp version , when codes in other volume
```
ValueError: '/Volumes/Codes/../.venv/lib/python3.13' is not in the subpath of '/Users/<user home>'
```

Files changed (1) hide show
  1. src/fastmcp/cli/cli.py +5 -1
src/fastmcp/cli/cli.py CHANGED
@@ -180,13 +180,17 @@ def _import_server(file: Path, server_object: str | None = None):
180
  def version(ctx: Context):
181
  if ctx.resilient_parsing:
182
  return
 
 
 
 
183
 
184
  info = {
185
  "FastMCP version": fastmcp.__version__,
186
  "MCP version": importlib.metadata.version("mcp"),
187
  "Python version": platform.python_version(),
188
  "Platform": platform.platform(),
189
- "FastMCP root path": f"~/{Path(__file__).resolve().parents[3].relative_to(Path.home())}",
190
  }
191
 
192
  g = Table.grid(padding=(0, 1))
 
180
  def version(ctx: Context):
181
  if ctx.resilient_parsing:
182
  return
183
+ try:
184
+ fastmcp_path = f"~/{Path(__file__).resolve().parents[3].relative_to(Path.home())}"
185
+ except ValueError:
186
+ fastmcp_path = str(Path(__file__).resolve().parents[3])
187
 
188
  info = {
189
  "FastMCP version": fastmcp.__version__,
190
  "MCP version": importlib.metadata.version("mcp"),
191
  "Python version": platform.python_version(),
192
  "Platform": platform.platform(),
193
+ "FastMCP root path": fastmcp_path,
194
  }
195
 
196
  g = Table.grid(padding=(0, 1))