EPICS Process Variable Bridge MCP server

Provides a bridge between AI and EPICS process variables, enabling real-time monitoring and control of industrial systems through tools for getting, setting, and retrieving detailed information about hardware systems.
Back to servers
Setup instructions
Provider
Yan Jiang
Release date
Apr 25, 2025
Language
Python
Stats
2 stars

The EPICS MCP Server enables interactions with EPICS (Experimental Physics and Industrial Control System) process variables through a Python-based interface. It allows retrieving and setting PV values as well as fetching detailed PV information using the Model Context Protocol framework.

Prerequisites

EPICS Installation

Before using the EPICS MCP Server, you must have EPICS properly installed on your machine with a functioning IOC. Verify that basic EPICS commands like caget, caput, and cainfo work correctly.

For EPICS installation instructions, visit the EPICS Controls website.

Example of a working EPICS setup:

jiangyan@DESKTOP-84CO9VB:~$ softIoc -d ~/EPICS/DB/test.db
Starting iocInit
############################################################################
## EPICS R7.0.8
## Rev. 2025-02-13T14:29+0800
## Rev. Date build date/time:
############################################################################
iocRun: All initialization complete
epics>

Verify EPICS commands are working:

jiangyan@DESKTOP-84CO9VB:~$ caget temperature:water
temperature:water              88
jiangyan@DESKTOP-84CO9VB:~$ caput temperature:water 100
Old : temperature:water              88
New : temperature:water              100
jiangyan@DESKTOP-84CO9VB:~$ cainfo temperature:water
temperature:water
    State:            connected
    Host:             127.0.0.1:5056
    Access:           read, write
    Native data type: DBF_DOUBLE
    Request type:     DBR_DOUBLE
    Element count:    1

Installation

Install the required dependencies:

pip install -r requirements.txt

Server Features

The EPICS MCP Server provides three main tools:

1. get_pv_value

Retrieves the current value of a specified PV.

Inputs:

  • pv_name (string): The name of the PV variable.

Returns: A JSON object containing the status (success or error) and the retrieved value or an error message.

2. set_pv_value

Sets a new value for a specified PV.

Inputs:

  • pv_name (string): The name of the PV variable.
  • pv_value (string): The new value to be set for the PV.

Returns: A JSON object containing the status (success or error) and a confirmation message or an error message.

3. get_pv_info

Fetches detailed information about a specified PV.

Inputs:

  • pv_name (string): The name of the PV variable.

Returns: A JSON object containing the status (success or error) and the detailed information about the PV or an error message.

Usage with Langchain

To use the EPICS MCP Server with Langchain, initialize the server parameters as follows:

server_params = StdioServerParameters(
    command="python",
    # Make sure to update to the full absolute path to your server.py file
    args=["/path/server.py"],
)

Example Client Implementation

Here's an example of how to create a client to interact with the server:

async def run():
    async with stdio_client(server_params) as (read, write):
        async with ClientSession(read, write) as session:
            # Initialize the connection
            await session.initialize()

            # Get tools
            tools = await load_mcp_tools(session)

            # Create and run the agent
            agent = create_react_agent(model, tools)
            agent_response = await agent.ainvoke({"messages": "To query the value of a PV (Process Variable) named temperature:water"})
            return agent_response

Example Output

When querying a PV value:

================================[1m Human Message [0m=================================

To query the value of a PV (Process Variable) named temperature:water
==================================[1m Ai Message [0m==================================
Tool Calls:
  get_pv_value (call_vvbXwi51CyYUxEM0hcyvCFCY)
 Call ID: call_vvbXwi51CyYUxEM0hcyvCFCY
  Args:
    pv_name: temperature:water
=================================[1m Tool Message [0m=================================
Name: get_pv_value

{
  "status": "success",
  "value": 88.0
}
==================================[1m Ai Message [0m==================================

The current value of the PV named `temperature:water` is 88.0.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "epics-mcp-server" '{"command":"python","args":["/path/server.py"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "epics-mcp-server": {
            "command": "python",
            "args": [
                "/path/server.py"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "epics-mcp-server": {
            "command": "python",
            "args": [
                "/path/server.py"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later