Skip to content

Commit c109e94

Browse files
authored
fix: add more description to application namespace to prompt the ai (#12)
* try to improve description * add namespace schema
1 parent 968dab9 commit c109e94

File tree

2 files changed

+25
-29
lines changed

2 files changed

+25
-29
lines changed

src/server/server.ts

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import packageJSON from '../../package.json' with { type: 'json' };
44
import { ArgoCDClient } from '../argocd/client.js';
55
import { z, ZodRawShape } from 'zod';
66
import { Application, ResourceRef } from '../shared/models/models.js';
7-
import { ApplicationSchema, ResourceRefSchema } from '../shared/models/schema.js';
7+
import {
8+
ApplicationNamespaceSchema,
9+
ApplicationSchema,
10+
ResourceRefSchema
11+
} from '../shared/models/schema.js';
812

913
type ServerInfo = {
1014
argocdBaseUrl: string;
@@ -80,11 +84,7 @@ export class Server extends McpServer {
8084
'get_application_workload_logs returns logs for application workload (Deployment, StatefulSet, Pod, etc.) by application name and resource ref',
8185
{
8286
applicationName: z.string(),
83-
applicationNamespace: z
84-
.string()
85-
.describe(
86-
'Namespace of the application, note the namespace is not always the same as the resource namespace'
87-
),
87+
applicationNamespace: ApplicationNamespaceSchema,
8888
resourceRef: ResourceRefSchema
8989
},
9090
async ({ applicationName, applicationNamespace, resourceRef }) =>
@@ -105,11 +105,7 @@ export class Server extends McpServer {
105105
'get_resource_events returns events for a resource that is managed by an application',
106106
{
107107
applicationName: z.string(),
108-
applicationNamespace: z
109-
.string()
110-
.describe(
111-
'Namespace of the application, note the namespace is not always the same as the resource namespace'
112-
),
108+
applicationNamespace: ApplicationNamespaceSchema,
113109
resourceUID: z.string(),
114110
resourceNamespace: z.string(),
115111
resourceName: z.string()
@@ -134,11 +130,7 @@ export class Server extends McpServer {
134130
'get_resource_actions returns actions for a resource that is managed by an application',
135131
{
136132
applicationName: z.string(),
137-
applicationNamespace: z
138-
.string()
139-
.describe(
140-
'Namespace of the application, note the namespace is not always the same as the resource namespace'
141-
),
133+
applicationNamespace: ApplicationNamespaceSchema,
142134
resourceRef: ResourceRefSchema
143135
},
144136
async ({ applicationName, applicationNamespace, resourceRef }) =>
@@ -153,11 +145,7 @@ export class Server extends McpServer {
153145
'run_resource_action runs an action on a resource',
154146
{
155147
applicationName: z.string(),
156-
applicationNamespace: z
157-
.string()
158-
.describe(
159-
'Namespace of the application, note the namespace is not always the same as the resource namespace'
160-
),
148+
applicationNamespace: ApplicationNamespaceSchema,
161149
resourceRef: ResourceRefSchema,
162150
action: z.string()
163151
},

src/shared/models/schema.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
import { z } from 'zod';
22

3+
export const ApplicationNamespaceSchema = z
4+
.string()
5+
.describe(
6+
`The namespace of the application.
7+
Note that this may differ from the namespace of individual resources.
8+
Make sure to verify the application namespace in the Application resource — it is often argocd, but not always.`
9+
);
10+
311
export const ResourceRefSchema = z.object({
412
uid: z.string(),
513
kind: z.string(),
@@ -11,7 +19,8 @@ export const ResourceRefSchema = z.object({
1119

1220
export const ApplicationSchema = z.object({
1321
metadata: z.object({
14-
name: z.string()
22+
name: z.string(),
23+
namespace: ApplicationNamespaceSchema
1524
}),
1625
spec: z.object({
1726
project: z.string(),
@@ -24,18 +33,17 @@ export const ApplicationSchema = z.object({
2433
syncOptions: z.array(z.string()),
2534
automated: z.object({
2635
prune: z.boolean(),
27-
selfHeal: z.boolean()
28-
})
29-
.optional(),
36+
selfHeal: z.boolean()
37+
}).optional(),
3038
retry: z
3139
.object({
3240
limit: z.number(),
3341
backoff: z.object({
34-
duration: z.string(),
35-
maxDuration: z.string(),
36-
factor: z.number()
42+
duration: z.string(),
43+
maxDuration: z.string(),
44+
factor: z.number()
45+
})
3746
})
38-
})
3947
}),
4048
destination: z.object({
4149
server: z.string(),

0 commit comments

Comments
 (0)