Skip to content

Commit c21d8cf

Browse files
committed
feat: add getResource tool to retrieve life resource manifest
Signed-off-by: Alexander Matyushentsev <[email protected]>
1 parent 08f48ef commit c21d8cf

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

src/argocd/client.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import {
66
V1EventList,
77
V1alpha1ResourceAction,
88
V1alpha1ResourceDiff,
9-
V1alpha1ResourceResult
9+
V1alpha1ResourceResult,
10+
V1alpha1ApplicationResourceResult
1011
} from '../types/argocd-types.js';
1112
import { HttpClient } from './http.js';
1213

@@ -238,6 +239,25 @@ export class ArgoCDClient {
238239
return body;
239240
}
240241

242+
public async getResource(
243+
applicationName: string,
244+
applicationNamespace: string,
245+
resourceRef: V1alpha1ResourceResult
246+
) {
247+
const { body } = await this.client.get<V1alpha1ApplicationResourceResult>(
248+
`/api/v1/applications/${applicationName}/resource`,
249+
{
250+
appNamespace: applicationNamespace,
251+
namespace: resourceRef.namespace,
252+
resourceName: resourceRef.name,
253+
group: resourceRef.group,
254+
kind: resourceRef.kind,
255+
version: resourceRef.version
256+
}
257+
);
258+
return body.manifest;
259+
}
260+
241261
public async getResourceEvents(
242262
applicationName: string,
243263
applicationNamespace: string,

src/server/server.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,17 @@ export class Server extends McpServer {
164164
resourceName
165165
)
166166
);
167+
this.addJsonOutputTool(
168+
'get_resource',
169+
'get_resource returns manifest of a kubernetes resources that belongs to an application',
170+
{
171+
applicationName: z.string(),
172+
applicationNamespace: ApplicationNamespaceSchema,
173+
resourceRef: ResourceRefSchema
174+
},
175+
async ({ applicationName, applicationNamespace, resourceRef }) =>
176+
await this.argocdClient.getResource(applicationName, applicationNamespace, resourceRef)
177+
);
167178
this.addJsonOutputTool(
168179
'get_resource_actions',
169180
'get_resource_actions returns actions for a resource that is managed by an application',

src/types/argocd-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ export type V1EventList = ArgoCD.V1EventList;
1010
export type V1alpha1ResourceAction = ArgoCD.V1alpha1ResourceAction;
1111
export type V1alpha1ResourceDiff = ArgoCD.V1alpha1ResourceDiff;
1212
export type V1alpha1ResourceResult = ArgoCD.V1alpha1ResourceResult;
13+
export type V1alpha1ApplicationResourceResult = ArgoCD.ApplicationApplicationResourceResponse;

0 commit comments

Comments
 (0)