Skip to content

Claude code integration issue - license server unable to connect #30

@jrich76

Description

@jrich76

I have been trying to get the mcp server to run via my Claude Code Agents. It is unable to connect to the MCP server when running anything from Claude Code because of an apparent licensing issue. However, I have the correct license working. I can confirm that in the MATLAB GUI or running MATLAB in batch mode from the command line. What is a little strange is that if I use the same batch mode command line from within Claude Code, it cannot connect to the license even though it will connect via the command line. I was able to run the MCP server via NPX.

Image
  • was able to run via 'npx @modelcontextprotocol/inspector /Users/[email protected]/.local/bin/matlab-mcp-core-server --matlab-root=/Applications/MATLAB_R2025b.app'.
  • running on a mac M4 Silicon computer in .zshrc

#Here is some more context

MATLAB Licensing Issue with Claude Code

Date: February 12, 2026
Author: (with Claude Code assistance)
Status: Resolved (workaround implemented)

Executive Summary

MATLAB fails to obtain a license when launched from within Claude Code (Anthropic's CLI tool), despite working correctly when launched from a standard terminal. The root cause appears to be something in the process inheritance from Claude Code's Node.js runtime that breaks FlexNet's license client protocol. A workaround using macOS launchd to spawn MATLAB outside the Claude Code process tree resolves the issue.


Problem Description

Symptoms

  • MATLAB batch mode commands fail with MathWorks Licensing Error 16 when executed from Claude Code
  • Error message: "Unable to communicate with your organization's license server"
  • FlexNet error code: -16,287 ("Cannot read data from license server system")
  • The same MATLAB commands work perfectly when run from a standard terminal (iTerm2)

Environment

  • Machine: MacBook Pro M4
  • OS: macOS Darwin 25.1.0
  • MATLAB: R2025b (also tested R2024b - same issue)
  • License Type: Network Named User (super user) + Concurrent pool
  • License Server:
  • VPN: GlobalProtect (Palo Alto Networks)
  • Claude Code: CLI version, launched from iTerm2 via claude command

Diagnostic Process

What We Ruled Out

1. Network Connectivity

Status: ✅ Working from Claude Code

# DNS resolution - WORKS
nslookup matlab-licensing.corp.company.com
# Result: 172.31.128.21

# TCP connectivity - WORKS
nc -zv matlab-licensing.corp.company.com 27000
# Result: Connection succeeded

# UDP connectivity - WORKS
nc -zuv matlab-licensing.corp.company.com 27000
# Result: Connection succeeded

# Raw socket data exchange - WORKS
(echo -e '\x00\x00\x00\x1e' | nc matlab-licensing.corp.company.com 27000 | xxd)
# Result: Received 147 bytes of response data

# Python socket test - WORKS
python3 -c "import socket; s=socket.socket(); s.connect(('matlab-licensing.corp.company.com',27000)); print('OK')"

Conclusion: Network layer is fully functional. The issue is specific to FlexNet's internal protocol.

2. Environment Variables

Status: ✅ Virtually identical between working and non-working environments

We compared env | sort output between:

  • Working: Direct terminal session
  • Non-working: Claude Code subprocess

Differences found:

  • TTY device numbers (expected - different sessions)
  • iTerm session IDs (expected)
  • Claude-specific variables (CLAUDECODE=1, CLAUDE_CODE_ENTRYPOINT=cli)
  • SSH agent PIDs (different agent instances)

Tests performed:

  • Ran MATLAB with working SSH agent credentials - FAILED
  • Ran MATLAB with env -i minimal environment - FAILED
  • Ran MATLAB with explicit USER=jrichards - FAILED

Conclusion: Environment variables are not the cause.

3. Sandbox/Container Restrictions

Status: ✅ No sandbox detected

sandbox-exec -p "(version 1)(allow default)" /bin/echo "test"
# Result: "not sandboxed"

4. Username/License Configuration

Status: ✅ Not the cause

Context: User is a "super user" with Network Named User license. There was a previous issue with username detection ([email protected] vs jrichards).

  • Verified username is correctly configured on license server
  • GUI MATLAB (running in same session) works with the license
  • Changing USER/LOGNAME environment variables has no effect

5. Process Detachment Methods

Status: ❌ All failed when spawned from Claude Code

Method Result
Direct bash call Failed
nohup background Failed
PTY via script command Failed
AppleScript do shell script Failed
Shell script with exec Failed
Different MATLAB version (R2024b) Failed
Explicit license server IP Failed
Clean environment (env -i) Failed

6. VPN (GlobalProtect) Configuration

Status: ✅ VPN routing works correctly

  • All network tests pass through VPN
  • License server is reachable
  • Data can be exchanged
  • No per-app routing restrictions detected

Root Cause Analysis

What We Know

  1. Network connectivity is fine - TCP, UDP, DNS all work from Claude Code subprocesses
  2. Raw socket communication works - Can send/receive data to license server port 27000
  3. FlexNet protocol specifically fails - The license client can connect but cannot complete its handshake
  4. GUI MATLAB works - Running MATLAB instance in the same user session has no license issues
  5. Direct terminal works - Same command, same user, same network - works fine
  6. All Claude Code subprocesses fail - Regardless of how the process is spawned

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingin progressWe are actively developing this feature or bug-fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions