Skip to content

Conversation

csz-akuity
Copy link
Contributor

Intended to reduce to amount of tokens used by the list_applications tool.
Related to #59

Add Pagination with Limits/Offsets:

# Example prompts 
List 5 applications to get a quick overview
Search for "frontend" apps, limit to 3 results

Strip manifest fields:

const strippedItems = body.items?.map((app) => ({
  metadata: {
    name: app.metadata?.name,              // ✅ Keep
    namespace: app.metadata?.namespace,    // ✅ Keep
    labels: app.metadata?.labels,          // ✅ Keep
    creationTimestamp: app.metadata?.creationTimestamp  // ✅ Keep
    // ❌ managedFields - REMOVED (1000-3000 tokens)
    // ❌ resourceVersion - REMOVED
    // ❌ uid - REMOVED
    // ❌ ownerReferences - REMOVED
    // ❌ finalizers - REMOVED
  },
  spec: {
    project: app.spec?.project,      // ✅ Keep
    source: app.spec?.source,        // ✅ Keep
    destination: app.spec?.destination  // ✅ Keep
    // ❌ syncPolicy - REMOVED
    // ❌ revisionHistoryLimit - REMOVED
    // ❌ ignoreDifferences - REMOVED
  },
  status: {
    sync: app.status?.sync,      // ✅ Keep
    health: app.status?.health,  // ✅ Keep
    summary: app.status?.summary // ✅ Keep
    // ❌ history - REMOVED (100+ entries)
    // ❌ conditions - REMOVED
    // ❌ resources - REMOVED (full manifests!)
    // ❌ operationState - REMOVED
  }
})) ?? [];

alexmt and others added 2 commits October 7, 2025 14:28
* remove akuity reference

Signed-off-by: Alexander Matyushentsev <[email protected]>

* remove akuity references

Signed-off-by: Alexander Matyushentsev <[email protected]>

---------

Signed-off-by: Alexander Matyushentsev <[email protected]>
Signed-off-by: Cristina Szumilo <[email protected]>
@csz-akuity csz-akuity force-pushed the csz/optimize-list-apps-tokens branch from b6c24b0 to cfff6b5 Compare October 7, 2025 21:29
Copy link
Contributor

@alexmt alexmt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you @csz-akuity !

FYI, we could reduce amount of traffic between mcp server and argocd as well using fields query parameter. E.g. following request should return only resourceVersion, metadata.name, metadata.annotations, and metadata.labels fields:

/api/v1/applications?fields=metadata.resourceVersion,items.metadata.name,items.metadata.namespace,items.metadata.annotations,items.metadata.labels

@alexmt
Copy link
Contributor

alexmt commented Oct 8, 2025

Lint failed. Please run pnpm lint --fix to fix linter errors.

Signed-off-by: Cristina Szumilo <[email protected]>
@alexmt alexmt merged commit 479abda into argoproj-labs:main Oct 8, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants