Skip to content
tnsaiDocs
GitHub

Server

tnsai-server runs TnsAI agents behind a WebSocket API. A client opens a session, chats with that session's agents, and approves their risky tool calls. By default the server listens on 127.0.0.1:7777 and stops after 30 minutes with no connections.

Quick start

Build the executable JAR from the framework source tree. The docker profile is the only build that produces it:

mvn -B -pl tnsai-server -am -Pdocker package -DskipTests

Then run it:

java -jar tnsai-server/target/tnsai-server-*-shaded.jar --port 7777

tnsai-server/Dockerfile builds the same JAR into an image. Run docker build from the root of the source tree, because the build copies the other modules. The image binds to 0.0.0.0, so it refuses to start unless you set TNSAI_TOKEN.

To start the server from your own code, see Running the server.

Options

A flag wins over its environment variable.

FlagEnvironment variableDefault
--port <n>TNSAI_PORT7777
--idle-timeout <minutes>TNSAI_IDLE_TIMEOUT30
--host <address>TNSAI_HOST127.0.0.1
--allow-publicTNSAI_ALLOW_PUBLIC=trueoff
TNSAI_TOKENauth disabled
TNSAI_ALLOWED_ORIGINSloopback origins only
TNSAI_WORKSPACE_ROOT, TNSAI_WORKSPACE_MAX_FILESworking directory, 50,000 files

A host other than loopback needs both --allow-public and TNSAI_TOKEN; otherwise the server refuses to start. Server hardening covers each setting.

Choosing the model

The server picks one LLMClient at startup, in this order:

  1. The first LLMClient registered through ServiceLoader on the classpath.
  2. When TNSAI_PROVIDER and TNSAI_API_KEY are both set: ollama is the only accepted provider, with TNSAI_MODEL or qwen3:8b as the model, and the key is not used. Any other provider stops startup with IllegalStateException.
  3. Otherwise, an OllamaClient for TNSAI_MODEL, or glm-5:cloud when it is unset.

To use another provider, start the server from code and pass your own llmClientSupplier.

Endpoints

PathPurpose
/chatWebSocket protocol for sessions, chat and approvals
/health, /health/live, /healthzHealth summary and liveness
/health/ready, /readyzReadiness
/api/infoServer information
/api/index, /api/index/statusIndex a directory into a session, check progress, clear the index
/api/searchSearch a session's index
/api/auditRead a session's audit trail
ToRead
Start the server from code, and see the tools each agent getsRunning the server
Write a clientWebSocket protocol
Decide which tool calls need approvalTool approval
Log or run commands around tool callsTool call hooks
Expose the server beyond localhostServer hardening