Skip to content

Commit f41af3d

Browse files
committed
precommit mypy fix
1 parent f65bfc8 commit f41af3d

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

myclient.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
import anthropic
2-
from rich import print
3-
url = 'https://0de03d07f8b9.ngrok-free.app'
2+
from rich import print as rprint
3+
4+
url = "https://0de03d07f8b9.ngrok-free.app"
45
client = anthropic.Anthropic()
56
response = client.beta.messages.create(
67
model="claude-sonnet-4-20250514",
78
max_tokens=1000,
8-
messages=[{"role": "user", "content": "Optimize my codebase, the file is \"/Users/codeflash/Downloads/codeflash-dev/codeflash/code_to_optimize/bubble_sort.py\" and the function is \"sorter\""}],
9-
mcp_servers=[
9+
messages=[
1010
{
11-
"type": "url",
12-
"url": f"{url}/mcp/",
13-
"name": "Code Optimization Assistant",
11+
"role": "user",
12+
"content": 'Optimize my codebase, the file is "/Users/codeflash/Downloads/codeflash-dev/codeflash/code_to_optimize/bubble_sort.py" and the function is "sorter"',
1413
}
1514
],
16-
extra_headers={
17-
"anthropic-beta": "mcp-client-2025-04-04"
18-
}
15+
mcp_servers=[{"type": "url", "url": f"{url}/mcp/", "name": "Code Optimization Assistant"}],
16+
extra_headers={"anthropic-beta": "mcp-client-2025-04-04"},
1917
)
20-
print(response.content)
18+
rprint(response.content)

myserver.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
import pathlib
2+
23
from fastmcp import FastMCP
4+
35
from tests.scripts.end_to_end_test_utilities import CoverageExpectation, TestConfig, run_codeflash_command
4-
mcp = FastMCP(name="Code Optimization Assistant",
6+
7+
mcp = FastMCP(
8+
name="Code Optimization Assistant",
59
instructions="""
610
This server provides code optimization tools.
711
Call optimize_code(file, function) to optimize your code.
8-
""")
12+
""",
13+
)
14+
915

1016
@mcp.tool
1117
def optimize_code(file: str, function: str) -> bool:
@@ -20,10 +26,11 @@ def optimize_code(file: str, function: str) -> bool:
2026
)
2127
],
2228
)
23-
cwd = (pathlib.Path(__file__).parent/ "code_to_optimize").resolve() # TODO remove it
29+
cwd = (pathlib.Path(__file__).parent / "code_to_optimize").resolve() # TODO remove it
2430
return run_codeflash_command(
2531
cwd, config, 100, ['print("codeflash stdout: Sorting list")', 'print(f"result: {arr}")']
2632
)
2733

34+
2835
if __name__ == "__main__":
29-
mcp.run(transport="http", port=8000)
36+
mcp.run(transport="http", port=8000)

0 commit comments

Comments
 (0)