Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 11, 2025

This PR implements trimmed responses for Azure DevOps MCP server tools to dramatically reduce LLM token consumption while maintaining backward compatibility.

Problem

The MCP server tools were returning full REST API JSON payloads, causing unnecessary token burn and making it difficult for weaker LLMs to extract relevant information. For example:

  • ado_resolve_comment was returning 4200+ character responses when a simple "resolved" message would suffice
  • ado_list_pull_request_threads was returning verbose payloads with _links objects, deleted comments, and unnecessary author properties

Solution

Added a fullResponse parameter (defaults to false) to key repository tools that provides two response modes:

Trimmed Mode (Default)

  • Action tools (resolve_comment, reply_to_comment) return simple success messages
  • List tools (list_pull_request_threads, list_pull_request_thread_comments) return filtered data excluding:
    • Deleted comments
    • _links objects
    • Verbose author properties (imageUrl, descriptor, url)

Full Mode (Opt-in)

  • Set fullResponse: true to get complete REST API responses for debugging or advanced use cases

Token Savings

Real-world examples show dramatic improvements:

  • resolve_comment: 97.3% reduction (1346 → 37 characters)
  • reply_to_comment: 92.5% reduction (549 → 41 characters)
  • list_pull_request_threads: 55.3% reduction (680 → 304 characters)

Example Usage

// Trimmed response (default)
await server.request({
  method: "tools/call",
  params: {
    name: "repo_resolve_comment",
    arguments: { repositoryId: "repo1", pullRequestId: 123, threadId: 456 }
  }
});
// Returns: "Thread 456 was successfully resolved."

// Full response (opt-in)
await server.request({
  method: "tools/call", 
  params: {
    name: "repo_resolve_comment",
    arguments: { 
      repositoryId: "repo1", 
      pullRequestId: 123, 
      threadId: 456,
      fullResponse: true 
    }
  }
});
// Returns: Complete thread JSON with all properties

Modified Tools

  • repo_resolve_comment - Simple success message vs full thread JSON
  • repo_reply_to_comment - Simple success message vs full comment JSON
  • repo_list_pull_request_threads - Filtered thread data vs complete response
  • repo_list_pull_request_thread_comments - Filtered comment data vs complete response

All changes maintain full backward compatibility via the optional fullResponse parameter.

Fixes #36.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits July 11, 2025 07:53
…ll_request_threads, list_pull_request_thread_comments, and reply_to_comment

Co-authored-by: nikolapeja6 <[email protected]>
@Copilot Copilot AI changed the title [WIP] Trim the payloads returned by the MCP commands Trim MCP server tool payloads to reduce token consumption Jul 11, 2025
Copilot finished work on behalf of nikolapeja6 July 11, 2025 08:03
@Copilot Copilot AI requested a review from nikolapeja6 July 11, 2025 08:03
@danhellem danhellem added the Stale and Needs Attention ✈️ stale item and needs someone to pick and finish or close label Jul 18, 2025
@Copilot Copilot AI requested a review from nikolapeja6 July 22, 2025 17:09
Copilot finished work on behalf of nikolapeja6 July 22, 2025 17:09
Copilot finished work on behalf of nikolapeja6 July 22, 2025 17:20
Copy link

github-actions bot commented Jul 22, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

1 similar comment
Copy link

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@Copilot Copilot AI requested a review from nikolapeja6 July 22, 2025 18:18
Copilot finished work on behalf of nikolapeja6 July 22, 2025 18:18
Copilot finished work on behalf of nikolapeja6 July 22, 2025 18:26
@nikolapeja6 nikolapeja6 marked this pull request as ready for review July 22, 2025 18:26
@nikolapeja6 nikolapeja6 requested a review from a team as a code owner July 22, 2025 18:26
@Arithmomaniac
Copy link

This is a pretty big change to merge straight into main, no? Especially as the default on, but only for certain tools.

@nikolapeja6
Copy link
Member

I believe it should be fine - the results of some tools were already being trimmed, this is just a continuation of that.

@nikolapeja6 nikolapeja6 merged commit 3e0704e into main Jul 23, 2025
7 checks passed
@nikolapeja6 nikolapeja6 deleted the copilot/fix-36 branch July 23, 2025 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Stale and Needs Attention ✈️ stale item and needs someone to pick and finish or close

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trim the payloads returned by the MCP commands

4 participants