Class TaskWorkflowBridge

java.lang.Object
neqsim.mcp.runners.TaskWorkflowBridge

public final class TaskWorkflowBridge extends Object
Bridges MCP tool outputs to the task_solve results.json format used by the NeqSim engineering task-solving workflow.

The task_solve workflow (docs/development/TASK_SOLVING_GUIDE.md) expects a results.json file with specific keys: key_results, validation, approach, conclusions, figure_captions, figure_discussion, equations, tables, references, uncertainty, risk_evaluation.

This class takes raw MCP tool outputs (flash results, process results, PVT data, etc.) and transforms them into the task_solve results.json schema so that the report generator (step3_report/generate_report.py) can produce professional engineering reports.

Version:
1.0
Author:
Even Solbraa
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final com.google.gson.Gson
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Private constructor — utility class.
  • Method Summary

    Modifier and Type
    Method
    Description
    private static String
    convertToResultsJson(com.google.gson.JsonObject input)
    Converts tool output to the task_solve results.json format.
    private static String
    errorJson(String message)
    Formats an error response.
    private static void
    extractEconomicsResults(com.google.gson.JsonObject output, com.google.gson.JsonObject kr)
    Extracts key economics results.
    private static void
    extractFlashResults(com.google.gson.JsonObject output, com.google.gson.JsonObject kr)
    Extracts key flash results.
    private static com.google.gson.JsonObject
    extractKeyResults(com.google.gson.JsonObject output, String runner)
    Extracts key results from various tool outputs.
    private static void
    extractPipelineResults(com.google.gson.JsonObject output, com.google.gson.JsonObject kr)
    Extracts key pipeline results.
    private static void
    extractProcessResults(com.google.gson.JsonObject output, com.google.gson.JsonObject kr)
    Extracts key process results.
    private static void
    extractPVTResults(com.google.gson.JsonObject output, com.google.gson.JsonObject kr)
    Extracts key PVT results.
    private static void
    extractStandardsResults(com.google.gson.JsonObject output, com.google.gson.JsonObject kr)
    Extracts key standards results.
    private static com.google.gson.JsonObject
    extractValidation(com.google.gson.JsonObject output)
    Extracts validation information from tool output.
    private static String
    Returns the results.json schema documentation.
    static String
    run(String json)
    Converts MCP tool output into task_solve results.json format.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • GSON

      private static final com.google.gson.Gson GSON
  • Constructor Details

    • TaskWorkflowBridge

      private TaskWorkflowBridge()
      Private constructor — utility class.
  • Method Details

    • run

      public static String run(String json)
      Converts MCP tool output into task_solve results.json format.

      Input JSON format:

      {
        "action": "toResultsJson",
        "toolOutput": { ... },        // Raw output from any MCP tool
        "sourceRunner": "runFlash",    // Which tool produced this
        "taskTitle": "Methane density analysis",
        "approach": "Used SRK EOS with classic mixing rule",
        "conclusions": "Density matches NIST within 2%"
      }
      
      Parameters:
      json - the bridge request JSON
      Returns:
      JSON in task_solve results.json format
    • convertToResultsJson

      private static String convertToResultsJson(com.google.gson.JsonObject input)
      Converts tool output to the task_solve results.json format.
      Parameters:
      input - the bridge request with toolOutput, sourceRunner, etc.
      Returns:
      complete results.json content
    • extractKeyResults

      private static com.google.gson.JsonObject extractKeyResults(com.google.gson.JsonObject output, String runner)
      Extracts key results from various tool outputs.
      Parameters:
      output - raw tool output
      runner - the source runner name
      Returns:
      key_results object with labeled values
    • extractFlashResults

      private static void extractFlashResults(com.google.gson.JsonObject output, com.google.gson.JsonObject kr)
      Extracts key flash results.
      Parameters:
      output - flash tool output
      kr - key_results to populate
    • extractProcessResults

      private static void extractProcessResults(com.google.gson.JsonObject output, com.google.gson.JsonObject kr)
      Extracts key process results.
      Parameters:
      output - process tool output
      kr - key_results to populate
    • extractPVTResults

      private static void extractPVTResults(com.google.gson.JsonObject output, com.google.gson.JsonObject kr)
      Extracts key PVT results.
      Parameters:
      output - PVT tool output
      kr - key_results to populate
    • extractPipelineResults

      private static void extractPipelineResults(com.google.gson.JsonObject output, com.google.gson.JsonObject kr)
      Extracts key pipeline results.
      Parameters:
      output - pipeline tool output
      kr - key_results to populate
    • extractStandardsResults

      private static void extractStandardsResults(com.google.gson.JsonObject output, com.google.gson.JsonObject kr)
      Extracts key standards results.
      Parameters:
      output - standards tool output
      kr - key_results to populate
    • extractEconomicsResults

      private static void extractEconomicsResults(com.google.gson.JsonObject output, com.google.gson.JsonObject kr)
      Extracts key economics results.
      Parameters:
      output - economics tool output
      kr - key_results to populate
    • extractValidation

      private static com.google.gson.JsonObject extractValidation(com.google.gson.JsonObject output)
      Extracts validation information from tool output.
      Parameters:
      output - raw tool output
      Returns:
      validation object
    • getResultsJsonSchema

      private static String getResultsJsonSchema()
      Returns the results.json schema documentation.
      Returns:
      JSON describing the task_solve results.json schema
    • errorJson

      private static String errorJson(String message)
      Formats an error response.
      Parameters:
      message - the error message
      Returns:
      JSON error string