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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ const urlForGithub = `https://insiders.vscode.dev/redirect?url=${encodeURICompon

The server provides the following ArgoCD management tools:

### Cluster Management
- `list_clusters`: List all clusters registered with ArgoCD

### Application Management
- `list_applications`: List and filter all applications
- `get_application`: Get detailed information about a specific application
Expand Down
16 changes: 15 additions & 1 deletion src/argocd/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
V1alpha1ResourceAction,
V1alpha1ResourceDiff,
V1alpha1ResourceResult,
V1alpha1ApplicationResourceResult
V1alpha1ApplicationResourceResult,
V1alpha1ClusterList
} from '../types/argocd-types.js';
import { HttpClient } from './http.js';

Expand Down Expand Up @@ -65,6 +66,19 @@ export class ArgoCDClient {
};
}

public async listClusters(params?: { server?: string; name?: string }) {
const queryParams: Record<string, string> = {};
if (params?.server) queryParams.server = params.server;
if (params?.name) queryParams.name = params.name;

const { body } = await this.client.get<V1alpha1ClusterList>(
`/api/v1/clusters`,
Object.keys(queryParams).length > 0 ? queryParams : undefined
);

return body;
}

public async getApplication(applicationName: string, appNamespace?: string) {
const queryParams = appNamespace ? { appNamespace } : undefined;
const { body } = await this.client.get<V1alpha1Application>(
Expand Down
19 changes: 19 additions & 0 deletions src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,25 @@ export class Server extends McpServer {
offset
})
);
this.addJsonOutputTool(
'list_clusters',
'list_clusters returns list of clusters registered with ArgoCD',
{
server: z
.string()
.optional()
.describe('Filter clusters by server URL. Optional.'),
name: z
.string()
.optional()
.describe('Filter clusters by name. Optional.')
},
async ({ server, name }) =>
await this.argocdClient.listClusters({
server: server ?? undefined,
name: name ?? undefined
})
);
this.addJsonOutputTool(
'get_application',
'get_application returns application by application name. Optionally specify the application namespace to get applications from non-default namespaces.',
Expand Down
2 changes: 2 additions & 0 deletions src/types/argocd-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ export type V1alpha1ResourceAction = ArgoCD.V1alpha1ResourceAction;
export type V1alpha1ResourceDiff = ArgoCD.V1alpha1ResourceDiff;
export type V1alpha1ResourceResult = ArgoCD.V1alpha1ResourceResult;
export type V1alpha1ApplicationResourceResult = ArgoCD.ApplicationApplicationResourceResponse;
export type V1alpha1Cluster = ArgoCD.V1alpha1Cluster;
export type V1alpha1ClusterList = ArgoCD.V1alpha1ClusterList;