You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 18 Next »

How to build an MCP Tool.

Scripts → Tutorial | Concept | How-to Guide | Reference


This Tutorial Teaches you to:

How to build an MCP (Model Context Protocol) Tool that exposes production KPIs and historical data to AI models, enabling intelligent analysis of industrial processes.

Prerequisites


Step 1: Create the MCP script

  1. Navigate to Scripts → Classes

  2. Click in the create a New Class button

  3. In Create new Code, select MCPTool

  4. Click OK

Step 2: Edit the Script

In the Script code, you can have multiple methods and they follow this format:

[McpServerTool, Description("<This is the question>")]
public string <MethodName> (
[Description("<Description of the parameter>")] <Parameters>)
{
	<Logic>

    <Return>
}

Example:

[McpServerTool, Description("Performs concatenation of two input text values.")]
public string Concat(
	[Description("The first text value to be used in the operation.")] string parameter1,
	[Description("The second text value to be used in the operation, concatenated after the first.")] string parameter2)
{
	return parameter1 + parameter2;
}



The logic can process the data and return it as a string, so the AI will receive it.

Step 3: Configure Claude AI

  1. Have Claude AI Desktop downloaded

  2. Go in Settings → Developer → Edit Config and select the ”claude_desktop_config.json”

  3. This .json should have the following content:

    {
      "mcpServers": {
        "<SolutionName>": {
          "command": "<ProductPath>\\fx-10\\net8.0\\TMCPServerStdio\\TMCPServerStdio.exe",
          "args": [ "/host:127.0.0.1", "/port:<port>" ],
          "transport": "stdio"
        }
      }
    }
  4. In the Developer setting it shoud show “running” and when you open a new chat in “Search and Tools” you will see the name of your solution there.

Step 4: Query in Claude AI

You can query any method in a Claude chat. e.g: “What is the tag value?” and it returns the value requested.

Besides the method you created in the script, you can ask general information about the solution, like:

  • Get tag historian

  • Get alarm online

  • Get value


These tutorials provide simple, practical starting points for both MCP Tools focusing on real industrial scenarios while keeping complexity minimal for learning purposes.


In this section...

The root page @parent could not be found in space FrameworX 10.1.



  • No labels