How to build an MCP Tool.

Tutorials → 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. This tutorial was done using ClaudeAI.

Prerequisites:


The steps 1 and 2 are only necessary if you want to create custom methods. If it is not your case, you can go directly to step 3. 

By default, in any solution you run, you have the following methods:

  • Get value – Retrieves the value of a specific tag. You must provide the full path of the tag if it is located in lower levels of the Asset Tree.

  • Get tag historian – Retrieves historical values from a tag. The tag must be stored in a historian database.

  • Get alarm online – Retrieves all information related to current and historical alarms.

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: Runtime

  1. Make sure ClaudeAI is closed in the Windows Task Manager.
  2. Run your solution.

Step 4: Configure Claude AI

  1. Have Claude AI Desktop downloaded

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

  3. Copy and paste the .json content into the ”claude_desktop_config.json”:

    {
      "mcpServers": {
        "<SolutionName>": {
          "command": "<ProductPath>\\fx-10\\net8.0\\TMCPServerStdio\\TMCPServerStdio.exe",
          "args": [ "/host:127.0.0.1", "/port:<port>" ],
          "transport": "stdio"
        }
      }
    }
  4. Replace the placeholders with the following values (including the < and > characters):
    <SolutionName>: Any name of your choice; it serves only as an identifier.
    <ProductPath>: The directory where the product was installed. You can find this in Solution Center > About FrameworX > InstalledPath.
    <Port>: The port on which your solution is running. This can be found in Designer > Solution > Settings > Port.

    The <ProductPath> has to have double counter slash instead of one.

  5. Save and close the file.
  6. Close Claude completely (it must be closed through the Windows Task Manager).
  7. Open Claude again.
  8. Go to Settings → Developer; it should display “running”.

  9. Open a new chat and click the Search and Tools icon. You should see the name of your solution there.

Step 5: Query in Claude AI

You can query any method in a Claude chat. e.g: “What is the Server.SystemMonitor.Uptime?” or "What is the value of tag Facility1.Sector4.Machine2.Pressure" and it returns the value requested.

By default, in any solution you have the following methods:

  • Get tag historian

  • Get alarm online

  • Get value

And you also can create custom methods in the scripts like shown in steps 1 and 2. More examples and information about the queries and custom methods, you can find in: AI MCP Tool Connector.

Troubleshoot

If when you open ClaudeAI and you don't see you solution in Search and Tools:

  1. Check if the ”claude_desktop_config.json” file is correct.
  2. Close the LLM completely (including in the Windows Task Manager) and open it again.

In this section...