Skip to content

Commit e1f89f6

Browse files
committed
feat: Support multiple keys for global config lookup
- Adds prioritized lookup for short, atlassian-jira, full, and unscoped package names in ~/.mcp/configs.json. - Updates README documentation to reflect supported keys and recommend short keys.
1 parent 8095f29 commit e1f89f6

2 files changed

Lines changed: 44 additions & 9 deletions

File tree

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Create or edit `~/.mcp/configs.json`:
5454

5555
```json
5656
{
57-
"@aashari/mcp-server-atlassian-jira": {
57+
"jira": {
5858
"environments": {
5959
"ATLASSIAN_SITE_NAME": "<YOUR_SITE_NAME>",
6060
"ATLASSIAN_USER_EMAIL": "<YOUR_ATLASSIAN_EMAIL>",
@@ -68,6 +68,8 @@ Create or edit `~/.mcp/configs.json`:
6868
- `<YOUR_ATLASSIAN_EMAIL>`: Your Atlassian account email.
6969
- `<YOUR_COPIED_API_TOKEN>`: The API token from Step 1.
7070

71+
**Note:** For backward compatibility, the server will also recognize configurations under the full package name (`@aashari/mcp-server-atlassian-jira`), the unscoped package name (`mcp-server-atlassian-jira`), or the `atlassian-jira` format if the recommended `jira` key is not found. However, using the short `jira` key is preferred for new configurations.
72+
7173
### Method B: Environment Variables
7274

7375
Pass credentials directly when running the server:
@@ -90,7 +92,7 @@ Configure your MCP-compatible client to launch this server.
9092
```json
9193
{
9294
"mcpServers": {
93-
"aashari/mcp-server-atlassian-jira": {
95+
"jira": {
9496
"command": "npx",
9597
"args": ["-y", "@aashari/mcp-server-atlassian-jira"]
9698
}

src/utils/config.util.ts

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,50 @@ class ConfigLoader {
109109
const configContent = fs.readFileSync(globalConfigPath, 'utf8');
110110
const config = JSON.parse(configContent);
111111

112-
if (
113-
!config[this.packageName] ||
114-
!config[this.packageName].environments
115-
) {
112+
// Determine the potential keys for the current package
113+
const shortKey = 'jira'; // Project-specific short key
114+
const atlassianProductKey = 'atlassian-jira'; // New supported key
115+
const fullPackageName = this.packageName; // e.g., '@aashari/mcp-server-atlassian-jira'
116+
const unscopedPackageName =
117+
fullPackageName.split('/')[1] || fullPackageName; // e.g., 'mcp-server-atlassian-jira'
118+
119+
// Define the prioritized order of keys to check
120+
const potentialKeys = [
121+
shortKey,
122+
atlassianProductKey,
123+
fullPackageName,
124+
unscopedPackageName,
125+
];
126+
let foundConfigSection: {
127+
environments?: Record<string, unknown>;
128+
} | null = null;
129+
let usedKey: string | null = null;
130+
131+
for (const key of potentialKeys) {
132+
if (
133+
config[key] &&
134+
typeof config[key] === 'object' &&
135+
config[key].environments
136+
) {
137+
foundConfigSection = config[key];
138+
usedKey = key;
139+
methodLogger.debug(
140+
`[src/utils/config.util.ts@loadFromGlobalConfig] Found configuration using key: ${key}`,
141+
);
142+
break; // Stop once found
143+
}
144+
}
145+
146+
if (!foundConfigSection || !foundConfigSection.environments) {
116147
methodLogger.debug(
117-
`[src/utils/config.util.ts@loadFromGlobalConfig] No configuration found for ${this.packageName}`,
148+
`[src/utils/config.util.ts@loadFromGlobalConfig] No configuration found for ${
149+
this.packageName
150+
} using keys: ${potentialKeys.join(', ')}`,
118151
);
119152
return;
120153
}
121154

122-
const environments = config[this.packageName].environments;
155+
const environments = foundConfigSection.environments;
123156
for (const [key, value] of Object.entries(environments)) {
124157
// Only set if not already defined in process.env
125158
if (process.env[key] === undefined) {
@@ -128,7 +161,7 @@ class ConfigLoader {
128161
}
129162

130163
methodLogger.debug(
131-
'[src/utils/config.util.ts@loadFromGlobalConfig] Loaded configuration from global config file',
164+
`[src/utils/config.util.ts@loadFromGlobalConfig] Loaded configuration from global config file using key: ${usedKey}`,
132165
);
133166
} catch (error) {
134167
methodLogger.error(

0 commit comments

Comments
 (0)