docs: add uv-managed dependencies and uvx examples to mcp-json configuration (#3843)

Closes #1707

- Add example for configuring mcp.json with uv-managed projects (pyproject.toml)
- Add examples for running published pip packages via uvx
- Update both main and v2 docs

Co-authored-by: Emily Chen <emilychen.techwriter@gmail.com>
Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
This commit is contained in:
vincent 2026-04-13 05:09:15 +08:00 committed by GitHub
commit 673e6bb0f7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 184 additions and 0 deletions

View file

@ -357,6 +357,98 @@ echo "$CONFIG" | jq '."CI Server".command'
# Output: "uv"
```
### UV-Managed Project Dependencies
For servers that live inside a uv-managed project (with `pyproject.toml`), use the `--project` flag to run within that project's environment:
```bash
fastmcp install mcp-json server.py --project .
```
Output:
```json
{
"My Server": {
"command": "uv",
"args": [
"run",
"--project",
"/absolute/path/to/project",
"--with",
"fastmcp",
"fastmcp",
"run",
"/absolute/path/to/project/server.py"
]
}
}
```
You can also use `fastmcp.json` with a local project:
```json fastmcp.json
{
"$schema": "https://gofastmcp.com/public/schemas/fastmcp.json/v1.json",
"source": {
"path": "server.py"
},
"environment": {
"project": "."
}
}
```
If your server needs additional packages beyond those in `pyproject.toml`, add them via the `dependencies` array or `--with`.
### Published Packages with `uvx`
If your team publishes MCP servers as pip packages, you can configure clients to run them with `uvx` directly instead of `uv run`. For example, if your package is called `my-mcp-server` and provides a CLI entry point of the same name:
```json
{
"mcpServers": {
"My Server": {
"command": "uvx",
"args": ["my-mcp-server"]
}
}
}
```
If the package name differs from the CLI command (e.g., package `weather-mcp` with command `weather-server`):
```json
{
"mcpServers": {
"Weather": {
"command": "uvx",
"args": ["--from", "weather-mcp", "weather-server"]
}
}
}
```
You can also pin Python versions or add extra dependencies:
```json
{
"mcpServers": {
"My Server": {
"command": "uvx",
"args": [
"--python", "3.12",
"--with", "requests",
"my-mcp-server"
]
}
}
}
```
<Note>
`fastmcp install mcp-json` generates `uv run` configurations for local development. For published packages, you'll typically write the `uvx` configuration manually or generate it through your own packaging workflow.
</Note>
## Integration with MCP Clients
The generated configuration works with any MCP-compatible application:

View file

@ -357,6 +357,98 @@ echo "$CONFIG" | jq '."CI Server".command'
# Output: "uv"
```
### UV-Managed Project Dependencies
For servers that live inside a uv-managed project (with `pyproject.toml`), use the `--project` flag to run within that project's environment:
```bash
fastmcp install mcp-json server.py --project .
```
Output:
```json
{
"My Server": {
"command": "uv",
"args": [
"run",
"--project",
"/absolute/path/to/project",
"--with",
"fastmcp",
"fastmcp",
"run",
"/absolute/path/to/project/server.py"
]
}
}
```
You can also use `fastmcp.json` with a local project:
```json fastmcp.json
{
"$schema": "https://gofastmcp.com/public/schemas/fastmcp.json/v1.json",
"source": {
"path": "server.py"
},
"environment": {
"project": "."
}
}
```
If your server needs additional packages beyond those in `pyproject.toml`, add them via the `dependencies` array or `--with`.
### Published Packages with `uvx`
If your team publishes MCP servers as pip packages, you can configure clients to run them with `uvx` directly instead of `uv run`. For example, if your package is called `my-mcp-server` and provides a CLI entry point of the same name:
```json
{
"mcpServers": {
"My Server": {
"command": "uvx",
"args": ["my-mcp-server"]
}
}
}
```
If the package name differs from the CLI command (e.g., package `weather-mcp` with command `weather-server`):
```json
{
"mcpServers": {
"Weather": {
"command": "uvx",
"args": ["--from", "weather-mcp", "weather-server"]
}
}
}
```
You can also pin Python versions or add extra dependencies:
```json
{
"mcpServers": {
"My Server": {
"command": "uvx",
"args": [
"--python", "3.12",
"--with", "requests",
"my-mcp-server"
]
}
}
}
```
<Note>
`fastmcp install mcp-json` generates `uv run` configurations for local development. For published packages, you'll typically write the `uvx` configuration manually or generate it through your own packaging workflow.
</Note>
## Integration with MCP Clients
The generated configuration works with any MCP-compatible application: