Create MCP Tools: Difference between revisions

From QPR ProcessAnalyzer Wiki
Jump to navigation Jump to search
(TK-64611)
Line 11: Line 11:


== MCP Tool Settings ==
== MCP Tool Settings ==
Every script can define its own '''McpTool''' configuration as JSON. Supported values are same as [https://modelcontextprotocol.io/specification/2025-11-25/server/tools#tool here], except for the '''name''' which is always generated automatically and can't be overridden. Defining the McpTool configuration will override any default configurations generated for scripts automatically by QPR ProcessAnalyzer. For example, specifying the value for "title" here will override the default functionality of using script's name as title of the tool.
<br>
'''Example''': The following JSON configures the MCP tool with a customized title and description, as well as some additional [https://github.com/modelcontextprotocol/csharp-sdk/blob/main/src/ModelContextProtocol.Core/Protocol/ToolAnnotations.cs MCP tool annotations]:<syntaxhighlight lang="json">
{
    "title": "Example MCP tool title",
    "description": "Example MCP tool description",
    "annotations": {
        "destructiveHint": true,
        "idempotentHint": true,
        "openWorldHint": true,
        "readOnlyHint": false
    }
}
</syntaxhighlight>


=== Defining Input Parameters ===
=== Input Parameters ===
MCP tool input parameters are defined using a JSON schema following the [https://modelcontextprotocol.io/specification/2025-11-25/basic#json-schema-usage Model Context Protocol's JSON Schema]. Each supported input parameter is listed under '''properties'''. By default, script don't enforce any schema.<br>
MCP tool input parameters are defined using a JSON schema following the [https://modelcontextprotocol.io/specification/2025-11-25/basic#json-schema-usage Model Context Protocol's JSON Schema]. Each supported input parameter is listed under '''properties'''. By default, script don't enforce any schema.<br>


Line 73: Line 59:
</syntaxhighlight>
</syntaxhighlight>


=== Defining Structured Tool Output ===
=== Structured Tool Output ===
Structured tool output is described using a JSON schema following the [https://modelcontextprotocol.io/specification/2025-11-25/basic#json-schema-usage Model Context Protocol's JSON Schema]. By default, scripts don't enforce any schema and the result is considered to be just text.
Structured tool output is described using a JSON schema following the [https://modelcontextprotocol.io/specification/2025-11-25/basic#json-schema-usage Model Context Protocol's JSON Schema]. By default, scripts don't enforce any schema and the result is considered to be just text.
<br>
<br>
Line 108: Line 94:
     }
     }
   }
   }
}
</syntaxhighlight>
=== MCP Tool Metadata ===
Every script can define its own '''McpTool''' configuration as JSON. Supported values are same as [https://modelcontextprotocol.io/specification/2025-11-25/server/tools#tool here], except for the '''name''' which is always generated automatically and can't be overridden. Defining the McpTool configuration will override any default configurations generated for scripts automatically by QPR ProcessAnalyzer. For example, specifying the value for "title" here will override the default functionality of using script's name as title of the tool.
Following annotations are available:
* '''destructiveHint''': Indicates that the MCP tool call deletes data which might be permanently lost. Some LLM agents ask for confirmation from the user, to make sure that destructive tool calls are not made by mistake.
* '''idempotentHint''': Indicates that all MCP tool calls with the same parameters always provide the same result. Some LLM agents may cache tool call results for idempotent MCP tools to improve performance and reduce load from the MCP server.
* '''openWorldHint''': Indicates that all MCP tool call in the MCP server will use external services. Open world tool calls are expected to be slower than usually.
* '''readOnlyHint''': Indicates that all MCP tool call does not change any data, and thus the call may not have any potentially undesired effects. Some LLM agents ask for confirmation from the user, to make sure that tool calls that change data are not made by mistake.
Example: The following JSON configures the MCP tool with a customized title and description, as well as some additional [https://github.com/modelcontextprotocol/csharp-sdk/blob/main/src/ModelContextProtocol.Core/Protocol/ToolAnnotations.cs MCP tool annotations]:<syntaxhighlight lang="json">
{
    "title": "Example MCP tool title",
    "annotations": {
        "destructiveHint": true,
        "idempotentHint": true,
        "openWorldHint": true,
        "readOnlyHint": false
    }
}
}
</syntaxhighlight>
</syntaxhighlight>

Revision as of 17:32, 17 May 2026

Creating MCP Tools

MCP tools are implemented using scripts written in QPR ProcessAnalyzer expression language. A script will be added as the MCP tool when the MCP tool checkbox is enabled in the Script Properties. Only system administrator users can enable the MCP tool checkbox. Also, scripts that are MCP tools, only system administrators can modify them because any changes to the MCP interface is restricted to system administrators for security reasons.

To enable a script as an MCP Tool:

  1. Log in to QPR ProcessAnalyzer as a System Administrator.
  2. Open or create the script.
  3. For the script to be used as an MCP tool, give it a name. This name is then used as the MCP tool name. It is important to ensure that every script intended for MCP use has a non-empty, valid name, as clients may fail to discover tools with invalid names. The maximum length of the name is 50 characters.
  4. Open the properties of the script.
  5. Switch to the MCP tab and select the MCP tool checkbox.
  6. Switch to the Description tab and provide a description. The description is added to the context of the client.

MCP Tool Settings

Input Parameters

MCP tool input parameters are defined using a JSON schema following the Model Context Protocol's JSON Schema. Each supported input parameter is listed under properties. By default, script don't enforce any schema.

Example: The following schema defines a script with five different types of parameters:

{
  "type": "object",
  "properties": {
    "stringParameter": {
      "type": "string",
      "description": "String parameter"
    },
	"numberParameter": {
	  "type": "number",
	  "description": "Number parameter"
	},
	"booleanParameter": {
	  "type": "boolean",
	  "description": "Boolean parameter"
	},
	"arrayParameter": {
	  "type": "array",
	  "description": "Array parameter",
	  "nullable": true,
	  "items": {
		  "type": "integer"
	  }
	},
	"objectParameter": {
	  "type": "object",
	  "description": "Object parameter",
	  "properties": {
	    "inner": {"type": "string"}
	  }
	}
  }
}


After this, the tool can be called, for example, with the following set of parameters:

{
  "stringParameter": "hello",
  "numberParameter": 123.456,
  "booleanParameter": true,
  "arrayParameter": [ 1, 2, 3 ],
  "objectParameter": { "inner": "test" }
}

Structured Tool Output

Structured tool output is described using a JSON schema following the Model Context Protocol's JSON Schema. By default, scripts don't enforce any schema and the result is considered to be just text.

Example: The following example configures the script's return value to contain an object having the "models" property with information about each model:

{
  "type": "object",
  "properties": {
    "string": {
      "type": "string",
      "description": "String value"
    },
    "number": {
      "type": "number",
      "description": "Number value"
    },
    "boolean": {
      "type": "boolean",
      "description": "Boolean value"
    },
    "array": {
      "type": "array",
      "description": "Array value",
      "nullable": true,
      "items": {
        "type": "integer"
      }
    },
    "object": {
      "type": "object",
      "description": "Object value",
      "properties": {
        "inner": {"type": "string"}
      }
    }
  }
}

MCP Tool Metadata

Every script can define its own McpTool configuration as JSON. Supported values are same as here, except for the name which is always generated automatically and can't be overridden. Defining the McpTool configuration will override any default configurations generated for scripts automatically by QPR ProcessAnalyzer. For example, specifying the value for "title" here will override the default functionality of using script's name as title of the tool.

Following annotations are available:

  • destructiveHint: Indicates that the MCP tool call deletes data which might be permanently lost. Some LLM agents ask for confirmation from the user, to make sure that destructive tool calls are not made by mistake.
  • idempotentHint: Indicates that all MCP tool calls with the same parameters always provide the same result. Some LLM agents may cache tool call results for idempotent MCP tools to improve performance and reduce load from the MCP server.
  • openWorldHint: Indicates that all MCP tool call in the MCP server will use external services. Open world tool calls are expected to be slower than usually.
  • readOnlyHint: Indicates that all MCP tool call does not change any data, and thus the call may not have any potentially undesired effects. Some LLM agents ask for confirmation from the user, to make sure that tool calls that change data are not made by mistake.

Example: The following JSON configures the MCP tool with a customized title and description, as well as some additional MCP tool annotations:

{
    "title": "Example MCP tool title",
    "annotations": {
        "destructiveHint": true,
        "idempotentHint": true,
        "openWorldHint": true,
        "readOnlyHint": false
    }
}

Testing MCP tools using QPR ProcessAnalyzer

When developing MCP tools, it might be useful try test them in QPR ProcessAnalyzer before publishing as MCP tools. Scripts (used as MCP tools) can be called in the Expression Designer. The following example expression calls a script with some parameters and shows the return value as json:

let returnValue = ScriptById(1).Run(#{
  "stringParameter": "hello",
  "numberParameter": 123.456,
  "booleanParameter": true,
  "arrayParameter": [1, 2, 3]
  "objectParameter": {
    "inner": "test"
  }
});
return ToJson(returnValue);

Now, if script having id 1 has the following script source code:

#{
  "string": stringParameter,
  "number": numberParameter,
  "boolean": booleanParameter,
  "array": arrayParameter,
  "object": objectParameter
}

and is configured as specified in the previous chapter, the result of expression will be the following valid JSON object as string:

{
  "string": "hello",
  "number": 123.456,
  "boolean": true,
  "array": [1,2,3],
  "object": {"inner": "text"}
}