MCP Server (AI Assistant Control)

On this page:

TerraStereo has a built-in MCP (Model Context Protocol) server. With it an AI assistant such as Claude Code can load sessions, convert projects, move the camera, take screenshots and digitize and edit shapes, for example to test the digitizing tools. The server is off by default.

The server only accepts requests from the same computer (localhost) that carry the access token. It needs no administrator rights, firewall rules or extra files.

Installing Claude Code

Install Claude Code once per user, in a normal (not administrator) PowerShell:

irm https://claude.ai/install.ps1 | iex

Then run claude once and log in. Git for Windows is recommended. See the Claude Code setup guide for other options.

Starting TerraStereo with the MCP Server

Start TerraStereo with the --mcp switch, for example from a shortcut or a command prompt in the installation folder:

TerraStereo.exe 1 --mcp

On the first start TerraStereo creates the access token in %LOCALAPPDATA%\TerraStereo\mcp_token.txt. Treat it like a password. To create a new token, delete the file and restart TerraStereo. Server errors are logged to %LOCALAPPDATA%\TerraStereo\mcp.log.

Connecting Claude Code

Register the server once, in a normal PowerShell, after TerraStereo has created the token:

$t = Get-Content "$env:LOCALAPPDATA\TerraStereo\mcp_token.txt"
claude mcp add --transport http terrastereo http://localhost:8765/mcp --header "Authorization: Bearer $t" -s user

-s user makes the server available in every folder; leave it out to limit it to the current folder. In Claude Code the /mcp command should then show terrastereo as connected. After TerraStereo has been restarted (or updated with new tools), reconnect it in /mcp. If the token is renewed, remove the server (claude mcp remove terrastereo -s user) and register it again.

Using the Server

Ask the assistant in plain language, for example "load the latest session and take a screenshot" or "digitize a line along the curb and test undo". The main tools are:

Message boxes of MCP-started operations are returned to the assistant instead of being shown. Saving a shape through the server also writes it to the TerraSurvey export file of the settings, as it does interactively.

Remote Use

TerraStereo needs the desktop session of the logged-on user (OpenGL, CUDA, stereo display). Keep the user logged on at the workstation; locking it is fine, signing out is not. Use SSH for the remote console, not Remote Desktop into the same session. The script TerraStereoRemote.ps1 in the installation folder starts TerraStereo with the MCP server in the console session through a scheduled task:

$r = 'C:\terra64\tstereo\TerraStereoRemote.ps1'
powershell -ExecutionPolicy Bypass -File $r install   # once: registers the task "TerraStereo MCP" (uninstall removes it)
powershell -ExecutionPolicy Bypass -File $r start     # starts TerraStereo and waits for the MCP server
powershell -ExecutionPolicy Bypass -File $r status
powershell -ExecutionPolicy Bypass -File $r stop      # graceful exit through MCP (-Force kills it)
powershell -ExecutionPolicy Bypass -File $r restart

Run Claude Code in the SSH session on the workstation, or forward the port to your own machine with ssh -L 8765:localhost:8765 user@workstation and register the server there with the workstation's token.