Skip to content

Agent Integration

String provides four ways for AI agents to interact with documents and skills. Pick the one that matches how your agent runs.

Best for: shell scripts, simple automation, AI agents with command execution.

Terminal window
# Topic mode: string <topic> '<command>'
string file:main '/open ./index.md'
string file:main '/act.search --query "hello"'
string app:weather '/act.forecast --city "Seoul"'

The CLI auto-starts a daemon process. Multiple commands share the same session state.

TopicUse Case
file:nameLocal file browsing and editing
app:nameInstalled SFMD apps
web:nameWeb browsing (HTML → Markdown)
bash:nameInteractive shell sessions
Terminal window
export STRINGD_PORT=3100 # Daemon port (default: 3100)
export STRINGD_USER=default # User ID
export STRINGD_HOME=~ # Home directory

Best for: Claude Desktop, Cursor, and other MCP-compatible AI clients.

{
"mcpServers": {
"string": {
"command": "npx",
"args": ["@string-os/string-mcp"]
}
}
}
ToolMaps toDescription
string_open/openOpen a document, URL, or directory
string_act/actExecute an action
string_exec/execRun a shell command
string_ls/lsList files and directories
string_nav/navNavigate shortcuts and menus
string_info/infoGet session state
string_write/writeWrite content to a file

Each tool wraps the corresponding String command. The MCP server creates a single Browser instance and routes tool calls through it.

Best for: custom agents, embedded use, programmatic control.

import { Browser } from '@string-os/string';
// Create a browser with a home directory
const browser = new Browser({
home: '/path/to/workspace',
allowHttp: true,
});
// Execute commands
const result = await browser.exec('/open ./index.md');
console.log(result.ok); // true
console.log(result.content); // Rendered document
// Work with multiple sessions
await browser.exec('/open ./app.md', 'app:myapp');
await browser.exec('/act.fetch --query "test"', 'app:myapp');
// Session management
browser.listSessions(); // ['main', 'app:myapp']
browser.switchSession('main');
browser.closeSession('app:myapp');
ClassPurpose
BrowserTop-level entry point. Manages sessions and loader.
SessionSingle browsing session with history, variables, and state.
LoaderLoads documents from file:// and http:// URIs.
const browser = new Browser({
home: '/workspace',
allowHttp: true, // Enable web fetching (default: true)
accessMode: 'workspace', // Restrict file access to home directory
htmlToMarkdown: customFn, // Custom HTML→Markdown converter
});

Best for: custom Node.js programs that want to talk to a running stringd without pulling in the full runtime, and as a reference for implementing the protocol in other languages.

import { ping, ensureUser, exec } from '@string-os/client';
const port = 3100;
const userId = 'default';
const home = process.env.HOME + '/.string/users/default';
if (!(await ping(port))) {
throw new Error('stringd is not running on port ' + port);
}
await ensureUser(port, { id: userId, home });
const result = await exec(port, userId, 'file:main', '/open ./index.md');
console.log(result.ok); // true on success
console.log(result.code); // null on success, string error code on failure
console.log(result.content); // the command output
console.log(result.meta); // current document metadata or null

No runtime dependencies — the client uses only Node’s built-in http module.

The CLI itself is built on @string-os/client. If you wrote cli.ts from scratch using this package, the result would be nearly identical.

@string-os/client speaks the stringd protocol v0.1. That document is normative and is the source of truth for any other-language client. Planned clients include:

  • Python (string-os on PyPI, in progress) — for Python-based agents and shell tools
  • Other languages welcome — open an issue if you implement one

You can also talk to stringd with any HTTP client and no SDK:

Terminal window
# Health check
curl http://localhost:3100/health
# Execute a command (SSE response)
curl -N -X POST http://localhost:3100/exec \
-H "X-User-Id: default" \
-H "Content-Type: application/json" \
-d '{"cmd": "/open index.md", "topic": "file:main"}'

The SSE response contains head, content, and done events. See the protocol spec for the full schema.