Skip to content

Commit 1594b0f

Browse files
Document .env discovery improvements (#626)
* Document improved env file discovery * Regenerate clean markdown files * Regenerate clean markdown files * Regenerate clean markdown files --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent a914027 commit 1594b0f

8 files changed

Lines changed: 38 additions & 34 deletions

File tree

app/en/get-started/quickstarts/mcp-server-quickstart/page.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,17 @@ This generates a Python module with the following structure:
8080

8181
```bash
8282
my_server/
83+
├── .env.example
8384
├── src/
8485
│ └── my_server/
8586
│ ├── __init__.py
86-
│ ├── .env.example
8787
│ └── server.py
8888
└── pyproject.toml
8989
```
9090

9191
- **server.py** Entrypoint file with MCPApp and example tools
9292
- **pyproject.toml** Dependencies and project configuration
93-
- **.env.example** Example `.env` file containing a secret required by one of the generated tools in `server.py`
93+
- **.env.example** Example `.env` file at the project root containing a secret required by one of the generated tools in `server.py`. Arcade automatically discovers `.env` files by traversing upward from the current directory.
9494

9595
`server.py` includes proper structure with command-line argument handling. It creates an `MCPApp` with three sample tools:
9696

@@ -106,17 +106,17 @@ Secrets are sensitive strings like passwords, API keys, or other tokens that gra
106106

107107
<Tabs items={[".env file", "Environment Variable"]}>
108108
<Tabs.Tab>
109-
You can create a `.env` file at the same directory as your entrypoint file (`server.py`) and add your secret:
109+
You can create a `.env` file at your project root directory and add your secret:
110110

111111
```env filename=".env"
112112
MY_SECRET_KEY="my-secret-value"
113113
```
114114

115-
The generated project includes a `.env.example` file with the secret key name and example value.
115+
The generated project includes a `.env.example` file at the project root with the secret key name and example value.
116116
You can rename it to `.env` to start using it.
117117

118118
```bash
119-
mv .env.example .env
119+
mv ../../.env.example ../../.env
120120
```
121121

122122
</Tabs.Tab>

app/en/guides/create-tools/tool-basics/build-mcp-server/page.mdx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,17 @@ This generates a Python module with the following structure:
7676

7777
```bash
7878
my_server/
79+
├── .env.example
7980
├── src/
8081
│ └── my_server/
8182
│ ├── __init__.py
82-
│ ├── .env.example
8383
│ └── server.py
8484
└── pyproject.toml
8585
```
8686

8787
1. **server.py** Main server file with MCPApp and example tools. It creates an `MCPApp`, defines tools with `@app.tool`, and will start the server with `app.run()` when the file is executed directly.
8888
1. **pyproject.toml** Dependencies and project configuration
89-
1. **.env.example** Example `.env` file containing a secret required by one of the generated tools in `server.py`. Environments are loaded on server start, so **if you update the `.env` file, you will need to restart your server.**
89+
1. **.env.example** Example `.env` file at the project root containing a secret required by one of the generated tools in `server.py`. Arcade automatically discovers `.env` files by traversing upward from the current directory, so placing it at the project root makes it accessible from any subdirectory. Environments are loaded on server start, so **if you update the `.env` file, you will need to restart your server.**
9090

9191
```python filename="server.py" showLineNumbers
9292
#!/usr/bin/env python3
@@ -171,17 +171,19 @@ Secrets are sensitive strings like passwords, API keys, or other tokens that gra
171171

172172
<Tabs items={[".env file", "Environment Variable"]}>
173173
<Tabs.Tab>
174-
You can create a `.env` file at the same directory as your entrypoint file (`server.py`) and add your secret:
174+
You can create a `.env` file at your project root directory and add your secret:
175175

176176
```env filename=".env"
177177
MY_SECRET_KEY="my-secret-value"
178178
```
179179

180-
The generated project includes a `.env.example` file with the secret key name and example value.
180+
Arcade automatically discovers `.env` files by traversing upward from the current directory through parent directories. This means you can place your `.env` file at the project root (`my_server/`), and it will be found even when running your server from a subdirectory like `src/my_server/`.
181+
182+
The generated project includes a `.env.example` file at the project root with the secret key name and example value.
181183
You can rename it to `.env` to start using it.
182184

183185
```bash
184-
mv .env.example .env
186+
mv ../../.env.example ../../.env
185187
```
186188

187189
</Tabs.Tab>

app/en/guides/create-tools/tool-basics/create-tool-secrets/page.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ Depending on where you're running your server, you can store your secret in a fe
6868

6969
<Tabs items={[".env file", "Arcade Dashboard", "Arcade CLI", "Environment Variable"]}>
7070
<Tabs.Tab>
71-
You can create a `.env` file in the same directory as your entrypoint file (typically `server.py` by default) and add your secret:
71+
You can create a `.env` file in your project root directory and add your secret:
7272

7373
```env filename=".env"
7474
MY_SECRET_KEY="my-secret-value"
7575
```
7676

77-
The project includes a `.env.example` file with the secret key name and example value.
77+
The project includes a `.env.example` file at the project root with the secret key name and example value.
7878
You can rename it to `.env` to start using it.
7979

8080
```bash
@@ -206,7 +206,7 @@ When your tool is executed, it will return: `"Got SECRET_KEY of length..."`. In
206206
## Key Concepts
207207

208208
- **Secure Access:** Secrets are accessed through context, not imported directly
209-
- **Environment Integration:** Works with both environment variables and .env files
209+
- **Environment Integration:** Works with both environment variables and `.env` files
210210
- **Error Handling:** Always handle the case where a secret might be missing
211211
- **Masking:** Never expose full secret values in logs or return values
212212
- **Declaration:** Use `requires_secrets` to make dependencies explicit
@@ -221,7 +221,7 @@ SECRET_KEY="supersecret"
221221

222222
<Callout type="warning">
223223

224-
For the code to work, you must define your environment variables locally or in a `.env` file.
224+
For the code to work, you must define your environment variables locally or in a `.env` file. Arcade will automatically search upward from the current directory to find your `.env` file.
225225

226226
</Callout>
227227

app/en/guides/deployment-hosting/arcade-deploy/page.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Validating user is logged in...
105105
Validating pyproject.toml exists in current directory...
106106
✓ pyproject.toml found at /path/to/your/project/pyproject.toml
107107

108-
Loading .env file from current directory if it exists...
108+
Searching for .env file...
109109
✓ Loaded environment from /path/to/your/project/.env
110110

111111
Validating server is healthy and extracting metadata before deploying...

public/_markdown/en/get-started/quickstarts/mcp-server-quickstart.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,17 @@ This generates a Python module with the following structure:
5757

5858
```bash
5959
my_server/
60+
├── .env.example
6061
├── src/
6162
│ └── my_server/
6263
│ ├── __init__.py
63-
│ ├── .env.example
6464
│ └── server.py
6565
└── pyproject.toml
6666
```
6767

6868
- **server.py** with MCPApp and example
6969
- **pyproject.toml** Dependencies and configuration
70-
- **.env.example** Example `.env` file containing a secret required by one of the generated in `server.py`
70+
- **.env.example** Example `.env` file at the root containing a secret required by one of the generated in `server.py`. Arcade automatically discovers `.env` files by traversing upward from the current directory.
7171

7272
`server.py` includes proper structure with command-line argument handling. It creates an `MCPApp` with three sample :
7373

@@ -83,17 +83,17 @@ Secrets are sensitive strings like passwords, , or other tokens that grant acces
8383

8484
### .env file
8585

86-
You can create a `.env` file at the same directory as your (`server.py`) and add your secret:
86+
You can create a `.env` file at your root directory and add your secret:
8787

8888
```bash
8989
# .env
9090
MY_SECRET_KEY="my-secret-value"
9191
```
9292

93-
The generated includes a `.env.example` file with the secret key name and example value. You can rename it to `.env` to start using it.
93+
The generated includes a `.env.example` file at the project root with the secret key name and example value. You can rename it to `.env` to start using it.
9494

9595
```bash
96-
mv .env.example .env
96+
mv ../../.env.example ../../.env
9797
```
9898

9999
### Environment Variable
@@ -216,7 +216,7 @@ Ensure you have set the environment variable in your terminal or `.env` file, an
216216
- **Learn how to deploy your server**: [Deploy your MCP server](/guides/deployment-hosting/arcade-deploy.md)
217217

218218

219-
Last updated on January 30, 2026
219+
Last updated on January 5, 2026
220220

221221
[Call tools in IDE/MCP clients](/en/get-started/quickstarts/call-tool-client.md)
222222
[Overview](/en/get-started/agent-frameworks.md)

public/_markdown/en/guides/create-tools/tool-basics/build-mcp-server.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,17 @@ This generates a Python module with the following structure:
5656

5757
```bash
5858
my_server/
59+
├── .env.example
5960
├── src/
6061
│ └── my_server/
6162
│ ├── __init__.py
62-
│ ├── .env.example
6363
│ └── server.py
6464
└── pyproject.toml
6565
```
6666

6767
1. **server.py** Main server file with MCPApp and example . It creates an `MCPApp`, defines tools with `@app.tool`, and will start the server with `app.run()` when the file is executed directly.
6868
2. **pyproject.toml** Dependencies and configuration
69-
3. **.env.example** Example `.env` file containing a secret required by one of the generated in `server.py`. Environments are loaded on server start, so **if you update the `.env` file, you will need to restart your server.**
69+
3. **.env.example** Example `.env` file at the root containing a secret required by one of the generated in `server.py`. Arcade automatically discovers `.env` files by traversing upward from the current directory, so placing it at the project root makes it accessible from any subdirectory. Environments are loaded on server start, so **if you update the `.env` file, you will need to restart your server.**
7070

7171
```python
7272
# server.py
@@ -152,17 +152,19 @@ Secrets are sensitive strings like passwords, , or other tokens that grant acces
152152

153153
### .env file
154154

155-
You can create a `.env` file at the same directory as your (`server.py`) and add your secret:
155+
You can create a `.env` file at your root directory and add your secret:
156156

157157
```bash
158158
# .env
159159
MY_SECRET_KEY="my-secret-value"
160160
```
161161

162-
The generated includes a `.env.example` file with the secret key name and example value. You can rename it to `.env` to start using it.
162+
Arcade automatically discovers `.env` files by traversing upward from the current directory through parent directories. This means you can place your `.env` file at the root (`my_server/`), and it will be found even when running your server from a subdirectory like `src/my_server/`.
163+
164+
The generated includes a `.env.example` file at the project root with the secret key name and example value. You can rename it to `.env` to start using it.
163165

164166
```bash
165-
mv .env.example .env
167+
mv ../../.env.example ../../.env
166168
```
167169

168170
### Environment Variable
@@ -272,7 +274,7 @@ That’s it! Your server is running and connected to your AI assistant.
272274
- **Deploy your server**: [Learn how to deploy your MCP server](/guides/deployment-hosting/arcade-deploy.md)
273275

274276

275-
Last updated on January 30, 2026
277+
Last updated on January 5, 2026
276278

277279
[Compare MCP server types](/en/guides/create-tools/tool-basics/compare-server-types.md)
278280
[Create a tool with auth](/en/guides/create-tools/tool-basics/create-tool-auth.md)

public/_markdown/en/guides/create-tools/tool-basics/create-tool-secrets.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ Depending on where you’re running your server, you can store your secret in a
6262

6363
### .env file
6464

65-
You can create a `.env` file in the same directory as your (typically `server.py` by default) and add your secret:
65+
You can create a `.env` file in your root directory and add your secret:
6666

6767
```bash
6868
# .env
6969
MY_SECRET_KEY="my-secret-value"
7070
```
7171

72-
The includes a `.env.example` file with the secret key name and example value. You can rename it to `.env` to start using it.
72+
The includes a `.env.example` file at the project root with the secret key name and example value. You can rename it to `.env` to start using it.
7373

7474
```bash
7575
mv .env.example .env
@@ -179,7 +179,7 @@ When your is executed, it will return: `"Got SECRET_KEY of length..."`. In a re
179179
## Key Concepts
180180

181181
- **Secure Access:** Secrets are accessed through , not imported directly
182-
- **Environment Integration:** Works with both environment variables and .env files
182+
- **Environment Integration:** Works with both environment variables and `.env` files
183183
- **Error Handling:** Always handle the case where a secret might be missing
184184
- **Masking:** Never expose full secret values in logs or return values
185185
- **Declaration:** Use `requires_secrets` to make dependencies explicit
@@ -193,7 +193,7 @@ When your is executed, it will return: `"Got SECRET_KEY of length..."`. In a re
193193
SECRET_KEY="supersecret"
194194
```
195195

196-
For the code to work, you must define your environment variables locally or in a `.env` file.
196+
For the code to work, you must define your environment variables locally or in a `.env` file. Arcade will automatically search upward from the current directory to find your `.env` file.
197197

198198
```python
199199
# secrets.py
@@ -249,7 +249,7 @@ For HTTP transport, view your server’s API docs at [http://127.0.0.1:8000/docs
249249

250250
For security reasons, Local HTTP servers do not currently support tool-level authorization and secrets. If you need to use tool-level authorization or secrets locally, you should use the stdio transport and configure the Arcade API key and secrets in your connection settings. Otherwise, if you intend to expose your HTTP to the public internet with \-level authorization and secrets, please follow the [deploying to the cloud with Arcade Deploy](/guides/deployment-hosting/arcade-deploy.md) guide or the [on-prem MCP server](/guides/deployment-hosting/on-prem.md) guide for secure remote deployment.
251251

252-
Last updated on January 30, 2026
252+
Last updated on January 5, 2026
253253

254254
[Create a tool with auth](/en/guides/create-tools/tool-basics/create-tool-auth.md)
255255
[Access runtime data](/en/guides/create-tools/tool-basics/runtime-data-access.md)

public/_markdown/en/guides/deployment-hosting/arcade-deploy.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Validating user is logged in...
8585
Validating pyproject.toml exists in current directory...
8686
✓ pyproject.toml found at /path/to/your/project/pyproject.toml
8787

88-
Loading .env file from current directory if it exists...
88+
Searching for .env file...
8989
✓ Loaded environment from /path/to/your/project/.env
9090

9191
Validating server is healthy and extracting metadata before deploying...
@@ -143,7 +143,7 @@ You can use any of the available [Arcade clients](/references.md) to call the to
143143

144144
Your Server is now deployed and managed by Arcade, and ready to be used in your MCP clients!
145145

146-
Last updated on January 30, 2026
146+
Last updated on January 5, 2026
147147

148148
[Configure Arcade's engine](/en/guides/deployment-hosting/configure-engine.md)
149149
[Overview](/en/guides/security.md)

0 commit comments

Comments
 (0)