Skip to content

Commit 5fcc491

Browse files
committed
refactor: remove execution_time from tool reporting
Some tools report execution time (execution_time). This is pointless, remove it from all of them. ```git-revs 74289f5 (Base revision) 9c5623b Remove execution_time calculation and durationMs from glob_files output 3ea1c75 Remove start_time and execution stats related code from chmod function docstring and start 3ceef27 Remove durationMs from chmod early return statements e5602f6 Remove execution_time calculation and durationMs from chmod output 53df773 Remove durationMs from chmod error handling 30314a0 Remove execution stats mention and start_time from git_log function aad0e1e Remove execution_time calculation and durationMs from git_log output 0155b92 Remove durationMs from git_log error handling 5accde2 Remove execution stats mention and start_time from git_blame function c7686d3 Remove execution_time calculation and durationMs from git_blame output a47db12 Remove durationMs from git_blame error handling ea94b86 Remove execution stats mention and start_time from git_diff function 71c0dca Remove execution_time calculation and durationMs from git_diff output 7ea1010 Remove durationMs from git_diff error handling f6e301c Remove execution stats mention and start_time from git_show function b4553d7 Remove execution_time calculation and durationMs from git_show output 550f606 Remove durationMs from git_show error handling dafec72 Remove execution stats mention and start_time from grep_files function 8d2a6d0 Remove execution_time calculation and durationMs from grep_files output HEAD Auto-commit lint changes ``` codemcp-id: 211-refactor-remove-execution-time-from-tool-reporting ghstack-source-id: cae15f1 Pull-Request-resolved: #205
1 parent 7d8aeaf commit 5fcc491

File tree

8 files changed

+7
-77
lines changed

8 files changed

+7
-77
lines changed

codemcp/main.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
import logging
44
import os
5-
import sys
65
from pathlib import Path
7-
from typing import Optional
86

97
import click
108
from mcp.server.fastmcp import FastMCP

codemcp/tools/chmod.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import logging
44
import os
55
import stat
6-
import time
76
from typing import Any, Literal
87

98
from ..common import normalize_file_path
@@ -44,10 +43,8 @@ async def chmod(
4443
signal: Optional abort signal to terminate the subprocess
4544
4645
Returns:
47-
A dictionary with execution stats and chmod output
46+
A dictionary with chmod output
4847
"""
49-
start_time = time.time()
50-
5148
if not path:
5249
raise ValueError("File path must be provided")
5350

@@ -76,14 +73,12 @@ async def chmod(
7673
message = f"File '{path}' is already executable"
7774
return {
7875
"output": message,
79-
"durationMs": int((time.time() - start_time) * 1000),
8076
"resultForAssistant": message,
8177
}
8278
elif mode == "a-x" and not is_executable:
8379
message = f"File '{path}' is already non-executable"
8480
return {
8581
"output": message,
86-
"durationMs": int((time.time() - start_time) * 1000),
8782
"resultForAssistant": message,
8883
}
8984

@@ -118,19 +113,12 @@ async def chmod(
118113
logging.warning(f"Failed to commit chmod changes: {commit_message}")
119114
return {
120115
"output": f"{action_msg}, but failed to commit changes: {commit_message}",
121-
"durationMs": int((time.time() - start_time) * 1000),
122116
"resultForAssistant": f"{action_msg}, but failed to commit changes: {commit_message}",
123117
}
124118

125-
# Calculate execution time
126-
execution_time = int(
127-
(time.time() - start_time) * 1000
128-
) # Convert to milliseconds
129-
130119
# Prepare output
131120
output = {
132121
"output": f"{action_msg} and committed changes",
133-
"durationMs": execution_time,
134122
}
135123

136124
# Add formatted result for assistant
@@ -142,7 +130,6 @@ async def chmod(
142130
error_message = f"Error executing chmod: {e!s}"
143131
return {
144132
"output": error_message,
145-
"durationMs": int((time.time() - start_time) * 1000),
146133
"resultForAssistant": error_message,
147134
}
148135

codemcp/tools/git_blame.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import logging
44
import shlex
5-
import time
65
from typing import Any
76

87
from ..common import normalize_file_path
@@ -46,9 +45,8 @@ async def git_blame(
4645
signal: Optional abort signal to terminate the subprocess
4746
4847
Returns:
49-
A dictionary with execution stats and git blame output
48+
A dictionary with git blame output
5049
"""
51-
start_time = time.time()
5250

5351
if path is None:
5452
raise ValueError("Path must be provided for git blame")
@@ -88,19 +86,12 @@ async def git_blame(
8886
error_message = f"Error: {result.stderr}"
8987
return {
9088
"output": error_message,
91-
"durationMs": int((time.time() - start_time) * 1000),
9289
"resultForAssistant": error_message,
9390
}
9491

95-
# Calculate execution time
96-
execution_time = int(
97-
(time.time() - start_time) * 1000
98-
) # Convert to milliseconds
99-
10092
# Prepare output
10193
output = {
10294
"output": result.stdout,
103-
"durationMs": execution_time,
10495
}
10596

10697
# Add formatted result for assistant
@@ -112,7 +103,6 @@ async def git_blame(
112103
error_message = f"Error executing git blame: {e!s}"
113104
return {
114105
"output": error_message,
115-
"durationMs": int((time.time() - start_time) * 1000),
116106
"resultForAssistant": error_message,
117107
}
118108

codemcp/tools/git_diff.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import logging
44
import shlex
5-
import time
65
from typing import Any
76

87
from ..common import normalize_file_path
@@ -47,9 +46,8 @@ async def git_diff(
4746
signal: Optional abort signal to terminate the subprocess
4847
4948
Returns:
50-
A dictionary with execution stats and git diff output
49+
A dictionary with git diff output
5150
"""
52-
start_time = time.time()
5351

5452
if path is None:
5553
raise ValueError("Path must be provided for git diff")
@@ -89,19 +87,12 @@ async def git_diff(
8987
error_message = f"Error: {result.stderr}"
9088
return {
9189
"output": error_message,
92-
"durationMs": int((time.time() - start_time) * 1000),
9390
"resultForAssistant": error_message,
9491
}
9592

96-
# Calculate execution time
97-
execution_time = int(
98-
(time.time() - start_time) * 1000
99-
) # Convert to milliseconds
100-
10193
# Prepare output
10294
output = {
10395
"output": result.stdout,
104-
"durationMs": execution_time,
10596
}
10697

10798
# Add formatted result for assistant
@@ -113,7 +104,6 @@ async def git_diff(
113104
error_message = f"Error executing git diff: {e!s}"
114105
return {
115106
"output": error_message,
116-
"durationMs": int((time.time() - start_time) * 1000),
117107
"resultForAssistant": error_message,
118108
}
119109

codemcp/tools/git_log.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import logging
44
import shlex
5-
import time
65
from typing import Any
76

87
from ..common import normalize_file_path
@@ -46,9 +45,8 @@ async def git_log(
4645
signal: Optional abort signal to terminate the subprocess
4746
4847
Returns:
49-
A dictionary with execution stats and git log output
48+
A dictionary with git log output
5049
"""
51-
start_time = time.time()
5250

5351
if path is None:
5452
raise ValueError("Path must be provided for git log")
@@ -88,19 +86,12 @@ async def git_log(
8886
error_message = f"Error: {result.stderr}"
8987
return {
9088
"output": error_message,
91-
"durationMs": int((time.time() - start_time) * 1000),
9289
"resultForAssistant": error_message,
9390
}
9491

95-
# Calculate execution time
96-
execution_time = int(
97-
(time.time() - start_time) * 1000
98-
) # Convert to milliseconds
99-
10092
# Prepare output
10193
output = {
10294
"output": result.stdout,
103-
"durationMs": execution_time,
10495
}
10596

10697
# Add formatted result for assistant
@@ -112,7 +103,6 @@ async def git_log(
112103
error_message = f"Error executing git log: {e!s}"
113104
return {
114105
"output": error_message,
115-
"durationMs": int((time.time() - start_time) * 1000),
116106
"resultForAssistant": error_message,
117107
}
118108

codemcp/tools/git_show.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import logging
44
import shlex
5-
import time
65
from typing import Any
76

87
from ..common import normalize_file_path
@@ -48,9 +47,8 @@ async def git_show(
4847
signal: Optional abort signal to terminate the subprocess
4948
5049
Returns:
51-
A dictionary with execution stats and git show output
50+
A dictionary with git show output
5251
"""
53-
start_time = time.time()
5452

5553
if path is None:
5654
raise ValueError("Path must be provided for git show")
@@ -90,19 +88,12 @@ async def git_show(
9088
error_message = f"Error: {result.stderr}"
9189
return {
9290
"output": error_message,
93-
"durationMs": int((time.time() - start_time) * 1000),
9491
"resultForAssistant": error_message,
9592
}
9693

97-
# Calculate execution time
98-
execution_time = int(
99-
(time.time() - start_time) * 1000
100-
) # Convert to milliseconds
101-
10294
# Prepare output
10395
output = {
10496
"output": result.stdout,
105-
"durationMs": execution_time,
10697
}
10798

10899
# Add formatted result for assistant
@@ -114,7 +105,6 @@ async def git_show(
114105
error_message = f"Error executing git show: {e!s}"
115106
return {
116107
"output": error_message,
117-
"durationMs": int((time.time() - start_time) * 1000),
118108
"resultForAssistant": error_message,
119109
}
120110

codemcp/tools/glob.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import asyncio
44
import logging
55
import os
6-
import time
76
from pathlib import Path
87
from typing import Any, Dict, Optional
98

@@ -169,10 +168,8 @@ async def glob_files(
169168
signal: Optional abort signal to terminate the operation
170169
171170
Returns:
172-
A dictionary with execution stats and matched files
171+
A dictionary with matched files
173172
"""
174-
start_time = time.time()
175-
176173
# Use current working directory if path is not provided
177174
if path is None:
178175
path = os.getcwd()
@@ -186,16 +183,12 @@ async def glob_files(
186183
# Execute glob
187184
result = await glob(pattern, path, options, signal)
188185

189-
# Calculate execution time
190-
execution_time = int((time.time() - start_time) * 1000) # Convert to milliseconds
191-
192186
# Get matching files
193187
files = result.get("files", [])
194188

195189
# Prepare output
196190
output = {
197191
"filenames": files,
198-
"durationMs": execution_time,
199192
"numFiles": len(files),
200193
"truncated": result.get("truncated", False),
201194
}

codemcp/tools/grep.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import logging
44
import os
55
import subprocess
6-
import time
76
from typing import Any
87

98
from ..common import normalize_file_path
@@ -173,10 +172,9 @@ async def grep_files(
173172
signal: Optional abort signal to terminate the subprocess
174173
175174
Returns:
176-
A dictionary with execution stats and matched files
175+
A dictionary with matched files
177176
178177
"""
179-
start_time = time.time()
180178

181179
# Execute git grep asynchronously
182180
matches = await git_grep(pattern, path, include, signal)
@@ -215,15 +213,9 @@ async def grep_files(
215213
)
216214
matches.sort()
217215

218-
# Calculate execution time
219-
execution_time = int(
220-
(time.time() - start_time) * 1000,
221-
) # Convert to milliseconds
222-
223216
# Prepare output
224217
output = {
225218
"filenames": matches[:MAX_RESULTS],
226-
"durationMs": execution_time,
227219
"numFiles": len(matches),
228220
}
229221

0 commit comments

Comments
 (0)