Skip to content

Commit 38dcd91

Browse files
author
Kyle Rader
committed
update to fixed env var name
1 parent 84fea39 commit 38dcd91

File tree

4 files changed

+23
-31
lines changed

4 files changed

+23
-31
lines changed

docs/GETTINGSTARTED.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ Click "Select Tools" and choose the available tools.
9090

9191
##### Using Token Authentication via Environment Variables
9292

93-
For automated scenarios or when you want to use a token stored in an environment variable, you can use the `ENV_` authentication pattern:
93+
For automated scenarios or when you want to use a token stored in an environment variable, you can use the `envvar` authentication type:
9494

95-
1. **Set your token in an environment variable:**
95+
1. **Set your token in the ADO_MCP_AUTH_TOKEN environment variable:**
9696

9797
```bash
98-
export ADO_TOKEN="your-azure-devops-token"
98+
export ADO_MCP_AUTH_TOKEN="your-azure-devops-token"
9999
```
100100

101101
2. **Update your `.vscode/mcp.json` to use token authentication:**
@@ -112,7 +112,7 @@ For automated scenarios or when you want to use a token stored in an environment
112112
"ado": {
113113
"type": "stdio",
114114
"command": "npx",
115-
"args": ["-y", "@azure-devops/mcp", "${input:ado_org}", "--authentication", "ENV_ADO_TOKEN"]
115+
"args": ["-y", "@azure-devops/mcp", "${input:ado_org}", "--authentication", "envvar"]
116116
}
117117
}
118118
}

docs/TROUBLESHOOTING.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,18 @@
5050

5151
### Token Authentication via Environment Variables
5252

53-
For automated scenarios or when you want to use a token stored in an environment variable, you can use the `ENV_` authentication pattern:
53+
For automated scenarios or when you want to use a token stored in an environment variable, you can use the `envvar` authentication type:
5454

55-
1. **Set your token in an environment variable:**
55+
1. **Set your token in the ADO_MCP_AUTH_TOKEN environment variable:**
5656

5757
```bash
58-
export ADO_TOKEN="your-azure-devops-token"
58+
export ADO_MCP_AUTH_TOKEN="your-azure-devops-token"
5959
```
6060

61-
2. **Use the ENV\_ authentication pattern:**
61+
2. **Use the envvar authentication type:**
6262

6363
```bash
64-
npx @azure-devops/mcp myorg --authentication ENV_ADO_TOKEN
64+
npx @azure-devops/mcp myorg --authentication envvar
6565
```
6666

6767
3. **For MCP configuration files, update your `.vscode/mcp.json`:**
@@ -78,7 +78,7 @@ For automated scenarios or when you want to use a token stored in an environment
7878
"ado": {
7979
"type": "stdio",
8080
"command": "npx",
81-
"args": ["-y", "@azure-devops/mcp", "${input:ado_org}", "--authentication", "ENV_ADO_TOKEN"]
81+
"args": ["-y", "@azure-devops/mcp", "${input:ado_org}", "--authentication", "envvar"]
8282
}
8383
}
8484
}

src/auth.ts

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -61,28 +61,19 @@ class OAuthAuthenticator {
6161
}
6262

6363
function createAuthenticator(type: string, tenantId?: string): () => Promise<string> {
64-
// Check for ENV_ prefix pattern for environment variable authentication
65-
if (type.startsWith("ENV_")) {
66-
const envVarName = type.substring(4); // Remove "ENV_" prefix
67-
if (!envVarName) {
68-
throw new Error("Environment variable name is required after ENV_ prefix. Example: ENV_ADO_MCP_TOKEN");
69-
}
70-
71-
return async () => {
72-
const token = process.env[envVarName];
73-
if (!token) {
74-
throw new Error(`Environment variable '${envVarName}' is not set or empty. Please set it with a valid Azure DevOps Personal Access Token.`);
75-
}
76-
return token;
77-
};
78-
}
79-
8064
switch (type) {
65+
case "envvar":
66+
// Read token from fixed environment variable
67+
return async () => {
68+
const token = process.env["ADO_MCP_AUTH_TOKEN"];
69+
if (!token) {
70+
throw new Error("Environment variable 'ADO_MCP_AUTH_TOKEN' is not set or empty. Please set it with a valid Azure DevOps Personal Access Token.");
71+
}
72+
return token;
73+
};
74+
8175
case "azcli":
82-
case "env":
83-
if (type !== "env") {
84-
process.env.AZURE_TOKEN_CREDENTIALS = "dev";
85-
}
76+
process.env.AZURE_TOKEN_CREDENTIALS = "dev";
8677
let credential: TokenCredential = new DefaultAzureCredential(); // CodeQL [SM05138] resolved by explicitly setting AZURE_TOKEN_CREDENTIALS
8778
if (tenantId) {
8879
// Use Azure CLI credential if tenantId is provided for multi-tenant scenarios

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ const argv = yargs(hideBin(process.argv))
4444
})
4545
.option("authentication", {
4646
alias: "a",
47-
describe: "Type of authentication to use. Supported values are 'interactive', 'azcli', 'env', or 'ENV_<VAR_NAME>' to read token from environment variable (default: 'interactive')",
47+
describe: "Type of authentication to use",
4848
type: "string",
49+
choices: ["interactive", "azcli", "envvar"],
4950
default: defaultAuthenticationType,
5051
})
5152
.option("tenant", {

0 commit comments

Comments
 (0)