Skip to content

Commit 2e48561

Browse files
committed
fix: review findings -- correct response keys, async index endpoint, defensive delete
- handlers.py: add_repository reads result.get('repo_id') not 'id' (backend returns 'repo_id') - handlers.py: index_repository uses /index/async when include_paths set (sync endpoint doesn't accept include_paths), reads 'functions' not 'function_count' - api_client.py: api_delete handles 204/empty body gracefully - test_tools.py: repo_tools list includes new write tools
1 parent fc281f7 commit 2e48561

3 files changed

Lines changed: 22 additions & 13 deletions

File tree

mcp-server/api_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ async def api_delete(path: str, **kwargs: Any) -> dict:
6363
client = await get_client()
6464
response = await client.delete(path, **kwargs)
6565
response.raise_for_status()
66+
if response.status_code == 204 or not response.content:
67+
return {}
6668
return response.json()
6769

6870

mcp-server/handlers.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ async def _handle_add_repository(args: dict[str, Any]) -> str:
8888
"branch": args.get("branch", "main"),
8989
}
9090
result = await api_post("/repos", json=payload)
91-
repo_id = result.get("id", "unknown")
91+
repo_id = result.get("repo_id", "unknown")
9292
name = result.get("name", args["name"])
9393
status = result.get("status", "added")
9494
needs_selection = result.get("needs_directory_selection", False)
@@ -130,25 +130,31 @@ async def _handle_get_repo_directories(args: dict[str, Any]) -> str:
130130
async def _handle_index_repository(args: dict[str, Any]) -> str:
131131
repo_id = args["repo_id"]
132132
include_paths = args.get("include_paths")
133-
# Build query params
134-
params = {}
133+
135134
if include_paths:
136-
params["include_paths"] = include_paths
137-
result = await api_post(
138-
f"/repos/{repo_id}/index",
139-
json=params if params else {},
140-
)
135+
# Async endpoint supports include_paths for monorepo subset indexing
136+
result = await api_post(
137+
f"/repos/{repo_id}/index/async",
138+
json={"include_paths": include_paths},
139+
)
140+
status = result.get("status", "accepted")
141+
return (
142+
f"Async indexing started for subset: {', '.join(include_paths)}\n"
143+
f"Status: {status}\n"
144+
f"Repo ID: `{repo_id}`\n"
145+
"\nIndexing runs in the background. Use list_repositories "
146+
"to check when status changes to 'indexed'."
147+
)
148+
149+
# Sync endpoint for full-repo indexing
150+
result = await api_post(f"/repos/{repo_id}/index", json={})
141151
status = result.get("status", "unknown")
142-
fn_count = result.get("function_count", result.get("functions_indexed", 0))
143-
file_count = result.get("file_count", result.get("files_indexed", 0))
152+
fn_count = result.get("functions", 0)
144153
lines = [
145154
"Indexing complete.",
146155
f"Status: {status}",
147-
f"Files indexed: {file_count}",
148156
f"Functions extracted: {fn_count}",
149157
]
150-
if include_paths:
151-
lines.append(f"Subset: {', '.join(include_paths)}")
152158
lines.append(
153159
f"\nYou can now use search_code(repo_id='{repo_id}') "
154160
"to search this codebase."

mcp-server/tests/test_tools.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def test_repo_tools_require_repo_id(self):
5757
repo_tools = [
5858
"get_dependency_graph", "analyze_code_style",
5959
"analyze_impact", "get_repository_insights", "get_codebase_dna",
60+
"get_repo_directories", "index_repository", "delete_repository",
6061
]
6162
for name in repo_tools:
6263
required = schemas[name].inputSchema.get("required", [])

0 commit comments

Comments
 (0)