How to build an MCP Tool.

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


This Tutorial Teaches you to:

Connect an AI model to your running FrameworX solution and query live operational data using Model Context Protocol (MCP).

Prerequisites:


Overview

AI MCP for Runtime exposes your solution data to AI models like Claude, enabling natural language queries against your industrial system. This tutorial covers:

Built-in Tools (Ready to Use)

Every FrameworX solution includes three pre-configured MCP tools:

ToolPurpose
runtime_get_valueQuery current tag values and metadata from the live Unified Namespace
runtime_browse_unsExplore the namespace structure to discover available tags
runtime_search_tagsFind tags by partial name or description
runtime_get_tag_historyRetrieve historical data for trend analysis
runtime_get_active_alarmsGet currently active alarms
runtime_query_alarm_historyQuery past alarm records from the Alarm Historian

Custom Tools (When You Need Specific features)

When built-in tools aren't enough, you can create custom MCP tools using Script Classes. Custom tools let you:

  • Expose solution-specific calculations or KPIs
  • Combine multiple data sources into a single query
  • Add business logic or validation before returning data
  • Create specialized queries for your process

What You'll Learn

  1. Steps 1-2: Create custom MCP tools (optional — skip if built-in tools are sufficient)
  2. Steps 3-4: Configure Claude Desktop to connect to your running solution
  3. Step 5: Query your solution using natural language

Note: This tutorial covers AI MCP for Runtime, which queries live data from running solutions. For AI-assisted solution configuration (creating tags, displays, etc.), see AI MCP for Designer Tutorial.

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

Naming Convention: Use the runtime_ prefix for your custom methods to distinguish them from Designer tools. Use snake_case (e.g., runtime_get_tank_level).


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 your solution using natural language. Claude will automatically select the appropriate tool.

Reading Live Values (runtime_get_value):

  • "What is the Server.SystemMonitor.Uptime?"
  • "What is the value of tag Facility1.Sector4.Machine2.Pressure?"
  • "Get the current temperature from Tag.Plant1/Line2/Temp"

Browsing the Namespace (runtime_browse_uns):

  • "What tags are available under Tag.Plant1?"
  • "Show me the structure of the Tag namespace"

Searching for Tags (runtime_search_tags):

  • "Find all tags containing 'Temperature'"
  • "Search for tags related to 'pump'"

Historical Data (runtime_get_tag_history):

  • "Show me the temperature history for today"
  • "Get historian data for Tag.Pressure from 8am to noon"

Alarms (runtime_get_active_alarms, runtime_query_alarm_history):

  • "Are there any active alarms?"
  • "Show me alarms from the last 24 hours"

Built-in Tools Summary:

ToolWhen to Use
runtime_get_valueCurrent values, system status, alarm counts
runtime_browse_unsDiscover what tags exist in a folder
runtime_search_tagsFind tags when you don't know the exact path
runtime_get_tag_historyHistorical trends and past values
runtime_get_active_alarmsCurrent alarm state
runtime_query_alarm_historyPast alarm events and patterns


For custom methods you created (Steps 1-2), just describe what you need and Claude will use them.

More examples and complete tool reference: AI MCP for Runtime 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...