MCP Tool Examples: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
| (4 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
This page contains example scripts | This page contains example scripts intended for use as MCP tools. When developing MCP tool scripts, make sure they return a string value, as this is required for the MCP client's LLM to interpret the output correctly. | ||
== List of Models == | == List of Models == | ||
Returns all models accessible for the user (in a CSV data) with following fields: Model name, Containing project name, Model ID, Case attributes, Event attributes, Case count, and Event count. | Returns all models accessible for the user (in a CSV data) with following fields: Model name, Containing project name, Model ID, Case attributes, Event attributes, Case count, and Event count. | ||
<syntaxhighlight lang="typescript" line> | <syntaxhighlight lang="typescript" line> | ||
let result = Query(#{ | let result = Query(#{ | ||
"Values": [ | "Values": [ | ||
| Line 51: | Line 48: | ||
"Root": "Models", | "Root": "Models", | ||
"ContextType": "generic" | "ContextType": "generic" | ||
}).Collect(); | |||
return result.ToCsv(); | |||
</syntaxhighlight> | |||
== Average case cost in specific model == | |||
Returns the average of the case Cost attribute value of all cases in the model with ID 1. | |||
<syntaxhighlight lang="typescript" line> | |||
let result = Query(#{ | |||
"Values": [ | |||
#{ | |||
"Name": "Average Cost", | |||
"Expression": "Column(\"Cost\")", | |||
"AggregationFunction": "average" | |||
} | |||
], | |||
"Dimensions": [], | |||
"Root": "Cases", | |||
"ModelId": 1, | |||
"ContextType": "model", | |||
"ProcessingMethod": "dataframe" | |||
}).Collect(); | }).Collect(); | ||
return result.ToCsv(); | return result.ToCsv(); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Latest revision as of 00:40, 17 April 2026
This page contains example scripts intended for use as MCP tools. When developing MCP tool scripts, make sure they return a string value, as this is required for the MCP client's LLM to interpret the output correctly.
List of Models
Returns all models accessible for the user (in a CSV data) with following fields: Model name, Containing project name, Model ID, Case attributes, Event attributes, Case count, and Event count.
let result = Query(#{
"Values": [
#{
"Name": "Model name",
"Expression": "Name"
},
#{
"Name": "Containing project name",
"Expression": "Project.Name"
},
#{
"Name": "Model ID",
"Expression": "Id"
},
#{
"Name": "Case attributes",
"Expression": "ToJson(If(Status==\"Online\",OrderByValue(Flatten(EventLog.CaseAttributes.Name)), CasesDatatable?.ColumnNames ?? []))"
},
#{
"Name": "Event attributes",
"Expression": "ToJson(If(Status==\"Online\",OrderByValue(Flatten(EventLog.EventAttributes.Name)), EventsDatatable?.ColumnNames ?? []))"
},
#{
"Name": "Case count",
"Expression": "CasesDatatable?.NRows"
},
#{
"Name": "Event count",
"Expression": "EventsDatatable?.NRows"
}
],
"Ordering": [
#{
"Name": "Containing project name",
"Direction": "Ascending"
},
#{
"Name": "Model name",
"Direction": "Ascending"
}
],
"Dimensions": null,
"Root": "Models",
"ContextType": "generic"
}).Collect();
return result.ToCsv();
Average case cost in specific model
Returns the average of the case Cost attribute value of all cases in the model with ID 1.
let result = Query(#{
"Values": [
#{
"Name": "Average Cost",
"Expression": "Column(\"Cost\")",
"AggregationFunction": "average"
}
],
"Dimensions": [],
"Root": "Cases",
"ModelId": 1,
"ContextType": "model",
"ProcessingMethod": "dataframe"
}).Collect();
return result.ToCsv();