Skip to content

Commit ac75a11

Browse files
Clarify the usage of the commands
1 parent b4be24b commit ac75a11

File tree

2 files changed

+21
-82
lines changed

2 files changed

+21
-82
lines changed

mcp_nexus/Tools/SessionAwareWindbgTool.cs

Lines changed: 18 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ namespace mcp_nexus.Tools
2323
[McpServerToolType]
2424
public class SessionAwareWindbgTool(ILogger<SessionAwareWindbgTool> logger, ISessionManager sessionManager)
2525
{
26+
private const string TOOL_USAGE_EXPLANATION =
27+
"Explains how to use the Nexus MCP server. Please get further details from the responses and the tool listings of the MCP server.\n\n" +
28+
"- **Tooling - Open Session** Open the analyze session for the dump file with the tool from Nexus MCP server `nexus_open_dump_analyze_session`. Using the open call you receive a `sessionid`. This **EXACT** `sessionid` **IS REQUIRED TO BE USED** for all following commands in the session.\n" +
29+
"- **Tooling - Exec Command** Use the `nexus_dump_analyze_session_async_command` to start async execution of the Windbg commands. Using the command call you receive a `commandId`. This **EXACT** `commandId` **IS REQUIRED TO BE USED** for the `nexus_dump_analyze_session_async_command_status` commands to get the async result.\n" +
30+
"- **Tooling - Get Command Status** Use the `nexus_dump_analyze_session_async_command_status` to poll for the status or result of the specific async execution of the Windbg commands\n" +
31+
"- **Tooling - Close Session** Use the `nexus_close_dump_analyze_session` to close analyze session of the dump file after all commands are executed or the session is not needed anymore";
32+
2633
/// <summary>
2734
/// Session-aware response wrapper for AI client guidance
2835
/// </summary>
@@ -93,29 +100,17 @@ public async Task<object> nexus_open_dump_analyze_session(
93100
var sessionId = await sessionManager.CreateSessionAsync(dumpPath, symbolsPath);
94101
var context = sessionManager.GetSessionContext(sessionId);
95102

96-
// Return comprehensive response with all critical information
103+
// Return simplified response with essential information
97104
var response = new
98105
{
99-
// CRITICAL IDENTIFIERS - Always include these
100106
sessionId = sessionId,
101107
dumpFile = Path.GetFileName(dumpPath),
102-
commandId = (string?)null, // No commandId for this operation
103-
104-
// OPERATION STATUS
108+
commandId = (string?)null,
105109
success = true,
106110
operation = "nexus_open_dump_analyze_session",
107111
status = "completed",
108112
message = $"Session created: {sessionId}",
109-
110-
// WORKFLOW GUIDANCE
111-
nextCommand = "nexus_dump_analyze_session_async_command",
112-
nextCommandParameters = new { sessionId = sessionId, command = "!analyze -v" },
113-
workflow = "STEP 1 COMPLETE → NEXT: nexus_dump_analyze_session_async_command → THEN: nexus_dump_analyze_session_async_command_status",
114-
115-
// CRITICAL REMINDERS
116-
extractSessionId = sessionId, // Extra copy for extraction
117-
useThisSessionId = sessionId, // Another copy for clarity
118-
instructions = $"SAVE this sessionId '{sessionId}' and use it in ALL subsequent commands!"
113+
toolusage = TOOL_USAGE_EXPLANATION
119114
};
120115

121116
logger.LogInformation("✅ Session {SessionId} created successfully", sessionId);
@@ -219,31 +214,19 @@ public async Task<object> nexus_close_dump_analyze_session(
219214
var context = sessionManager.GetSessionContext(sessionId);
220215
var closed = await sessionManager.CloseSessionAsync(sessionId);
221216

222-
// Return comprehensive response with all critical information
217+
// Return simplified response with essential information
223218
var response = new
224219
{
225-
// CRITICAL IDENTIFIERS - Always include these
226220
sessionId = sessionId,
227-
dumpFile = (string?)null, // No dump file for close operation
228-
commandId = (string?)null, // No commandId for this operation
229-
230-
// OPERATION STATUS
221+
dumpFile = (string?)null,
222+
commandId = (string?)null,
231223
success = closed,
232224
operation = "nexus_close_dump_analyze_session",
233225
status = closed ? "completed" : "warning",
234226
message = closed
235227
? $"Session closed: {sessionId}"
236228
: $"Session may have already been closed: {sessionId}",
237-
238-
// WORKFLOW GUIDANCE
239-
nextCommand = closed ? "nexus_open_dump_analyze_session" : null,
240-
nextCommandParameters = closed ? new { dumpPath = "<new-dump-file-path>" } : null,
241-
workflow = closed ? "Session closed successfully. Use nexus_open_dump_analyze_session to start a new session." : "Session cleanup in progress.",
242-
243-
// CRITICAL REMINDERS
244-
closedSessionId = sessionId, // Extra copy for tracking
245-
resourcesFreed = closed,
246-
instructions = closed ? "Session successfully closed. Start new session with nexus_open_dump_analyze_session if needed." : "Session cleanup in progress."
229+
toolusage = TOOL_USAGE_EXPLANATION
247230
};
248231

249232
logger.LogInformation("✅ Session {SessionId} closed successfully", sessionId);
@@ -335,31 +318,17 @@ private object ExecuteCommandSync(string sessionId, string command)
335318
var commandId = commandQueue.QueueCommand(command);
336319
var context = sessionManager.GetSessionContext(sessionId);
337320

338-
// Return comprehensive response with all critical information
321+
// Return simplified response with essential information
339322
var response = new
340323
{
341-
// CRITICAL IDENTIFIERS - Always include these
342324
sessionId = sessionId,
343325
dumpFile = context?.DumpPath != null ? Path.GetFileName(context.DumpPath) : null,
344326
commandId = commandId,
345-
346-
// OPERATION STATUS
347327
success = true,
348328
operation = "nexus_dump_analyze_session_async_command",
349329
status = "queued",
350330
message = $"Command queued: {commandId}",
351-
352-
// WORKFLOW GUIDANCE
353-
nextCommand = "nexus_dump_analyze_session_async_command_status",
354-
nextCommandParameters = new { commandId = commandId },
355-
workflow = "STEP 2 COMPLETE → NEXT: nexus_dump_analyze_session_async_command_status → POLL until status='completed'",
356-
357-
// CRITICAL REMINDERS
358-
extractCommandId = commandId, // Extra copy for extraction
359-
useThisCommandId = commandId, // Another copy for clarity
360-
useThisSessionId = sessionId, // Session reminder
361-
instructions = $"SAVE this commandId '{commandId}' and use it in nexus_dump_analyze_session_async_command_status to get results!",
362-
polling = "Check nexus_dump_analyze_session_async_command_status every 3-5 seconds until status='completed'"
331+
toolusage = TOOL_USAGE_EXPLANATION
363332
};
364333

365334
logger.LogInformation("✅ Command {CommandId} queued in session {SessionId}", commandId, sessionId);
@@ -506,48 +475,18 @@ var r when r.Contains("failed") => "failed",
506475
_ => "completed"
507476
};
508477

509-
// Return comprehensive response with all critical information
478+
// Return simplified response with essential information
510479
var response = new
511480
{
512-
// CRITICAL IDENTIFIERS - Always include these
513481
sessionId = sessionId,
514482
dumpFile = context?.DumpPath != null ? Path.GetFileName(context.DumpPath) : null,
515483
commandId = commandId,
516-
517-
// OPERATION STATUS
518484
success = true,
519485
operation = "nexus_dump_analyze_session_async_command_status",
520486
status = status,
521487
message = $"Command status: {status}",
522-
523-
// COMMAND RESULT
524488
result = result,
525-
debuggerOutput = result, // Extra copy for clarity
526-
527-
// WORKFLOW GUIDANCE
528-
isComplete = status is "completed" or "failed" or "cancelled",
529-
nextCommand = status is "completed" or "failed" or "cancelled" ? null : "nexus_dump_analyze_session_async_command_status",
530-
nextCommandParameters = status is "completed" or "failed" or "cancelled" ? null : new { commandId = commandId },
531-
workflow = status switch
532-
{
533-
"queued" or "executing" => "POLLING: Call nexus_dump_analyze_session_async_command_status again in 3-5 seconds",
534-
"completed" => "STEP 3 COMPLETE → Use 'result' field for debugger output → Call nexus_close_dump_analyze_session when done",
535-
"failed" => "COMMAND FAILED → Check 'result' for error details → Try new command or nexus_close_dump_analyze_session",
536-
_ => "Check status and continue as needed"
537-
},
538-
539-
// CRITICAL REMINDERS
540-
extractResult = status == "completed" ? result : null, // Extra copy for extraction
541-
useThisCommandId = commandId, // Command reminder
542-
useThisSessionId = sessionId, // Session reminder
543-
instructions = status switch
544-
{
545-
"queued" or "executing" => $"Command '{commandId}' still processing. Check again in 3-5 seconds.",
546-
"completed" => $"Command '{commandId}' completed! Use the 'result' field for debugger output.",
547-
"failed" => $"Command '{commandId}' failed. Check 'result' field for error details.",
548-
_ => $"Command '{commandId}' status: {status}"
549-
},
550-
polling = status is "queued" or "executing" ? "Check nexus_dump_analyze_session_async_command_status again in 3-5 seconds" : null
489+
toolusage = TOOL_USAGE_EXPLANATION
551490
};
552491

553492
return response;

mcp_nexus/mcp_nexus.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
<TargetFramework>net8.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
7-
<Version>1.0.3.5</Version>
8-
<AssemblyVersion>1.0.3.5</AssemblyVersion>
9-
<FileVersion>1.0.3.5</FileVersion>
7+
<Version>1.0.3.6</Version>
8+
<AssemblyVersion>1.0.3.6</AssemblyVersion>
9+
<FileVersion>1.0.3.6</FileVersion>
1010
<Product>MCP Nexus</Product>
1111
<Description>Model Context Protocol Server for Windows Debugging Tools</Description>
1212
<Company>MCP Nexus</Company>

0 commit comments

Comments
 (0)