Skip to content

Commit f364dc4

Browse files
committed
support token
1 parent babcb46 commit f364dc4

File tree

6 files changed

+344
-17
lines changed

6 files changed

+344
-17
lines changed

packages/monday-api-mcp/README.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ A server implementation for the [Model Context Protocol (MCP)](https://modelcont
88
@mondaydotcomorg/monday-api-mcp -t abcd123
99
```
1010

11+
The Monday API token can also be provided via the `monday_token` environment variable.
12+
1113
### Command Line Arguments
1214

1315
| Argument | Flags | Description | Required | Default |
1416
|----------|-------|-------------|----------|---------|
15-
| Monday API Token | `--token`, `-t` | Monday.com API token | Yes | - |
17+
| Monday API Token | `--token`, `-t` | Monday.com API token (can also be provided via `monday_token` environment variable) | Yes | - |
1618
| API Version | `--version`, `-v` | Monday.com API version | No | `current` |
1719
| Read Only Mode | `--read-only`, `-ro` | Enable read-only mode | No | `false` |
1820
| Dynamic API Tools | `--enable-dynamic-api-tools`, `-edat` | (Beta) Enable dynamic API tools (Mode that includes the whole API schema, not supported when using read-only mode) | No | `false` |
@@ -50,6 +52,24 @@ A server implementation for the [Model Context Protocol (MCP)](https://modelcont
5052
}
5153
```
5254

55+
### Example Using Environment Variable
56+
57+
```json
58+
{
59+
"mcpServers": {
60+
"monday-api-mcp": {
61+
"command": "npx",
62+
"args": [
63+
"@mondaydotcomorg/monday-api-mcp"
64+
],
65+
"env": {
66+
"monday_token": "abcd123"
67+
}
68+
}
69+
}
70+
}
71+
```
72+
5373
## License
5474

55-
MIT
75+
MIT

packages/monday-api-mcp/lib/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
33
import { MondayAgentToolkit } from '@mondaydotcomorg/agent-toolkit/mcp';
44
import { parseArgs, validateArgs } from './utils/args/args.service.js';
5+
import dotenv from 'dotenv';
6+
7+
dotenv.config();
58

69
/**
710
* Initializes and starts the MCP server with the Monday Agent Toolkit

packages/monday-api-mcp/lib/utils/args/args.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const ARG_CONFIGS: ArgConfig[] = [
1212
flags: ['--version', '-v'],
1313
description: 'Monday API version',
1414
required: false,
15-
defaultValue: 'current',
15+
defaultValue: undefined,
1616
},
1717
{
1818
name: 'readOnlyMode',

packages/monday-api-mcp/lib/utils/args/args.service.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { ARG_CONFIGS } from './args.config.js';
33

44
/**
55
* Parse command line arguments based on the defined configurations
6+
* Also checks environment variables if command line args are not provided
67
* @param args Command line arguments (process.argv.slice(2))
78
* @returns Object with parsed arguments
89
*/
@@ -11,6 +12,8 @@ export function parseArgs(args: string[]): ParsedArgs {
1112

1213
ARG_CONFIGS.forEach((config) => {
1314
let argValue: string | undefined;
15+
16+
// Try to get value from command line arguments
1417
for (const flag of config.flags) {
1518
const flagIndex = args.findIndex((arg) => arg === flag);
1619
if (flagIndex !== -1 && flagIndex + 1 < args.length) {
@@ -19,6 +22,19 @@ export function parseArgs(args: string[]): ParsedArgs {
1922
}
2023
}
2124

25+
// If not found in command line args, try environment variables
26+
if (argValue === undefined) {
27+
const envVarName = `MONDAY_${config.name.toUpperCase()}`;
28+
if (process.env[envVarName]) {
29+
argValue = process.env[envVarName];
30+
}
31+
}
32+
33+
// If still not found, use default value if provided
34+
if (argValue === undefined && config.defaultValue !== undefined) {
35+
argValue = String(config.defaultValue);
36+
}
37+
2238
result[config.name] = argValue;
2339
});
2440

packages/monday-api-mcp/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
},
2525
"dependencies": {
2626
"@modelcontextprotocol/sdk": "^1.7.0",
27-
"@mondaydotcomorg/agent-toolkit": "workspace:*"
27+
"@mondaydotcomorg/agent-toolkit": "workspace:*",
28+
"dotenv": "^16.4.7"
2829
},
2930
"devDependencies": {
3031
"@types/jest": "^29.5.12",

0 commit comments

Comments
 (0)