Remove top level env var

This commit is contained in:
Jeremiah Lowin 2024-11-30 22:25:49 -05:00
commit abbbd53539

View file

@ -51,14 +51,11 @@ That's it! FastMCP handles all the complex protocol details and server managemen
- [Prompts](#prompts)
- [Images](#images)
- [Context](#context)
- [Environment Variables](#environment-variables)
- [Claude Desktop](#claude-desktop)
- [Development Mode](#development-mode)
- [Deployment](#deployment)
- [Development](#development)
- [Environment Variables](#environment-variables)
- [Claude Desktop](#claude-desktop)
- [Environment Variables](#environment-variables-1)
- [Claude Desktop](#claude-desktop-1)
- [Environment Variables](#environment-variables-2)
- [Examples](#examples)
- [Echo Server](#echo-server)
- [SQLite Explorer](#sqlite-explorer)
@ -272,42 +269,6 @@ The Context object provides:
- Resource access through `read_resource()`
- Request metadata via `request_id` and `client_id`
## Environment Variables
MCP servers run in isolated environments and do not inherit environment variables from your system. Here's how to handle environment variables in different contexts:
### Claude Desktop
When installing a server in Claude Desktop, provide environment variables using the CLI:
```bash
# Single env var
fastmcp install server.py -e API_KEY=abc123
# Multiple env vars
fastmcp install server.py -e API_KEY=abc123 -e OTHER_VAR=value
# Load from .env file
fastmcp install server.py -f .env
```
Environment variables persist across reinstalls and are only updated when new values are provided:
```bash
# First install
fastmcp install server.py -e FOO=bar -e BAZ=123
# Second install - FOO and BAZ are preserved
fastmcp install server.py -e NEW=value
# Third install - FOO gets new value, others preserved
fastmcp install server.py -e FOO=newvalue
```
### Development Mode
The MCP Inspector also runs servers in an isolated environment. Environment variables must be set through the Inspector UI and are not inherited from your system. The Inspector does not currently support setting environment variables via command line (see [Issue #94](https://github.com/modelcontextprotocol/inspector/issues/94)).
## Deployment
The FastMCP CLI helps you develop and deploy MCP servers.