feat(mcp-server): advanced tools — wait/analyze/suggest/estimate (Phase 2)
Add four tools closing the submit→watch→analyze→suggest loop in the request/response MCP model: - scheduler_wait_job: poll a job to a terminal state or timeout. - scheduler_analyze_failure: gather job record + output logs for failure analysis (interpretation left to the LLM). - scheduler_suggest_resources: conservative processor/node suggestions from current cluster availability. - scheduler_estimate_wait_time: rough wait estimate from pending count and free cores (guidance, not a guarantee). All verified live on t1 against the running apiserver. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
c8bd8fe896
commit
59531d19ed
2 changed files with 231 additions and 0 deletions
|
|
@ -112,6 +112,53 @@ func main() {
|
|||
mcp.WithDestructiveHintAnnotation(false),
|
||||
), app.HandleClusterMetrics)
|
||||
|
||||
// ── advanced tools (Phase 2) ──
|
||||
// These help the agent close the submit → watch → analyze → suggest loop
|
||||
// against the request/response MCP model.
|
||||
|
||||
// ── scheduler_wait_job ──
|
||||
s.AddTool(mcp.NewTool("scheduler_wait_job",
|
||||
mcp.WithDescription("Poll a job until it reaches a terminal state (DONE/EXIT) or a timeout. Returns the final status and elapsed time. Use after scheduler_submit to follow a job to completion."),
|
||||
mcp.WithString("id",
|
||||
mcp.Description("Job ID to wait for"),
|
||||
mcp.Required(),
|
||||
),
|
||||
mcp.WithNumber("timeout_s", mcp.Description("Maximum seconds to wait (default 120)")),
|
||||
mcp.WithNumber("poll_interval_s", mcp.Description("Poll interval seconds (default 3)")),
|
||||
mcp.WithReadOnlyHintAnnotation(true),
|
||||
mcp.WithDestructiveHintAnnotation(false),
|
||||
), app.HandleWaitJob)
|
||||
|
||||
// ── scheduler_analyze_failure ──
|
||||
s.AddTool(mcp.NewTool("scheduler_analyze_failure",
|
||||
mcp.WithDescription("Gather everything about a failed (EXIT) job — job info, execution hosts, and output logs — for failure analysis. Returns structured data; interpret the likely cause from the logs and job metadata."),
|
||||
mcp.WithString("id",
|
||||
mcp.Description("Job ID of the failed job"),
|
||||
mcp.Required(),
|
||||
),
|
||||
mcp.WithNumber("log_tail", mcp.Description("Max log lines to include (default 200)")),
|
||||
mcp.WithReadOnlyHintAnnotation(true),
|
||||
mcp.WithDestructiveHintAnnotation(false),
|
||||
), app.HandleAnalyzeFailure)
|
||||
|
||||
// ── scheduler_suggest_resources ──
|
||||
s.AddTool(mcp.NewTool("scheduler_suggest_resources",
|
||||
mcp.WithDescription("Suggest resource parameters (processors, walltime, memory) for a job based on current node capacity and queue state. Returns concrete recommendations for scheduler_submit."),
|
||||
mcp.WithString("command", mcp.Description("The command the job will run (used to gauge footprint)")),
|
||||
mcp.WithString("queue", mcp.Description("Target queue (default normal)")),
|
||||
mcp.WithReadOnlyHintAnnotation(true),
|
||||
mcp.WithDestructiveHintAnnotation(false),
|
||||
), app.HandleSuggestResources)
|
||||
|
||||
// ── scheduler_estimate_wait_time ──
|
||||
s.AddTool(mcp.NewTool("scheduler_estimate_wait_time",
|
||||
mcp.WithDescription("Estimate how long a pending job would wait before dispatch, based on current pending jobs, node capacity, and queue state. Returns a rough estimate — treat as guidance, not a guarantee."),
|
||||
mcp.WithString("queue", mcp.Description("Target queue (default normal)")),
|
||||
mcp.WithNumber("processors", mcp.Description("Number of processors the job requests (default 1)")),
|
||||
mcp.WithReadOnlyHintAnnotation(true),
|
||||
mcp.WithDestructiveHintAnnotation(false),
|
||||
), app.HandleEstimateWaitTime)
|
||||
|
||||
// ── write tools (Phase 1) ──
|
||||
// Write tools are annotated destructive so the MCP client (e.g. Claude
|
||||
// Code) prompts the user for confirmation before executing them — the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue