Create MCP Tools

From QPR ProcessAnalyzer Wiki
Revision as of 08:46, 28 April 2026 by Ollvihe (talk | contribs) (Created page with "== 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 re...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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.
  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 Configuration

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.

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",
    "description": "Example MCP tool description",
    "annotations": {
        "destructiveHint": true,
        "idempotentHint": true,
        "openWorldHint": true,
        "readOnlyHint": false
    }
}

Defining 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" }
}

Defining 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"}
      }
    }
  }
}

Testing MCP tools in 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"}
}