Start the CodeGraphContext MCP server. Starts the server which listens for JSON-RPC requests from stdin. This is used by IDE integrations (VS Code, Cursor, etc.).
()
| 120 | |
| 121 | @mcp_app.command("start") |
| 122 | def mcp_start(): |
| 123 | """ |
| 124 | Start the CodeGraphContext MCP server. |
| 125 | |
| 126 | Starts the server which listens for JSON-RPC requests from stdin. |
| 127 | This is used by IDE integrations (VS Code, Cursor, etc.). |
| 128 | """ |
| 129 | console.print("[bold green]Starting CodeGraphContext Server...[/bold green]") |
| 130 | _load_credentials() |
| 131 | |
| 132 | server = None |
| 133 | loop = asyncio.new_event_loop() |
| 134 | asyncio.set_event_loop(loop) |
| 135 | try: |
| 136 | server = MCPServer(loop=loop, cwd=Path.cwd()) |
| 137 | loop.run_until_complete(server.run()) |
| 138 | except ValueError as e: |
| 139 | # This typically happens if credentials are still not found after all checks. |
| 140 | console.print(f"[bold red]Configuration Error:[/bold red] {e}") |
| 141 | console.print("Please run `cgc neo4j setup` or use FalkorDB (default).") |
| 142 | except KeyboardInterrupt: |
| 143 | # Handle graceful shutdown on Ctrl+C. |
| 144 | console.print("\n[bold yellow]Server stopped by user.[/bold yellow]") |
| 145 | finally: |
| 146 | # Ensure server and event loop are properly closed. |
| 147 | if server: |
| 148 | server.shutdown() |
| 149 | loop.close() |
| 150 | |
| 151 | @mcp_app.command("tools") |
| 152 | def mcp_tools(): |