Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
44 changes: 41 additions & 3 deletions src/argocd/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,47 @@ export class ArgoCDClient {
this.client = new HttpClient(this.baseUrl, this.apiToken);
}

public async listApplications(params?: { search?: string }) {
const { body } = await this.client.get<V1alpha1ApplicationList>(`/api/v1/applications`, params);
return body;
public async listApplications(params?: { search?: string; limit?: number; offset?: number }) {
const { body } = await this.client.get<V1alpha1ApplicationList>(
`/api/v1/applications`,
params?.search ? { search: params.search } : undefined
);

// Strip heavy fields to reduce token usage
const strippedItems =
body.items?.map((app) => ({
metadata: {
name: app.metadata?.name,
namespace: app.metadata?.namespace,
labels: app.metadata?.labels,
creationTimestamp: app.metadata?.creationTimestamp
},
spec: {
project: app.spec?.project,
source: app.spec?.source,
destination: app.spec?.destination
},
status: {
sync: app.status?.sync,
health: app.status?.health,
summary: app.status?.summary
}
})) ?? [];

// Apply pagination
const start = params?.offset ?? 0;
const end = params?.limit ? start + params.limit : strippedItems.length;
const items = strippedItems.slice(start, end);

return {
items,
metadata: {
resourceVersion: body.metadata?.resourceVersion,
totalItems: strippedItems.length,
returnedItems: items.length,
hasMore: end < strippedItems.length
}
};
}

public async getApplication(applicationName: string) {
Expand Down
24 changes: 22 additions & 2 deletions src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,30 @@ export class Server extends McpServer {
.optional()
.describe(
'Search applications by name. This is a partial match on the application name and does not support glob patterns (e.g. "*"). Optional.'
),
limit: z
.number()
.int()
.positive()
.optional()
.describe(
'Maximum number of applications to return. Use this to reduce token usage when there are many applications. Optional.'
),
offset: z
.number()
.int()
.min(0)
.optional()
.describe(
'Number of applications to skip before returning results. Use with limit for pagination. Optional.'
)
},
async ({ search }) =>
await this.argocdClient.listApplications({ search: search ?? undefined })
async ({ search, limit, offset }) =>
await this.argocdClient.listApplications({
search: search ?? undefined,
limit,
offset
})
);
this.addJsonOutputTool(
'get_application',
Expand Down