Skip to content

feat(mcp): expose entry info and time balance to agents (ADR-021 Phase 5)#570

Merged
CybotTM merged 2 commits into
mainfrom
feat/mcp-info-tools
Jul 6, 2026
Merged

feat(mcp): expose entry info and time balance to agents (ADR-021 Phase 5)#570
CybotTM merged 2 commits into
mainfrom
feat/mcp-info-tools

Conversation

@CybotTM

@CybotTM CybotTM commented Jul 6, 2026

Copy link
Copy Markdown
Member

Gives MCP agents the same booking context a user sees in the tracking UI, both inline after a write and as dedicated read tools.

Tools

  • get_ticket_info (reporting:read) — the per-scope totals from an entry’s "Info" (I) popup: customer / project / activity / ticket, each with the user’s own booked minutes and everyone’s total, plus the project estimate. Adds a near/over status and warnings.
  • get_time_balance (reporting:read) — today / week / month IST vs SOLL (both whole-period and "so far"), the diff, and a behind/over status with warnings.

log_time enrichment

After a successful booking, log_time now returns:

  • ticket_info — the same aggregation as get_ticket_info for the created entry
  • balance — the same data as get_time_balance

so an agent sees an estimate or time target being neared / exceeded / underrun without a second round-trip.

Both tools are thin wrappers over two new services — EntrySummaryService (wraps EntryRepository::getEntrySummary) and TimeBalanceService (IST from EntryRepository::getWorkByUser, SOLL from ExpectedWorkTimeCalculator over the user’s contracts minus public holidays). No business logic is reimplemented.

Tests

tests/Mcp/McpToolsTest.php: happy path + scope-denied for each new tool, an unknown-entry error path, and that log_time returns ticket_info + balance.

Docs: ADR-021 Phase 5 toolset section updated.

Add two read tools mirroring what the tracking UI shows for a booking:

- get_ticket_info (reporting:read): the per-scope totals from the entry
  "Info" (I) popup — customer/project/activity/ticket own+total minutes
  plus the project estimate, with a near/over status and warnings.
- get_time_balance (reporting:read): today/week/month IST vs SOLL (total
  and so-far), the diff, and a behind/over status with warnings.

log_time now returns that same context inline after a successful booking
(ticket_info + balance), so an agent sees limits reached/exceeded/underrun
without a second call. Both surfaces are thin wrappers over the new
EntrySummaryService and TimeBalanceService (ADR-021 Phase 5).

Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
Copilot AI review requested due to automatic review settings July 6, 2026 07:04
@gemini-code-assist

Copy link
Copy Markdown

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR expands the MCP toolset so agents can access the same “after-booking” context shown in the tracking UI: per-scope ticket aggregation (“Info” popup) and the user’s IST-vs-SOLL time balance, both as dedicated read tools and (for convenience) inline after log_time.

Changes:

  • Added MCP read tools get_ticket_info and get_time_balance (both reporting:read) backed by new thin services EntrySummaryService and TimeBalanceService.
  • Enriched log_time responses with ticket_info and balance to avoid a second agent round-trip after booking.
  • Extended MCP tool tests and updated ADR-021 documentation to reflect the Phase 5 toolset.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/Mcp/McpToolsTest.php Adds coverage for the new read tools and verifies log_time enrichment.
src/Service/TimeBalanceService.php New service computing today/week/month IST vs SOLL totals/so-far, diff, status, and warnings.
src/Service/EntrySummaryService.php New service wrapping EntryRepository::getEntrySummary() and adding estimate status + warnings.
src/Mcp/Tool/LogTimeTool.php Enriches log_time output with ticket_info and balance.
src/Mcp/Tool/GetTimeBalanceTool.php New MCP tool exposing time-balance data via TimeBalanceService.
src/Mcp/Tool/GetTicketInfoTool.php New MCP tool exposing per-entry “Info” aggregation via EntrySummaryService.
docs/adr/ADR-021-api-token-authentication.md Documents the new tools and the log_time “info-on-write” enrichment.

Comment thread src/Service/EntrySummaryService.php
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 120 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.14%. Comparing base (c1454c7) to head (83759a3).

Files with missing lines Patch % Lines
src/Service/TimeBalanceService.php 0.00% 60 Missing ⚠️
src/Service/EntrySummaryService.php 0.00% 38 Missing ⚠️
src/Mcp/Tool/LogTimeTool.php 0.00% 11 Missing ⚠️
src/Mcp/Tool/GetTicketInfoTool.php 0.00% 7 Missing ⚠️
src/Mcp/Tool/GetTimeBalanceTool.php 0.00% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #570      +/-   ##
============================================
- Coverage     83.22%   82.14%   -1.08%     
- Complexity     3337     3378      +41     
============================================
  Files           237      241       +4     
  Lines          9091     9210     +119     
============================================
  Hits           7566     7566              
- Misses         1525     1644     +119     
Flag Coverage Δ
integration 54.10% <0.00%> (-0.71%) ⬇️
unit 46.60% <0.00%> (-0.62%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

getEntrySummary aggregates customer/project/activity/ticket totals across
all users, so returning a summary for an entry the caller does not own
would disclose other users' scope names and totals. Treat "not owned by
the authenticated user" as "not found" in EntrySummaryService::forEntry.

Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
@sonarqubecloud

sonarqubecloud Bot commented Jul 6, 2026

Copy link
Copy Markdown

@CybotTM CybotTM merged commit 39c3b6c into main Jul 6, 2026
26 checks passed
@CybotTM CybotTM deleted the feat/mcp-info-tools branch July 6, 2026 09:26
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