Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,22 @@ This disables TLS certificate validation for Node.js when connecting to Argo CD

> **Warning**: Disabling SSL verification reduces security. Use this setting only in development environments or when you understand the security implications.


### Read Only Mode

If you want to run the MCP Server in a ReadOnly mode to avoid resource or application modification, you should set the environment variable:
```
"MCP_READ_ONLY": "true"
```
This will disable the following tools:
- `create_application`
- `update_application`
- `delete_application`
- `sync_application`
- `run_resource_action`

By default, all the tools will be available.

## Available Tools

The server provides the following ArgoCD management tools:
Expand Down
99 changes: 53 additions & 46 deletions src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
});
this.argocdClient = new ArgoCDClient(serverInfo.argocdBaseUrl, serverInfo.argocdApiToken);

const isReadOnly = String(process.env.MCP_READ_ONLY ?? '').trim().toLowerCase() === 'true';

Check failure on line 28 in src/server/server.ts

View workflow job for this annotation

GitHub Actions / build

Replace `·String(process.env.MCP_READ_ONLY·??·'').trim()` with `⏎······String(process.env.MCP_READ_ONLY·??·'')⏎········.trim()⏎········`

// Always register read/query tools
this.addJsonOutputTool(
'list_applications',
'list_applications returns list of applications',
Expand All @@ -45,35 +48,6 @@
{ applicationName: z.string() },
async ({ applicationName }) => await this.argocdClient.getApplication(applicationName)
);
this.addJsonOutputTool(
'create_application',
'create_application creates application',
{ application: ApplicationSchema },
async ({ application }) =>
await this.argocdClient.createApplication(application as V1alpha1Application)
);
this.addJsonOutputTool(
'update_application',
'update_application updates application',
{ applicationName: z.string(), application: ApplicationSchema },
async ({ applicationName, application }) =>
await this.argocdClient.updateApplication(
applicationName,
application as V1alpha1Application
)
);
this.addJsonOutputTool(
'delete_application',
'delete_application deletes application',
{ applicationName: z.string() },
async ({ applicationName }) => await this.argocdClient.deleteApplication(applicationName)
);
this.addJsonOutputTool(
'sync_application',
'sync_application syncs application',
{ applicationName: z.string() },
async ({ applicationName }) => await this.argocdClient.syncApplication(applicationName)
);
this.addJsonOutputTool(
'get_application_resource_tree',
'get_application_resource_tree returns resource tree for application by application name',
Expand Down Expand Up @@ -176,23 +150,56 @@
resourceRef as V1alpha1ResourceResult
)
);
this.addJsonOutputTool(
'run_resource_action',
'run_resource_action runs an action on a resource',
{
applicationName: z.string(),
applicationNamespace: ApplicationNamespaceSchema,
resourceRef: ResourceRefSchema,
action: z.string()
},
async ({ applicationName, applicationNamespace, resourceRef, action }) =>
await this.argocdClient.runResourceAction(
applicationName,
applicationNamespace,
resourceRef as V1alpha1ResourceResult,
action
)
);

// Only register modification tools if not in read-only mode
if (!isReadOnly) {
this.addJsonOutputTool(
'create_application',
'create_application creates application',
{ application: ApplicationSchema },
async ({ application }) =>
await this.argocdClient.createApplication(application as V1alpha1Application)
);
this.addJsonOutputTool(
'update_application',
'update_application updates application',
{ applicationName: z.string(), application: ApplicationSchema },
async ({ applicationName, application }) =>
await this.argocdClient.updateApplication(
applicationName,
application as V1alpha1Application
)
);
this.addJsonOutputTool(
'delete_application',
'delete_application deletes application',
{ applicationName: z.string() },
async ({ applicationName }) => await this.argocdClient.deleteApplication(applicationName)
);
this.addJsonOutputTool(
'sync_application',
'sync_application syncs application',
{ applicationName: z.string() },
async ({ applicationName }) => await this.argocdClient.syncApplication(applicationName)
);
this.addJsonOutputTool(
'run_resource_action',
'run_resource_action runs an action on a resource',
{
applicationName: z.string(),
applicationNamespace: ApplicationNamespaceSchema,
resourceRef: ResourceRefSchema,
action: z.string()
},
async ({ applicationName, applicationNamespace, resourceRef, action }) =>
await this.argocdClient.runResourceAction(
applicationName,
applicationNamespace,
resourceRef as V1alpha1ResourceResult,
action
)
);
}
}

private addJsonOutputTool<Args extends ZodRawShape, T>(
Expand Down
Loading