Home Applications iris-execute-mcp

iris-execute-mcp

InterSystems does not provide technical support for this project. Please contact its developer for the technical assistance.
0
0 reviews
0
Awards
7
Views
0
IPM installs
0
0
Details
Releases (1)
Reviews
Issues
MCP Server for executing methods, compiling classes and executing unit test in InterSystems IRIS

What's new in this version

Initial Release

IRIS Execute MCP Server

Complete MCP Integration for InterSystems IRIS - 9 Tools Production Ready! 🎉

The IRIS Execute MCP server provides 9 fully functional tools for comprehensive IRIS integration, including basic operations, compilation tools, and advanced unit testing capabilities with WorkMgr-based process isolation.

Current Tool Status ✅

Basic Tools (5):

  • execute_command: Direct ObjectScript execution with I/O CAPTURE - Real output capture!
  • execute_classmethod: Dynamic class method invocation with full parameter support
  • get_global: Dynamic global retrieval with complex subscripts
  • set_global: Dynamic global setting with verification
  • get_system_info: Real-time IRIS system information

Compilation Tools (2):

  • compile_objectscript_class: Compile one or more ObjectScript classes with error reporting
  • compile_objectscript_package: Compile all classes in a package recursively

Unit Testing Tools (2):

  • queue_unit_tests: Queue tests for async execution with WorkMgr-based process isolation
  • poll_unit_tests: Poll for test results with pass/fail counts and detailed information

Installation

Prerequisites

  • Python 3.8+
  • InterSystems IRIS 2024.3 or later
  • VS Code with Cline extension

Step 1: Clone and Setup

# Clone the repository
git clone https://github.com/jbrandtmse/iris-execute-mcp.git
cd iris-execute-mcp

Create virtual environment

python -m venv venv

Activate virtual environment

Windows:

venv\Scripts\activate

Linux/Mac:

source venv/bin/activate

Install dependencies

pip install -r requirements.txt

Step 2: Configure Environment

Create a .env file (copy from .env.example):

IRIS_HOSTNAME=localhost
IRIS_PORT=1972
IRIS_NAMESPACE=HSCUSTOM
IRIS_USERNAME=_SYSTEM
IRIS_PASSWORD=_SYSTEM

Step 3: Install IRIS Classes

  1. Open IRIS Studio or VS Code with ObjectScript extension
  2. Import classes from src/ExecuteMCP/Core/ directory
  3. Compile the ExecuteMCP package:
Do $System.OBJ.CompilePackage("ExecuteMCP")

Step 4: Configure Unit Testing (Optional)

If you plan to use the unit testing tools, configure the test root directory:

// Set the unit test root directory (create this directory first)
Set ^UnitTestRoot = "C:\temp"

// Verify configuration
Write ^UnitTestRoot

Important: The directory specified in ^UnitTestRoot must exist and be writable by IRIS.

Cline MCP Configuration

Step 1: Open Cline MCP Settings

  1. Open VS Code with Cline extension
  2. Open Settings (Ctrl + ,)
  3. Search for “MCP”
  4. Find “Cline > MCP: Servers”
  5. Click “Edit in settings.json”

Step 2: Production Configuration (All 9 Tools)

Add this to your Cline MCP settings:

{
  "iris-execute-mcp": {
    "autoApprove": [
      "execute_command",
      "execute_classmethod",
      "get_global",
      "set_global",
      "get_system_info",
      "compile_objectscript_class",
      "compile_objectscript_package",
      "queue_unit_tests",
      "poll_unit_tests"
    ],
    "disabled": false,
    "timeout": 60,
    "type": "stdio",
    "command": "C:/iris-execute-mcp/venv/Scripts/python.exe",
    "args": ["C:/iris-execute-mcp/iris_execute_mcp.py"],
    "env": {
      "IRIS_HOSTNAME": "localhost",
      "IRIS_PORT": "1972",
      "IRIS_NAMESPACE": "HSCUSTOM",
      "IRIS_USERNAME": "_SYSTEM",
      "IRIS_PASSWORD": "_SYSTEM"
    }
  }
}

Key Configuration Details:

Server Name: iris-execute-mcp
Script Name: iris_execute_mcp.py (consolidated server with all features)
9 Tools: 5 basic + 2 compilation + 2 unit testing tools
Virtual Environment: Uses isolated dependencies for reliability
Environment Variables: Proper IRIS connection configuration
Auto-Approve: All 9 tools approved for seamless AI workflows

Step 3: Restart and Test

  1. Save the settings.json file
  2. Restart VS Code completely
  3. Open a new Cline chat
  4. Test functionality:
    • “Show me IRIS system information”
    • “Execute: WRITE $ZV”
    • “Queue unit test ExecuteMCP.Test.SampleUnitTest”

Verification

Test Server Startup

# Navigate to project directory
cd C:/iris-execute-mcp

Activate virtual environment

venv\Scripts\activate

Test server startup

python iris_execute_mcp.py

Expected output:

INFO - Starting IRIS Execute FastMCP Server
INFO - IRIS Available: True
INFO - ✅ IRIS connectivity test passed
INFO - 🚀 FastMCP server ready for connections

Test Tools Directly

# Test all functionality
python test_execute_final.py

Test FastMCP integration

python test_fastmcp.py

Validate MVP implementation

python validate_mvp.py

Test unit test implementation

python test_unittest_final_validation.py

Tool Documentation

Basic Tools

execute_command

Execute ObjectScript commands with I/O capture:

# Examples:
"Execute: WRITE $ZV"
→ Returns actual IRIS version string

"Execute: SET ^MyGlobal = 123"
→ Returns "Command executed successfully"

execute_classmethod

Dynamically invoke ObjectScript class methods:

# Examples:
"Call GetVersion on %SYSTEM.Version"
→ Returns IRIS version details

"Call ABS on %SYSTEM.SQL.Functions with parameter -456"
→ Returns 456

get_global / set_global

Manage IRIS globals dynamically:

# Set a global
"Set global ^MyApp('Config','Version') to '1.0.0'"

Get a global

"Get the value of ^MyApp('Config','Version')"

get_system_info

Retrieve IRIS system information:

"What version of IRIS is running?"
→ Returns version, namespace, timestamp

Compilation Tools

compile_objectscript_class

Compile one or more ObjectScript classes with comprehensive error reporting.

IMPORTANT: Class names MUST include the .cls suffix for proper compilation.

# Compile single class (note the .cls suffix)
"Compile ObjectScript class MyPackage.MyClass.cls"
→ Returns compilation status and any errors

Compile multiple classes (all with .cls suffix)

"Compile classes MyPackage.Class1.cls, MyPackage.Class2.cls"
→ Returns status for each class

Custom compilation flags

"Compile MyPackage.MyClass.cls with flags 'bckry'"
→ b=rebuild, c=compile, k=keep source, r=recursive, y=display info

Note: If .cls suffix is omitted, it will be automatically added

"Compile MyPackage.MyClass" → Internally becomes "MyPackage.MyClass.cls"

compile_objectscript_package

Compile all classes in a package recursively:

# Compile entire package
"Compile ObjectScript package MyPackage"
→ Compiles all classes in package and sub-packages

With custom flags

"Compile package MyPackage with flags 'bc'"
→ Basic compile without recursion

Unit Testing Tools

queue_unit_tests

Queue unit test execution using WorkMgr async pattern for process isolation.

This tool uses %SYSTEM.WorkMgr to execute tests in an isolated worker process, avoiding %UnitTest.Manager singleton conflicts. Tests run with full assertion macro support and return immediately with a job ID for polling.

Auto-Prefix Feature: The leading colon for root test suite format is optional - it will be automatically added if missing.

# Queue a test suite (colon prefix is optional - auto-added if missing)
"Queue unit test ExecuteMCP.Test.SampleUnitTest"
→ Returns job ID instantly for polling

With explicit colon (backward compatible)

"Queue unit test :ExecuteMCP.Test.SampleUnitTest"
→ Returns job ID instantly for polling

Queue with specific test method (no leading colon for method-specific tests)

"Queue unit test ExecuteMCP.Test.SampleUnitTest:TestAddition"
→ Runs only the TestAddition method

Default qualifiers (optimized for VS Code workflow)

/noload - Don't load classes from filesystem (VS Code auto-syncs)

/nodelete - Don't delete test classes after run

/recursive - Run all test methods in the class/package

Custom qualifiers example

"Queue unit test :ExecuteMCP.Test with qualifiers '/debug/verbose'"
→ Runs tests with debug output

Prerequisites for Unit Testing:

  1. ^UnitTestRoot must be configured - Points to a valid, writable directory
  2. Test classes must be compiled - VS Code syncs but doesn’t compile
  3. Test spec format - Colon prefix optional (auto-added if missing for root test suites)

poll_unit_tests

Poll for unit test results from WorkMgr execution:

# Poll for results using job ID from queue_unit_tests
"Poll unit test job 12345"
→ Returns current status if running, or complete results if finished

Response includes:

- Test counts (pass/fail/error)

- Individual test method results

- Duration and timestamps

- Detailed error messages if any

Architecture

Technology Stack

  • Python MCP Server: FastMCP framework with STDIO transport
  • IRIS Backend: ExecuteMCP.Core.Command, ExecuteMCP.Core.Compile, and ExecuteMCP.Core.UnitTestQueue classes
  • Async Job Management: ExecuteMCP.Core.UnitTestQueue using %SYSTEM.WorkMgr for process isolation
  • I/O Capture: Global variable mechanism avoiding STDIO conflicts
  • Compilation Engine: $System.OBJ methods with comprehensive error handling

Key Innovations

  1. I/O Capture Breakthrough: Real output from WRITE commands via ^MCPCapture
  2. Dynamic Method Invocation: Call any ObjectScript class method by name
  3. WorkMgr Unit Testing: Process isolation eliminates %UnitTest.Manager singleton issues
  4. Zero Timeout Architecture: All operations complete in <100ms

Performance Metrics

  • Command Execution: 0ms with I/O capture
  • Method Invocation: <10ms for complex calls
  • Global Operations: Sub-millisecond response
  • Unit Test Queueing: Instant job ID return
  • System Info: <50ms full details

Troubleshooting

MCP Connection Issues

If you see “MCP error -32000: Connection closed”:

  1. Restart VS Code completely
  2. Or disable/enable Cline extension
  3. Check server is running: python iris_execute_mcp.py

Tool Not Working

  1. Verify IRIS classes are compiled:
    Do $System.OBJ.CompilePackage("ExecuteMCP")
    
  2. Check security privileges:
    Write $SYSTEM.Security.Check("%Development","USE")
    
  3. Test backend directly in IRIS terminal

Path Issues

  • Use absolute paths in configuration
  • Verify virtual environment activation
  • Check Python path points to venv Python

Unit Test Issues

Test Discovery Problems

  • Symptom: Tests run but report “0 tests found”
  • Cause: Test classes not compiled in IRIS
  • Solution:
    // Compile test classes (VS Code syncs but doesn't compile)
    Do $System.OBJ.CompilePackage("ExecuteMCP.Test")
    

Configuration Issues

  • Symptom: “^UnitTestRoot not configured” error
  • Solution:
    // Create test directory first
    // Windows: mkdir C:\temp
    // Then in IRIS:
    Set ^UnitTestRoot = "C:\temp"
    

Test Spec Format

  • Symptom: “Invalid test specification” error
  • Supported Formats (colon prefix is auto-added if missing):
    • ExecuteMCP.Test.SampleUnitTest - Auto-adds colon prefix
    • :ExecuteMCP.Test.SampleUnitTest - Explicit colon (backward compatible)
    • ExecuteMCP.Test.SampleUnitTest:TestMethod - Method-specific (no leading colon)

WorkMgr Issues

  • Symptom: Tests timeout or never complete
  • Check WorkMgr availability:
    Write ##class(%SYSTEM.WorkMgr).IsWorkerJobActive()
    

Advanced Usage

Combined Workflows

# Complete test workflow with compilation
1. "Compile ObjectScript package ExecuteMCP.Test"
2. "Queue unit test :ExecuteMCP.Test.SampleUnitTest"
3. "Poll unit test job "
4. "Get global ^UnitTest.Result to see raw results"

CI/CD Integration

The WorkMgr-based unit testing enables robust CI/CD pipelines:

# Queue tests without blocking
job_id = queue_unit_tests(":MyTestSuite")

Continue with other tasks

compile_classes()
deploy_changes()

Check results when ready

results = poll_unit_tests(job_id)
if results["failed"] > 0:
raise TestFailure(results)

Understanding Test Results

The unit test results are stored in globals with the following structure:

// Result global structure
^UnitTest.Result(ResultID, "ExecuteMCP\Test\SampleUnitTest", "SampleUnitTest", "TestAddition")
// Note: Suite names use backslashes, not dots

Contributing

Contributions welcome! Please ensure:

  • All tests pass
  • Code follows ObjectScript conventions
  • MCP tools have proper documentation
  • Changes are tested with Cline

License

MIT License - See LICENSE file for details

Version History

  • v2.3.1 (September 7, 2025): Added auto-prefix feature for unit test specifications
  • v2.3.0 (September 7, 2025): Fixed unit testing with WorkMgr pattern (9 tools total)
  • v2.2.0 (September 3, 2025): Added 2 compilation tools
  • v2.1.0 (August 30, 2025): Consolidated server with unit testing
  • v2.0.0: Added unit testing capabilities
  • v1.0.0: Initial 5 basic tools

Support


Status: ✅ Production Ready - All 9 tools operational
Last Updated: September 7, 2025

Made with
Version
2.3.108 Sep, 2025
Ideas portal
Category
Developer Environment
Works with
InterSystems IRISInterSystems IRIS for HealthHealthShare
First published
08 Sep, 2025
Last edited
08 Sep, 2025