Runs the main server loop, listening for JSON-RPC requests from stdin.
(self)
| 684 | return {"error": f"Unknown tool: {tool_name}"} |
| 685 | |
| 686 | async def run(self): |
| 687 | """ |
| 688 | Runs the main server loop, listening for JSON-RPC requests from stdin. |
| 689 | """ |
| 690 | # info_logger("MCP Server is running. Waiting for requests...") |
| 691 | print("MCP Server is running. Waiting for requests...", file=sys.stderr, flush=True) |
| 692 | self.code_watcher.start() |
| 693 | |
| 694 | loop = asyncio.get_event_loop() |
| 695 | try: |
| 696 | await self._run_loop(loop) |
| 697 | finally: |
| 698 | # Release watcher/DB resources even when stdin reaches EOF or the |
| 699 | # loop exits unexpectedly. |
| 700 | try: |
| 701 | self.shutdown() |
| 702 | except Exception as exc: |
| 703 | warning_logger(f"Error during server shutdown: {exc}") |
| 704 | |
| 705 | async def _run_loop(self, loop): |
| 706 | request_count = 0 |
no test coverage detected