|
9 | 9 | class CodebaseState:
|
10 | 10 | """Class to manage codebase state and parsing."""
|
11 | 11 |
|
12 |
| - parse_task: Optional[asyncio.Task] = None |
| 12 | + parse_task: Optional[asyncio.Future] = None |
13 | 13 | parsed_codebase: Optional[Codebase] = None
|
| 14 | + codebase_path: Optional[str] = None |
14 | 15 | log_buffer: List[str] = field(default_factory=list)
|
15 | 16 |
|
16 | 17 | async def parse(self, path: str) -> Codebase:
|
17 | 18 | """Parse the codebase at the given path."""
|
18 | 19 | codebase = Codebase(path)
|
19 | 20 | self.parsed_codebase = codebase
|
| 21 | + self.codebase_path = path |
20 | 22 | return codebase
|
21 | 23 |
|
22 | 24 | def reset(self) -> None:
|
@@ -46,7 +48,7 @@ def capture_output(*args, **kwargs) -> None:
|
46 | 48 | @mcp.tool(name="parse_codebase", description="Initiate codebase parsing")
|
47 | 49 | async def parse_codebase(codebase_path: Annotated[str, "path to the codebase to be parsed"]) -> Dict[str, str]:
|
48 | 50 | if not state.parse_task or state.parse_task.done():
|
49 |
| - state.parse_task = asyncio.create_task(state.parse(codebase_path)) |
| 51 | + state.parse_task = asyncio.get_event_loop().run_in_executor(None, lambda: state.parse(codebase_path)) |
50 | 52 | 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."}
|
51 | 53 | return {"message": "Codebase is already being parsed."}
|
52 | 54 |
|
@@ -86,7 +88,7 @@ def main():
|
86 | 88 | print("starting codegen-mcp-server")
|
87 | 89 | run = mcp.run_stdio_async()
|
88 | 90 | print("codegen-mcp-server started")
|
89 |
| - asyncio.run(run) |
| 91 | + asyncio.get_event_loop().run_until_complete(run) |
90 | 92 |
|
91 | 93 |
|
92 | 94 | if __name__ == "__main__":
|
|
0 commit comments