Skip to content

feat: add count_resources aggregation tool#249

Open
yuvalk wants to merge 4 commits into
RHEcosystemAppEng:mainfrom
yuvalk:feat/aggregation-tool
Open

feat: add count_resources aggregation tool#249
yuvalk wants to merge 4 commits into
RHEcosystemAppEng:mainfrom
yuvalk:feat/aggregation-tool

Conversation

@yuvalk
Copy link
Copy Markdown
Collaborator

@yuvalk yuvalk commented May 26, 2026

Summary

  • Adds a count_resources FunctionTool — the first custom (non-MCP) tool in the agent — that efficiently answers "how many?" questions by calling MCP tools with limit=1 and reading the total count from response metadata, instead of the LLM iterating through all pages
  • Supports 13 MCP tools across 6 categories: vulnerability (meta.total_items), inventory (total), advisor/content-sources/image-builder/RHSM (meta.count)
  • Updates the pagination-handling skill to teach the LLM when to use the new tool, with examples for all resource types (CVEs, hosts, rules, blueprints, etc.)
  • Includes thread-safe session manager singleton with double-checked locking, JWT auth pass-through, and robust error handling

Test plan

  • 44 new tests covering all 6 resource categories, error handling, edge cases, and mapping consistency
  • ruff check passes clean
  • Full test suite passes (370 passed, 5 pre-existing LiteLLM failures unrelated)
  • Manual verification with live MCP server

🤖 Generated with Claude Code

yuvalk and others added 4 commits May 26, 2026 21:39
…ueries

Adds the first custom FunctionTool to the agent. When users ask counting
questions ("how many CVEs/hosts/rules?"), this tool calls the MCP tool
with limit=1 and reads the total from response metadata — one API call
instead of paginating through all results.

Supports 13 MCP tools across 6 categories: vulnerability (JSON:API
meta.total_items), inventory (total), advisor/content-sources/image-builder/
RHSM (meta.count). Includes thread-safe session manager singleton, robust
error handling, and JWT auth pass-through.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Updates pagination-handling skill with examples for all resource types:
CVEs, hosts, advisor rules, blueprints — so the LLM knows to call
count_resources instead of paginating manually.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Covers _extract_total helper, count_resources for all 6 MCP categories
(vulnerability, inventory, advisor, content-sources, image-builder, RHSM),
error handling (unsupported tools, MCP failures, bad JSON, missing metadata,
empty responses, session failures), factory function, and TOOL_TOTAL_PATHS
consistency checks.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@luis5tb luis5tb left a comment

Choose a reason for hiding this comment

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

I'm not sure I like the approach here of tightly coupling skills with mcp and tools.

Why not have everything as part of the skill? meaning adding the scripts needed by the skill inside the skills/pagination-handling (or even a new skill if it fits better)

@luis5tb
Copy link
Copy Markdown
Collaborator

luis5tb commented May 27, 2026

what about this instead? #252

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