Skip to content

Commit bff145e

Browse files
committed
chore(perf): Reduce token consumption to avoid session crash by only fetching one page on paginated endpoints
Issue: APPAI-32
1 parent fb4a994 commit bff145e

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

packages/developer_mcp_server/src/developer_mcp_server/server.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@
6767
6868
1. **Finding Existing Secret Incidents**:
6969
- Detect secrets already identified as GitGuardian incidents in your repository
70-
- Use `list_repo_incidents` to view all secret incidents in a repository
70+
- Use `list_repo_incidents` to view secret incidents in a repository (defaults to first page)
7171
- Filter incidents by various criteria including those assigned to you
72+
- Pass get_all=True when you need comprehensive results
7273
7374
2. **Proactive Secret Scanning**:
7475
- Use `scan_secrets` to detect secrets in code before they're committed
@@ -77,6 +78,7 @@
7778
7879
3. **Complete Secret Remediation**:
7980
- Use `remediate_secret_incidents` for guided secret removal
81+
- By default fetches the first page of results for token efficiency; pass get_all=True for comprehensive results
8082
- Get best practice recommendations for different types of secrets
8183
- Replace hardcoded secrets with environment variables
8284
- Create .env.example files with placeholders for detected secrets
@@ -97,7 +99,8 @@
9799
mcp.add_tool(remediate_secret_incidents,
98100
description="Find and fix secrets in the current repository using exact match locations (file paths, line numbers, character indices). "
99101
"This tool leverages the occurrences API to provide precise remediation instructions without needing to search for secrets in files. "
100-
"By default, this only shows incidents assigned to the current user. Pass mine=False to get all incidents related to this repo.",
102+
"By default, only shows incidents assigned to the current user and fetches the first page of results for token efficiency. "
103+
"Pass mine=False to get all incidents. Pass get_all=True for comprehensive results when explicitly requested.",
101104
required_scopes=["incidents:read", "sources:read"],
102105
)
103106

@@ -114,9 +117,9 @@
114117
)
115118

116119
mcp.add_tool(list_repo_incidents,
117-
description="List secret incidents or occurrences related to a specific repository, and assigned to the current user."
118-
"By default, this tool only shows incidents assigned to the current user. "
119-
"Only pass mine=False to get all incidents related to this repo if the user explicitly asks for all incidents even the ones not assigned to him.",
120+
description="List secret incidents or occurrences related to a specific repository. "
121+
"By default, only shows incidents assigned to the current user and fetches the first page of results for token efficiency. "
122+
"Pass mine=False to get all incidents (even ones not assigned to you). Pass get_all=True for comprehensive results when explicitly requested.",
120123
required_scopes=["incidents:read", "sources:read"],
121124
)
122125

@@ -125,6 +128,7 @@
125128
list_repo_occurrences,
126129
description="List secret occurrences for a specific repository with exact match locations. "
127130
"Returns detailed occurrence data including file paths, line numbers, and character indices where secrets were detected. "
131+
"By default fetches the first page of results for token efficiency; pass get_all=True for comprehensive results. "
128132
"Use this tool when you need to locate and remediate secrets in the codebase with precise file locations.",
129133
required_scopes=["incidents:read"],
130134
)

packages/gg_api_core/src/gg_api_core/tools/remediate_secret_incidents.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ async def remediate_secret_incidents(
2020
create_env_example: bool = Field(
2121
default=True, description="Whether to create a .env.example file with placeholders for detected secrets"
2222
),
23-
get_all: bool = Field(default=True, description="Whether to get all incidents or just the first page"),
23+
get_all: bool = Field(default=False, description="Whether to get all incidents or just the first page. Set to True for comprehensive results."),
2424
mine: bool = Field(
2525
default=True,
2626
description="If True, fetch only incidents assigned to the current user. Set to False to get all incidents.",
@@ -29,9 +29,11 @@ async def remediate_secret_incidents(
2929
"""
3030
Find and remediate secret incidents in the current repository using EXACT match locations.
3131
32-
By default, this tool only shows incidents assigned to the current user. Pass mine=False to get all incidents related to this repo.
32+
By default, this tool:
33+
- Only shows incidents assigned to the current user (pass mine=False for all incidents)
34+
- Fetches only the first page of results (pass get_all=True for comprehensive results)
3335
34-
This tool now uses the occurrences API to get precise file locations, line numbers, and character indices,
36+
This tool uses the occurrences API to get precise file locations, line numbers, and character indices,
3537
eliminating the need to search for secrets in files. The workflow is:
3638
3739
1. Fetch secret occurrences with exact match locations (file path, line_start, line_end, index_start, index_end)
@@ -55,7 +57,7 @@ async def remediate_secret_incidents(
5557
repository_name: The full repository name (e.g., 'GitGuardian/gg-mcp')
5658
include_git_commands: Whether to include git commands to fix incidents in git history
5759
create_env_example: Whether to create a .env.example file with placeholders for detected secrets
58-
get_all: Whether to get all occurrences or just the first page
60+
get_all: Whether to get all occurrences or just the first page. Defaults to False for token efficiency.
5961
mine: If True, fetch only occurrences for incidents assigned to the current user. Set to False to get all.
6062
6163
Returns:

0 commit comments

Comments
 (0)