Skip to content

Commit 9f91ca8

Browse files
authored
Merge branch 'main' into dependabot/npm_and_yarn/npm_and_yarn-6ea9762674
2 parents b9d01f5 + ea9c071 commit 9f91ca8

File tree

5 files changed

+142
-70
lines changed

5 files changed

+142
-70
lines changed

.github/workflows/release.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
types:
66
- published
77

8+
permissions:
9+
id-token: write
10+
contents: read
11+
812
jobs:
913
release:
1014
if: startsWith(github.ref, 'refs/tags/v')
@@ -29,4 +33,4 @@ jobs:
2933
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
3034
VERSION=${GITHUB_REF#refs/tags/v}
3135
npm version $VERSION --no-git-tag-version
32-
npm publish --access public
36+
npm publish --provenance --access public

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,6 @@ dist
140140

141141
# ide
142142
.idea/
143+
144+
# claude code
145+
CLAUDE.md

README.md

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,26 @@ Akuity is the enterprise company for Argo and Kargo, and provides the essential
3939
- **Complete Argo CD API Integration**: Provides comprehensive access to Argo CD resources and operations
4040
- **AI Assistant Ready**: Pre-configured tools for AI assistants to interact with Argo CD in natural language
4141

42+
## Available Tools
43+
44+
The server provides the following ArgoCD management tools:
45+
46+
### Application Management
47+
- `list_applications`: List and filter all applications
48+
- `get_application`: Get detailed information about a specific application
49+
- `create_application`: Create a new application
50+
- `update_application`: Update an existing application
51+
- `delete_application`: Delete an application
52+
- `sync_application`: Trigger a sync operation on an application
53+
54+
### Resource Management
55+
- `get_application_resource_tree`: Get the resource tree for a specific application
56+
- `get_application_managed_resources`: Get managed resources for a specific application
57+
- `get_application_workload_logs`: Get logs for application workloads (Pods, Deployments, etc.)
58+
- `get_resource_events`: Get events for resources managed by an application
59+
- `get_resource_actions`: Get available actions for resources
60+
- `run_resource_action`: Run an action on a resource
61+
4262
## Installation
4363

4464
### Prerequisites
@@ -129,25 +149,21 @@ This disables TLS certificate validation for Node.js when connecting to Argo CD
129149

130150
> **Warning**: Disabling SSL verification reduces security. Use this setting only in development environments or when you understand the security implications.
131151
132-
## Available Tools
133-
134-
The server provides the following ArgoCD management tools:
135152

136-
### Application Management
137-
- `list_applications`: List and filter all applications
138-
- `get_application`: Get detailed information about a specific application
139-
- `create_application`: Create a new application
140-
- `update_application`: Update an existing application
141-
- `delete_application`: Delete an application
142-
- `sync_application`: Trigger a sync operation on an application
153+
### Read Only Mode
143154

144-
### Resource Management
145-
- `get_application_resource_tree`: Get the resource tree for a specific application
146-
- `get_application_managed_resources`: Get managed resources for a specific application
147-
- `get_application_workload_logs`: Get logs for application workloads (Pods, Deployments, etc.)
148-
- `get_resource_events`: Get events for resources managed by an application
149-
- `get_resource_actions`: Get available actions for resources
150-
- `run_resource_action`: Run an action on a resource
155+
If you want to run the MCP Server in a ReadOnly mode to avoid resource or application modification, you should set the environment variable:
156+
```
157+
"MCP_READ_ONLY": "true"
158+
```
159+
This will disable the following tools:
160+
- `create_application`
161+
- `update_application`
162+
- `delete_application`
163+
- `sync_application`
164+
- `run_resource_action`
165+
166+
By default, all the tools will be available.
151167

152168
## For Development
153169

src/argocd/client.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,21 @@ export class ArgoCDClient {
7272
return body;
7373
}
7474

75-
public async getApplicationManagedResources(applicationName: string) {
75+
public async getApplicationManagedResources(
76+
applicationName: string,
77+
filters?: {
78+
namespace?: string;
79+
name?: string;
80+
version?: string;
81+
group?: string;
82+
kind?: string;
83+
appNamespace?: string;
84+
project?: string;
85+
}
86+
) {
7687
const { body } = await this.client.get<{ items: V1alpha1ResourceDiff[] }>(
77-
`/api/v1/applications/${applicationName}/managed-resources`
88+
`/api/v1/applications/${applicationName}/managed-resources`,
89+
filters
7890
);
7991
return body;
8092
}

src/server/server.ts

Lines changed: 87 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ export class Server extends McpServer {
2525
});
2626
this.argocdClient = new ArgoCDClient(serverInfo.argocdBaseUrl, serverInfo.argocdApiToken);
2727

28+
const isReadOnly =
29+
String(process.env.MCP_READ_ONLY ?? '')
30+
.trim()
31+
.toLowerCase() === 'true';
32+
33+
// Always register read/query tools
2834
this.addJsonOutputTool(
2935
'list_applications',
3036
'list_applications returns list of applications',
@@ -45,35 +51,6 @@ export class Server extends McpServer {
4551
{ applicationName: z.string() },
4652
async ({ applicationName }) => await this.argocdClient.getApplication(applicationName)
4753
);
48-
this.addJsonOutputTool(
49-
'create_application',
50-
'create_application creates application',
51-
{ application: ApplicationSchema },
52-
async ({ application }) =>
53-
await this.argocdClient.createApplication(application as V1alpha1Application)
54-
);
55-
this.addJsonOutputTool(
56-
'update_application',
57-
'update_application updates application',
58-
{ applicationName: z.string(), application: ApplicationSchema },
59-
async ({ applicationName, application }) =>
60-
await this.argocdClient.updateApplication(
61-
applicationName,
62-
application as V1alpha1Application
63-
)
64-
);
65-
this.addJsonOutputTool(
66-
'delete_application',
67-
'delete_application deletes application',
68-
{ applicationName: z.string() },
69-
async ({ applicationName }) => await this.argocdClient.deleteApplication(applicationName)
70-
);
71-
this.addJsonOutputTool(
72-
'sync_application',
73-
'sync_application syncs application',
74-
{ applicationName: z.string() },
75-
async ({ applicationName }) => await this.argocdClient.syncApplication(applicationName)
76-
);
7754
this.addJsonOutputTool(
7855
'get_application_resource_tree',
7956
'get_application_resource_tree returns resource tree for application by application name',
@@ -83,10 +60,37 @@ export class Server extends McpServer {
8360
);
8461
this.addJsonOutputTool(
8562
'get_application_managed_resources',
86-
'get_application_managed_resources returns managed resources for application by application name',
87-
{ applicationName: z.string() },
88-
async ({ applicationName }) =>
89-
await this.argocdClient.getApplicationManagedResources(applicationName)
63+
'get_application_managed_resources returns managed resources for application by application name with optional filtering. Use filters to avoid token limits with large applications. Examples: kind="ConfigMap" for config maps only, namespace="production" for specific namespace, or combine multiple filters.',
64+
{
65+
applicationName: z.string(),
66+
kind: z
67+
.string()
68+
.optional()
69+
.describe(
70+
'Filter by Kubernetes resource kind (e.g., "ConfigMap", "Secret", "Deployment")'
71+
),
72+
namespace: z.string().optional().describe('Filter by Kubernetes namespace'),
73+
name: z.string().optional().describe('Filter by resource name'),
74+
version: z.string().optional().describe('Filter by resource API version'),
75+
group: z.string().optional().describe('Filter by API group'),
76+
appNamespace: z.string().optional().describe('Filter by Argo CD application namespace'),
77+
project: z.string().optional().describe('Filter by Argo CD project')
78+
},
79+
async ({ applicationName, kind, namespace, name, version, group, appNamespace, project }) => {
80+
const filters = {
81+
...(kind && { kind }),
82+
...(namespace && { namespace }),
83+
...(name && { name }),
84+
...(version && { version }),
85+
...(group && { group }),
86+
...(appNamespace && { appNamespace }),
87+
...(project && { project })
88+
};
89+
return await this.argocdClient.getApplicationManagedResources(
90+
applicationName,
91+
Object.keys(filters).length > 0 ? filters : undefined
92+
);
93+
}
9094
);
9195
this.addJsonOutputTool(
9296
'get_application_workload_logs',
@@ -149,23 +153,56 @@ export class Server extends McpServer {
149153
resourceRef as V1alpha1ResourceResult
150154
)
151155
);
152-
this.addJsonOutputTool(
153-
'run_resource_action',
154-
'run_resource_action runs an action on a resource',
155-
{
156-
applicationName: z.string(),
157-
applicationNamespace: ApplicationNamespaceSchema,
158-
resourceRef: ResourceRefSchema,
159-
action: z.string()
160-
},
161-
async ({ applicationName, applicationNamespace, resourceRef, action }) =>
162-
await this.argocdClient.runResourceAction(
163-
applicationName,
164-
applicationNamespace,
165-
resourceRef as V1alpha1ResourceResult,
166-
action
167-
)
168-
);
156+
157+
// Only register modification tools if not in read-only mode
158+
if (!isReadOnly) {
159+
this.addJsonOutputTool(
160+
'create_application',
161+
'create_application creates application',
162+
{ application: ApplicationSchema },
163+
async ({ application }) =>
164+
await this.argocdClient.createApplication(application as V1alpha1Application)
165+
);
166+
this.addJsonOutputTool(
167+
'update_application',
168+
'update_application updates application',
169+
{ applicationName: z.string(), application: ApplicationSchema },
170+
async ({ applicationName, application }) =>
171+
await this.argocdClient.updateApplication(
172+
applicationName,
173+
application as V1alpha1Application
174+
)
175+
);
176+
this.addJsonOutputTool(
177+
'delete_application',
178+
'delete_application deletes application',
179+
{ applicationName: z.string() },
180+
async ({ applicationName }) => await this.argocdClient.deleteApplication(applicationName)
181+
);
182+
this.addJsonOutputTool(
183+
'sync_application',
184+
'sync_application syncs application',
185+
{ applicationName: z.string() },
186+
async ({ applicationName }) => await this.argocdClient.syncApplication(applicationName)
187+
);
188+
this.addJsonOutputTool(
189+
'run_resource_action',
190+
'run_resource_action runs an action on a resource',
191+
{
192+
applicationName: z.string(),
193+
applicationNamespace: ApplicationNamespaceSchema,
194+
resourceRef: ResourceRefSchema,
195+
action: z.string()
196+
},
197+
async ({ applicationName, applicationNamespace, resourceRef, action }) =>
198+
await this.argocdClient.runResourceAction(
199+
applicationName,
200+
applicationNamespace,
201+
resourceRef as V1alpha1ResourceResult,
202+
action
203+
)
204+
);
205+
}
169206
}
170207

171208
private addJsonOutputTool<Args extends ZodRawShape, T>(

0 commit comments

Comments
 (0)