Skip to content

Commit 52422da

Browse files
committed
feat: update RMCP package and enhance MCP tools tests with auto-detected UUID handling
1 parent 0bf21a4 commit 52422da

File tree

2 files changed

+45
-29
lines changed

2 files changed

+45
-29
lines changed

Cargo.lock

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test_mcp_tools.py

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,34 +30,44 @@
3030
TESTS = [
3131
("1. pattern_detection", {
3232
"jsonrpc": "2.0", "method": "tools/call",
33-
"params": {"name": "pattern_detection","arguments": {"_unused": None}}, "id": 101
33+
"params": {"name": "pattern_detection", "arguments": {"_unused": None}}, "id": 101
3434
}),
3535
("2. vector_search", {
3636
"jsonrpc": "2.0", "method": "tools/call",
37-
"params": {"name": "vector_search","arguments": {"query": "async function implementation","limit": 3}}, "id": 102
37+
"params": {"name": "vector_search", "arguments": {"query": "async function implementation", "limit": 3}}, "id": 102
3838
}),
3939
("3. enhanced_search", {
4040
"jsonrpc": "2.0", "method": "tools/call",
41-
"params": {"name": "enhanced_search","arguments": {"query": "RAG engine streaming implementation","limit": 3}}, "id": 103
41+
"params": {"name": "enhanced_search", "arguments": {"query": "RAG engine streaming implementation", "limit": 3}}, "id": 103
4242
}),
4343
("4. codebase_qa", {
4444
"jsonrpc": "2.0", "method": "tools/call",
45-
"params": {"name": "codebase_qa","arguments": {"question": "How does the RAG engine handle streaming responses?","max_results": 3,"streaming": False}}, "id": 104
45+
"params": {"name": "codebase_qa", "arguments": {"question": "How does the RAG engine handle streaming responses?", "max_results": 3, "streaming": False}}, "id": 104
4646
}),
4747
("5. graph_neighbors (auto-fill node UUID)", {
4848
"jsonrpc": "2.0", "method": "tools/call",
49-
"params": {"name": "graph_neighbors","arguments": {"node": "REPLACE_WITH_NODE_UUID","limit": 5}}, "id": 105
49+
"params": {"name": "graph_neighbors", "arguments": {"node": "REPLACE_WITH_NODE_UUID", "limit": 5}}, "id": 105
5050
}),
5151
("6. impact_analysis", {
5252
"jsonrpc": "2.0", "method": "tools/call",
53-
"params": {"name": "impact_analysis","arguments": {"target_function": "analyze_codebase","file_path": "crates/codegraph-mcp/src/qwen.rs","change_type": "modify"}}, "id": 106
53+
"params": {"name": "impact_analysis", "arguments": {"target_function": "analyze_codebase", "file_path": "crates/codegraph-mcp/src/qwen.rs", "change_type": "modify"}}, "id": 106
5454
}),
5555
("7. code_documentation", {
5656
"jsonrpc": "2.0", "method": "tools/call",
57-
"params": {"name": "code_documentation","arguments": {"target_name": "QwenClient","file_path": "crates/codegraph-mcp/src/qwen.rs","style": "concise"}}, "id": 107
57+
"params": {"name": "code_documentation", "arguments": {"target_name": "QwenClient", "file_path": "crates/codegraph-mcp/src/qwen.rs", "style": "concise"}}, "id": 107
5858
}),
5959
]
6060

61+
WAIT_OVERRIDE = {
62+
101: 4.0,
63+
102: 4.0,
64+
103: 12.0,
65+
104: 15.0,
66+
105: 6.0,
67+
106: 12.0,
68+
107: 12.0,
69+
}
70+
6171
def drain(proc, seconds=2.0):
6272
"""Read stdout for up to `seconds`, print as it arrives, and return captured text."""
6373
out = []
@@ -191,29 +201,37 @@ def run():
191201
vec2_output = ""
192202
for title, payload in TESTS:
193203
print(f"\n### {title} ###")
194-
out = send(proc, payload, wait=3.0)
204+
if payload["id"] == 105:
205+
node = extract_uuid(vec2_output)
206+
if not node:
207+
print("⚠️ No UUID found in vector_search output. Skipping graph_neighbors call.")
208+
continue
209+
print(f"Auto-detected node UUID from vector_search: {node}")
210+
payload = {
211+
**payload,
212+
"params": {
213+
**payload["params"],
214+
"arguments": {
215+
**payload["params"]["arguments"],
216+
"node": node
217+
}
218+
}
219+
}
220+
221+
wait_time = WAIT_OVERRIDE.get(payload["id"], 3.0)
222+
out = send(proc, payload, wait=wait_time)
223+
224+
if not out.strip():
225+
# Some tools (especially ones calling local LLMs) can take longer than
226+
# our initial wait window. Give them more time and capture any output.
227+
extra_wait = max(5.0, wait_time)
228+
extra = drain(proc, extra_wait)
229+
if extra:
230+
out += extra
231+
195232
if payload["id"] == 102:
196233
vec2_output = out
197234

198-
if payload["id"] == 105: # graph_neighbors placeholder
199-
if "REPLACE_WITH_NODE_UUID" in json.dumps(payload):
200-
node = extract_uuid(vec2_output)
201-
if node:
202-
print(f"Auto-detected node UUID from vector_search: {node}")
203-
payload = {
204-
**payload,
205-
"params": {
206-
**payload["params"],
207-
"arguments": {
208-
**payload["params"]["arguments"],
209-
"node": node
210-
}
211-
}
212-
}
213-
send(proc, payload, wait=3.0)
214-
else:
215-
print("⚠️ No UUID found in vector_search output. Skipping graph_neighbors actual call.")
216-
217235
# Graceful shutdown
218236
try:
219237
proc.send_signal(signal.SIGINT)

0 commit comments

Comments
 (0)