Skip to content

Commit d4aeb62

Browse files
rushilpatel0github-actions[bot]
authored andcommitted
Automated pre-commit update
1 parent cefaafb commit d4aeb62

File tree

1 file changed

+5
-9
lines changed
  • codegen-examples/examples/codegen-mcp-server

1 file changed

+5
-9
lines changed

codegen-examples/examples/codegen-mcp-server/server.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import asyncio
22
from dataclasses import dataclass, field
3-
import json
4-
from types import coroutine
5-
from typing import Annotated, Coroutine, Optional, Dict, Any, List
3+
from typing import Annotated, Optional, Dict, Any, List
64
from mcp.server.fastmcp import FastMCP
75
from codegen import Codebase
86

@@ -44,26 +42,24 @@ def capture_output(*args, **kwargs) -> None:
4442
for arg in args:
4543
state.log_buffer.append(str(arg))
4644

45+
4746
def update_codebase(future: asyncio.Future):
4847
try:
4948
result = future.result()
5049
if result is not None:
5150
state.parsed_codebase = result
5251
else:
5352
state.parsed_codebase = None
54-
except Exception as e:
53+
except Exception:
5554
pass
5655

5756

58-
5957
@mcp.tool(name="parse_codebase", description="Initiate codebase parsing")
6058
async def parse_codebase(codebase_path: Annotated[str, "path to the codebase to be parsed"]) -> Dict[str, str]:
6159
if not state.parse_task or state.parse_task.done():
6260
state.parse_task = asyncio.get_event_loop().run_in_executor(None, lambda: state.parse(codebase_path))
6361
state.parse_task.add_done_callback(update_codebase)
64-
return {
65-
"message": "Codebase parsing initiated, this may take some time depending on the size of the codebase. Use the `check_parsing_status` tool to check if the parse has completed."
66-
}
62+
return {"message": "Codebase parsing initiated, this may take some time depending on the size of the codebase. Use the `check_parsing_status` tool to check if the parse has completed."}
6763
return {"message": "Codebase is already being parsed.", "status": "error"}
6864

6965

@@ -83,7 +79,7 @@ async def execute_codemod(codemod: Annotated[str, "The python codemod code to ex
8379

8480
try:
8581
await state.parse_task
86-
if (state.parsed_codebase is None):
82+
if state.parsed_codebase is None:
8783
return {"error": "Codebase path is not set."}
8884
else:
8985
# TODO: Implement proper sandboxing for code execution

0 commit comments

Comments
 (0)