Runs the main server loop, listening for JSON-RPC requests from stdin.
(self)
| 752 | return {"error": f"Unknown tool: {tool_name}"} |
| 753 | |
| 754 | async def run(self): |
| 755 | """ |
| 756 | Runs the main server loop, listening for JSON-RPC requests from stdin. |
| 757 | """ |
| 758 | # info_logger("MCP Server is running. Waiting for requests...") |
| 759 | print("MCP Server is running. Waiting for requests...", file=sys.stderr, flush=True) |
| 760 | self.code_watcher.start() |
| 761 | |
| 762 | loop = asyncio.get_event_loop() |
| 763 | try: |
| 764 | await self._run_loop(loop) |
| 765 | finally: |
| 766 | # Release watcher/DB resources even when stdin reaches EOF or the |
| 767 | # loop exits unexpectedly. |
| 768 | try: |
| 769 | self.shutdown() |
| 770 | except Exception as exc: |
| 771 | warning_logger(f"Error during server shutdown: {exc}") |
| 772 | |
| 773 | async def _run_loop(self, loop): |
| 774 | request_count = 0 |
no test coverage detected