Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 23 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,50 +86,37 @@ The server provides the following ArgoCD management tools:

### Usage with VSCode

1. Follow the [Use MCP servers in VS Code documentation](https://code.visualstudio.com/docs/copilot/chat/mcp-servers), and create a `.vscode/mcp.json` file in your project:
```json
{
"servers": {
"argocd-mcp-stdio": {
"type": "stdio",
"command": "npx",
"args": [
"argocd-mcp@latest",
"stdio"
],
"env": {
"ARGOCD_BASE_URL": "<argocd_url>",
"ARGOCD_API_TOKEN": "<argocd_token>"
}
}
}
}
1. Enable the ArgoCD MCP server in VS Code:
```bash
npx argocd-mcp@latest vscode enable --url <argocd_url> --token <argocd_token>
```

Optionally, use the `--workspace` flag to install in the current workspace directory instead of the user configuration directory.

You can also set the `ARGOCD_BASE_URL` and `ARGOCD_API_TOKEN` environment variables instead of using the `--url` and `--token` flags.

2. Start a conversation with an AI assistant in VS Code that supports MCP.

To disable the server, run:
```bash
npx argocd-mcp@latest vscode disable
```

### Usage with Claude Desktop

1. Follow the [MCP in Claude Desktop documentation](https://modelcontextprotocol.io/quickstart/user), and create a `claude_desktop_config.json` configuration file:
```json
{
"mcpServers": {
"argocd-mcp": {
"command": "npx",
"args": [
"argocd-mcp@latest",
"stdio"
],
"env": {
"ARGOCD_BASE_URL": "<argocd_url>",
"ARGOCD_API_TOKEN": "<argocd_token>"
}
}
}
}
1. Enable the ArgoCD MCP server in Claude Desktop:
```bash
npx argocd-mcp@latest claude enable --url <argocd_url> --token <argocd_token>
```

2. Configure Claude Desktop to use this configuration file in settings.
You can also set the `ARGOCD_BASE_URL` and `ARGOCD_API_TOKEN` environment variables instead of using the `--url` and `--token` flags.

2. Restart Claude Desktop to load the configuration.

To disable the server, run:
```bash
npx argocd-mcp@latest claude disable
```

### Self-signed Certificates

Expand Down
218 changes: 217 additions & 1 deletion src/cmd/cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import {
connectHttpTransport,
connectSSETransport
} from '../server/transport.js';
import { ClaudeConfigManager } from '../platform/claude/config.js';
import { VSCodeConfigManager } from '../platform/vscode/config.js';
import { CursorConfigManager } from '../platform/cursor/config.js';

export const cmd = () => {
const exe = yargs(hideBin(process.argv));
Expand Down Expand Up @@ -40,5 +43,218 @@ export const cmd = () => {
({ port }) => connectHttpTransport(port)
);

exe.demandCommand().parseSync();
const validateUrl = (baseUrl?: string) => {
// MCP servers do not have access to local env, it must be set in config
// If flag was not set, fallback to env
if (!baseUrl) {
baseUrl = process.env.ARGOCD_BASE_URL;
if (!baseUrl) {
throw new Error(
'Argocd baseurl not provided and not in env, please provide it with the --url flag'
);
}
}

// Validate url
new URL(baseUrl);

return baseUrl;
};

const validateToken = (apiToken?: string) => {
// MCP servers do not have access to local env, it must be set in config
// If flag was not set, fallback to env
if (!apiToken) {
apiToken = process.env.ARGOCD_API_TOKEN;
if (!apiToken) {
throw new Error(
'Argocd token not provided and not in env, please provide it with the --token flag'
);
}
}

return apiToken;
};

exe.command('claude', 'Manage Claude Desktop integration', (yargs) => {
return yargs
.command(
'enable',
'Enable ArgoCD MCP server in Claude Desktop',
(yargs) => {
return yargs
.option('url', {
type: 'string',
description: 'ArgoCD base URL (falls back to ARGOCD_BASE_URL env var)'
})
.option('token', {
type: 'string',
description: 'ArgoCD API token (falls back to ARGOCD_API_TOKEN env var)'
});
},
async ({ url, token }) => {
const manager = new ClaudeConfigManager();
try {
console.log(`Configuration file: ${manager.getConfigPath()}`);
const wasEnabled = await manager.enable(validateUrl(url), validateToken(token));
if (wasEnabled) {
console.log('✓ ArgoCD MCP server configuration updated in Claude Desktop');
} else {
console.log('✓ ArgoCD MCP server enabled in Claude Desktop');
}
} catch (error) {
console.error('Failed to enable ArgoCD MCP server:', (error as Error).message);
process.exit(1);
}
}
)
.command(
'disable',
'Disable ArgoCD MCP server in Claude Desktop',
() => {},
async () => {
const manager = new ClaudeConfigManager();
try {
console.log(`Configuration file: ${manager.getConfigPath()}`);
const wasEnabled = await manager.disable();
if (wasEnabled) {
console.log('✓ ArgoCD MCP server disabled in Claude Desktop');
} else {
console.log('ArgoCD MCP server was not enabled');
}
} catch (error) {
console.error('Failed to disable ArgoCD MCP server:', (error as Error).message);
process.exit(1);
}
}
);
});

exe.command('cursor', 'Manage Cursor integration', (yargs) => {
return yargs
.command(
'enable',
'Enable ArgoCD MCP server in Cursor',
(yargs) => {
return yargs
.option('workspace', {
type: 'boolean',
description: 'Install in current workspace directory'
})
.option('url', {
type: 'string',
description: 'ArgoCD base URL (falls back to ARGOCD_BASE_URL env var)'
})
.option('token', {
type: 'string',
description: 'ArgoCD API token (falls back to ARGOCD_API_TOKEN env var)'
});
},
async ({ workspace, url, token }) => {
const manager = new CursorConfigManager(workspace);
try {
console.log(`Configuration file: ${manager.getConfigPath()}`);
const wasEnabled = await manager.enable(validateUrl(url), validateToken(token));
if (wasEnabled) {
console.log('✓ ArgoCD MCP server configuration updated in Cursor');
} else {
console.log('✓ ArgoCD MCP server enabled in Cursor');
}
} catch (error) {
console.error('Failed to enable ArgoCD MCP server:', (error as Error).message);
process.exit(1);
}
}
)
.command(
'disable',
'Disable ArgoCD MCP server in Cursor',
(yargs) => {
return yargs.option('workspace', {
type: 'boolean',
description: 'Install in current workspace directory'
});
},
async ({ workspace }) => {
const manager = new CursorConfigManager(workspace);
try {
console.log(`Configuration file: ${manager.getConfigPath()}`);
const wasEnabled = await manager.disable();
if (wasEnabled) {
console.log('✓ ArgoCD MCP server disabled in Cursor');
} else {
console.log('ArgoCD MCP server was not enabled');
}
} catch (error) {
console.error('Failed to disable ArgoCD MCP server:', (error as Error).message);
process.exit(1);
}
}
);
});

exe.command('vscode', 'Manage VS Code integration', (yargs) => {
return yargs
.command(
'enable',
'Enable ArgoCD MCP server in VS Code',
(yargs) => {
return yargs
.option('workspace', {
type: 'boolean',
description: 'Install in current workspace directory'
})
.option('url', {
type: 'string',
description: 'ArgoCD base URL (falls back to ARGOCD_BASE_URL env var)'
})
.option('token', {
type: 'string',
description: 'ArgoCD API token (falls back to ARGOCD_API_TOKEN env var)'
});
},
async ({ workspace, url, token }) => {
const manager = new VSCodeConfigManager(workspace);
try {
console.log(`Configuration file: ${manager.getConfigPath()}`);
const wasEnabled = await manager.enable(validateUrl(url), validateToken(token));
if (wasEnabled) {
console.log('✓ ArgoCD MCP server configuration updated in VS Code');
} else {
console.log('✓ ArgoCD MCP server enabled in VS Code');
}
} catch (error) {
console.error('Failed to enable ArgoCD MCP server:', (error as Error).message);
process.exit(1);
}
}
)
.command(
'disable',
'Disable ArgoCD MCP server in VS Code',
(yargs) => {
return yargs.option('workspace', {
type: 'boolean',
description: 'Install in current workspace directory'
});
},
async ({ workspace }) => {
const manager = new VSCodeConfigManager(workspace);
try {
console.log(`Configuration file: ${manager.getConfigPath()}`);
const wasEnabled = await manager.disable();
if (wasEnabled) {
console.log('✓ ArgoCD MCP server disabled in VS Code');
} else {
console.log('ArgoCD MCP server was not enabled');
}
} catch (error) {
console.error('Failed to disable ArgoCD MCP server:', (error as Error).message);
process.exit(1);
}
}
);
});

exe.demandCommand().strict().parse();
};
Loading