How to build an MCP Tool.
Tutorials → Technology Learning Tutorial → AI Runtime 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:
- Cross-platform .NET Desktop Runtime matching your FrameworX version installed (.NET 8 for 10.1.4 and earlier, .NET 10 for 10.1.5 and later)
Overview
AI 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 six pre-configured MCP tools:
| Tool | Purpose |
|---|---|
| runtime_get_value | Query current tag values and metadata from the live Unified Namespace |
| runtime_browse_object_model | Explore the namespace structure to discover available tags |
| runtime_search_uns | Find tags by partial name or description |
| runtime_get_tag_history | Retrieve historical data for trend analysis |
| runtime_get_active_alarms | Get currently active alarms |
| runtime_query_alarm_history | Query 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
- Steps 1-2: Create custom MCP tools (optional — skip if built-in tools are sufficient)
- Steps 3-4: Configure Claude Desktop to connect to your running solution
- Step 5: Query your solution using natural language
Note: This tutorial covers AI Runtime, which queries live data from running solutions. For AI-assisted solution configuration (creating tags, displays, etc.), see AI Designer In Action.
Step 1: Create the MCP script
- Navigate to Scripts → Classes
- Click in the create a New Class button
- In Create new Code, select MCPTool
- 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
- Make sure ClaudeAI is closed in the Windows Task Manager.
- Run your solution.
Step 4: Configure Claude AI
- Have Claude AI Desktop downloaded
- Go in Settings → Developer → Edit Config and open the "claude_desktop_config.json" in Notepad.
- Copy and paste the .json content into the "claude_desktop_config.json":
{
"mcpServers": {
"<SolutionName>": {
"command": "<ProductPath>\\fx-10\\net10.0\\RuntimeMCP.exe",
"args": [ "/host:127.0.0.1", "/port:<port>" ],
"transport": "stdio"
}
}
}
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. The example above uses
net10.0, which is the default for FrameworX 10.1.5 and later. For 10.1.4 and earlier, usenet8.0instead.For AI-assisted solution authoring (creating tags, displays, scripts) rather than runtime queries, see the AI Designer In Action tutorial — it covers DesignerMCP for configuring solutions via AI.
Save and close the file.
Close Claude completely (it must be closed through the Windows Task Manager).
Open Claude again.
Go to Settings → Developer; it should display "running".
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_object_model):
- "What tags are available under Tag.Plant1?"
- "Show me the structure of the Tag namespace"
Searching for Tags (runtime_search_uns):
- "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:
| Tool | When to Use |
|---|---|
| runtime_get_value | Current values, system status, alarm counts |
| runtime_browse_object_model | Discover what tags exist in a folder |
| runtime_search_uns | Find tags when you don't know the exact path |
| runtime_get_tag_history | Historical trends and past values |
| runtime_get_active_alarms | Current alarm state |
| runtime_query_alarm_history | Past 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 Runtime Connector.
Troubleshoot
If when you open ClaudeAI and you don't see your solution in Search and Tools:
- Check if the "claude_desktop_config.json" file is correct.
- Close the LLM completely (including in the Windows Task Manager) and open it again.
In this section...