(
request: IndexRequest,
background_tasks: BackgroundTasks,
server: MCPServer = Depends(get_server)
)
| 87 | |
| 88 | @router.post("/index", response_model=ApiResponse) |
| 89 | async def index_repository( |
| 90 | request: IndexRequest, |
| 91 | background_tasks: BackgroundTasks, |
| 92 | server: MCPServer = Depends(get_server) |
| 93 | ): |
| 94 | # The add_code_to_graph handler only understands "path" (and is_dependency); |
| 95 | # repo_name/branch/force from the request model are not supported by it. |
| 96 | args = {"path": request.path} |
| 97 | |
| 98 | try: |
| 99 | result = await server.handle_tool_call( |
| 100 | "add_code_to_graph", |
| 101 | args |
| 102 | ) |
| 103 | except (OSError, socket.error) as exc: |
| 104 | raise_service_unavailable(exc) |
| 105 | |
| 106 | if "error" in result: |
| 107 | raise HTTPException( |
| 108 | status_code=400, |
| 109 | detail=result["error"] |
| 110 | ) |
| 111 | |
| 112 | return ApiResponse( |
| 113 | status="ok", |
| 114 | message="Indexing job started", |
| 115 | data=result |
| 116 | ) |
| 117 | |
| 118 | @router.post("/query", response_model=ApiResponse) |
| 119 | async def execute_query( |
nothing calls this directly
no test coverage detected