Skip to content

Commit 891f857

Browse files
authored
fix: improve prompts for create and list applications (#32)
* chore: update readme * fix: #27 * fix: #29 * revise comment
1 parent 149cf1a commit 891f857

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,17 +153,17 @@ pnpm run dev
153153
```
154154
Once the server is running, you can utilize the MCP server within Visual Studio Code or other MCP client.
155155

156-
## Upgrading ArgoCD Types
156+
### Upgrading ArgoCD Types
157157

158158
To update the TypeScript type definitions based on the latest Argo CD API specification:
159159

160-
1. Download the `swagger.json` file from the [ArgoCD release page](https://github.com/argoproj/argo-cd/releases), for example here is the [swagger.json link](https://github.com/argoproj/argo-cd/blob/v2.14.11/assets/swagger.json) for ArgoCD v2.14.11.
160+
1. Download the `swagger.json` file from the [ArgoCD release page](https://github.com/argoproj/argo-cd/releases), for example here is the [swagger.json link](https://github.com/argoproj/argo-cd/blob/v2.14.11/assets/swagger.json) for ArgoCD v2.14.11.
161161

162-
2. Place the downloaded `swagger.json` file in the root directory of the `argocd-mcp` project.
162+
2. Place the downloaded `swagger.json` file in the root directory of the `argocd-mcp` project.
163163

164-
3. Generate the TypeScript types from the Swagger definition by running the following command. This will create or overwrite the `src/types/argocd.d.ts` file:
164+
3. Generate the TypeScript types from the Swagger definition by running the following command. This will create or overwrite the `src/types/argocd.d.ts` file:
165165
```bash
166166
pnpm run generate-types
167167
```
168168

169-
4. Update the `src/types/argocd-types.ts` file to export the required types from the newly generated `src/types/argocd.d.ts`. This step often requires manual review to ensure only necessary types are exposed.
169+
4. Update the `src/types/argocd-types.ts` file to export the required types from the newly generated `src/types/argocd.d.ts`. This step often requires manual review to ensure only necessary types are exposed.

src/server/server.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ export class Server extends McpServer {
2929
'list_applications',
3030
'list_applications returns list of applications',
3131
{
32-
search: z.string().nullish().describe('Search applications by name, optional')
32+
search: z
33+
.string()
34+
.optional()
35+
.describe(
36+
'Search applications by name. This is a partial match on the application name and does not support glob patterns (e.g. "*"). Optional.'
37+
)
3338
},
3439
async ({ search }) =>
3540
await this.argocdClient.listApplications({ search: search ?? undefined })

src/shared/models/schema.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,20 @@ export const ApplicationSchema = z.object({
4646
})
4747
}),
4848
destination: z.object({
49-
server: z.string(),
50-
namespace: z.string(),
49+
server: z.string().optional(),
50+
namespace: z.string().optional(),
5151
name: z.string().optional()
5252
})
53+
.refine(
54+
data =>
55+
(!data.server && !!data.name) || (!!data.server && !data.name),
56+
{
57+
message: "Only one of server or name must be specified in destination"
58+
}
59+
)
60+
.describe(
61+
`The destination of the application.
62+
Only one of server or name must be specified.`
63+
)
5364
})
5465
});

0 commit comments

Comments
 (0)