Skip to content

Commit e8b9202

Browse files
committed
stdio server
1 parent ffbd894 commit e8b9202

File tree

3 files changed

+27
-23
lines changed

3 files changed

+27
-23
lines changed

codeflash/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# These version placeholders will be replaced by uv-dynamic-versioning during build.
2-
__version__ = "0.16.3"
2+
__version__ = "0.16.5"

myserver.py

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
import pathlib
2-
31
from fastmcp import FastMCP
42

5-
from tests.scripts.end_to_end_test_utilities import CoverageExpectation, TestConfig, run_codeflash_command
6-
73
mcp = FastMCP(
84
name="codeflash",
95
instructions="""
@@ -14,23 +10,30 @@
1410

1511

1612
@mcp.tool
17-
def optimize_code(file: str, function: str) -> bool:
18-
config = TestConfig(
19-
file_path=pathlib.Path(file),
20-
function_name=function,
21-
test_framework="pytest",
22-
min_improvement_x=1.0,
23-
coverage_expectations=[
24-
CoverageExpectation(
25-
function_name=function, expected_coverage=100.0, expected_lines=[2, 3, 4, 5, 6, 7, 8, 9, 10]
26-
)
27-
],
28-
)
29-
cwd = (pathlib.Path(__file__).parent / "code_to_optimize").resolve() # TODO remove it
30-
return run_codeflash_command(
31-
cwd, config, 100, ['print("codeflash stdout: Sorting list")', 'print(f"result: {arr}")']
32-
)
13+
def optimize_code(file: str, function: str) -> dict[str, str]:
14+
# config = TestConfig(
15+
# file_path=pathlib.Path(file),
16+
# function_name=function,
17+
# test_framework="pytest",
18+
# min_improvement_x=1.0,
19+
# coverage_expectations=[
20+
# CoverageExpectation(
21+
# function_name=function, expected_coverage=100.0, expected_lines=[2, 3, 4, 5, 6, 7, 8, 9, 10]
22+
# )
23+
# ],
24+
# )
25+
# cwd = pathlib.Path("/Users/aseemsaxena/Downloads/codeflash_dev/codeflash/code_to_optimize") # TODO remove it
26+
print(file, function)
27+
return {
28+
"code": """def sorter(arr):
29+
print("codeflash stdout: Sorting list")
30+
arr.sort()
31+
print(f"result: {arr}")
32+
return arr
33+
""",
34+
"explanation": "A faster version of the code is using python's in-built timsort function",
35+
}
3336

3437

3538
if __name__ == "__main__":
36-
mcp.run(transport="http", port=8000)
39+
mcp.run(transport="stdio")

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "codeflash"
33
dynamic = ["version"]
44
description = "Client for codeflash.ai - automatic code performance optimization, powered by AI"
55
authors = [{ name = "CodeFlash Inc.", email = "[email protected]" }]
6-
requires-python = ">=3.9"
6+
requires-python = ">=3.10"
77
readme = "README.md"
88
license = {text = "BSL-1.1"}
99
keywords = [
@@ -43,6 +43,7 @@ dependencies = [
4343
"platformdirs>=4.3.7",
4444
"pygls>=1.3.1",
4545
"codeflash-benchmark",
46+
"fastmcp"
4647
]
4748

4849
[project.urls]

0 commit comments

Comments
 (0)