Skip to main content
Glama

driver_session

Idempotent

Start, stop, or check status of WebSocket sessions to control Tauri app automation. Required before using webview and IPC tools.

Instructions

[Tauri Apps Only] Start/stop automation session to connect to a RUNNING Tauri app. Supports multiple concurrent app connections - each app runs on a unique port. The most recently connected app becomes the "default" app used when no appIdentifier is specified. Use action "status" to check connection state: returns single app format when 1 app connected, or array format with "isDefault" indicator when multiple apps connected. Action "stop" without appIdentifier stops ALL sessions; with appIdentifier stops only that app. The identifier field (e.g., "com.example.myapp") uniquely identifies each app. REQUIRED before using other webview_* or ipc_* tools. Connects via WebSocket to the MCP Bridge plugin in the Tauri app. For browser automation, use Chrome DevTools MCP instead. For Electron apps, this tool will NOT work.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesAction to perform: start or stop the session, or check status
hostNoHost address to connect to (e.g., 192.168.1.100). Falls back to MCP_BRIDGE_HOST or TAURI_DEV_HOST env vars
portNoPort to connect to (default: 9223)
appIdentifierNoApp identifier (port number or bundle ID) to stop. Only used with action "stop". If omitted, stops all sessions.

Implementation Reference

  • Registration of the 'driver_session' tool in the TOOLS registry. Defines name, description, category, schema reference, and handler. The handler parses args via ManageDriverSessionSchema then delegates to manageDriverSession().
    {
       name: 'driver_session',
       description:
          '[Tauri Apps Only] Start/stop automation session to connect to a RUNNING Tauri app. ' +
          'Supports multiple concurrent app connections - each app runs on a unique port. ' +
          'The most recently connected app becomes the "default" app used when no appIdentifier is specified. ' +
          'Use action "status" to check connection state: returns single app format when 1 app connected, ' +
          'or array format with "isDefault" indicator when multiple apps connected. ' +
          'Action "stop" without appIdentifier stops ALL sessions; with appIdentifier stops only that app. ' +
          'The identifier field (e.g., "com.example.myapp") uniquely identifies each app. ' +
          'REQUIRED before using other webview_* or ipc_* tools. ' +
          'Connects via WebSocket to the MCP Bridge plugin in the Tauri app. ' +
          'For browser automation, use Chrome DevTools MCP instead. ' +
          'For Electron apps, this tool will NOT work.',
       category: TOOL_CATEGORIES.UI_AUTOMATION,
       schema: ManageDriverSessionSchema,
       annotations: {
          title: 'Manage Tauri Session',
          readOnlyHint: false,
          destructiveHint: false,
          idempotentHint: true,
          openWorldHint: false,
       },
       handler: async (args) => {
          const parsed = ManageDriverSessionSchema.parse(args);
    
          return await manageDriverSession(parsed.action, parsed.host, parsed.port, parsed.appIdentifier);
       },
    },
  • The manageDriverSession function - the core handler implementation that dispatches to handleStartAction, handleStopAction, or handleStatusAction based on the 'action' parameter.
    export async function manageDriverSession(
       action: 'start' | 'stop' | 'status',
       host?: string,
       port?: number,
       appIdentifier?: string | number
    ): Promise<string> {
       switch (action) {
          case 'status': {
             return handleStatusAction();
          }
    
          case 'start': {
             return handleStartAction(host, port);
          }
    
          case 'stop': {
             return handleStopAction(appIdentifier);
          }
    
          default: {
             return handleStopAction(appIdentifier);
          }
       }
    }
  • ManageDriverSessionSchema - Zod schema defining the input for driver_session: action (enum start/stop/status), optional host, optional port, and optional appIdentifier for targeted stop.
    export const ManageDriverSessionSchema = z.object({
       action: z.enum([ 'start', 'stop', 'status' ]).describe('Action to perform: start or stop the session, or check status'),
       host: z.string().optional().describe(
          'Host address to connect to (e.g., 192.168.1.100). Falls back to MCP_BRIDGE_HOST or TAURI_DEV_HOST env vars'
       ),
       port: z.number().optional().describe('Port to connect to (default: 9223)'),
       appIdentifier: z.union([ z.string(), z.number() ]).optional().describe(
          'App identifier (port number or bundle ID) to stop. Only used with action "stop". If omitted, stops all sessions.'
       ),
    });
  • handleStatusAction helper - returns JSON with connection state, session info, and multi-app support.
    async function handleStatusAction(): Promise<string> {
       if (activeSessions.size === 0) {
          return JSON.stringify({
             connected: false,
             app: null,
             identifier: null,
             host: null,
             port: null,
          });
       }
    
       if (activeSessions.size === 1) {
          const session = activeSessions.values().next().value;
    
          if (!session) {
             return JSON.stringify({
                connected: false,
                app: null,
                identifier: null,
                host: null,
                port: null,
             });
          }
    
          return JSON.stringify({
             connected: true,
             app: session.name,
             identifier: session.identifier,
             host: session.host,
             port: session.port,
          });
       }
    
       const apps = Array.from(activeSessions.values()).map((session) => {
          return {
             name: session.name,
             identifier: session.identifier,
             host: session.host,
             port: session.port,
             isDefault: session.port === defaultPort,
          };
       });
    
       return JSON.stringify({
          connected: true,
          apps,
          totalCount: apps.length,
          defaultPort,
       });
    }
  • handleStartAction helper - attempts to connect to Tauri app via localhost or configured host, auto-discovers ports, creates PluginClient, and stores session info.
    async function handleStartAction(host?: string, port?: number): Promise<string> {
       const configuredHost = host ?? getDefaultHost();
    
       const configuredPort = port ?? getDefaultPort();
    
       if (activeSessions.has(configuredPort)) {
          return `Already connected to app on port ${configuredPort}`;
       }
    
       let connectedSession: { name: string; host: string; port: number } | null = null;
    
       if (configuredHost !== 'localhost' && configuredHost !== '127.0.0.1') {
          try {
             connectedSession = await tryConnect('localhost', configuredPort);
          } catch{
             // ignore
          }
       }
    
       if (!connectedSession) {
          try {
             connectedSession = await tryConnect(configuredHost, configuredPort);
          } catch{
             // ignore
          }
       }
    
       if (!connectedSession) {
          const localhostDiscovery = getAppDiscovery('localhost');
    
          const firstApp = await localhostDiscovery.getFirstAvailableApp();
    
          if (firstApp) {
             try {
                connectedSession = await tryConnect('localhost', firstApp.port);
             } catch{
                // ignore
             }
          }
       }
    
       if (!connectedSession) {
          return `Session start failed - no Tauri app found at localhost or ${configuredHost}:${configuredPort}`;
       }
    
       const client = new PluginClient(connectedSession.host, connectedSession.port);
    
       await client.connect();
    
       const identifier = await fetchAppIdentifier(client);
    
       const sessionInfo: SessionInfo = {
          name: connectedSession.name,
          identifier,
          host: connectedSession.host,
          port: connectedSession.port,
          client,
          connected: true,
       };
    
       activeSessions.set(connectedSession.port, sessionInfo);
       defaultPort = connectedSession.port;
    
       sessionLogger.info(
          `Session started: ${sessionInfo.name} (${sessionInfo.host}:${sessionInfo.port}) [DEFAULT]`
       );
    
       return `Session started with app: ${sessionInfo.name} (${sessionInfo.host}:${sessionInfo.port}) [DEFAULT]`;
    }
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Beyond annotations (readOnlyHint=false, destructiveHint=false, idempotentHint=true), the description adds significant behavioral context: it connects via WebSocket to the MCP Bridge plugin, supports multiple concurrent app connections, explains the default app logic, and details action-specific behaviors (status returns single vs array format, stop without appIdentifier stops all). No contradictions with annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured: front-loaded with the primary constraint ('Tauri Apps Only'), followed by key details. It uses clear, concise sentences and logical flow. Though slightly long, every sentence adds value. Could be slightly tighter but overall effective.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (4 parameters, multiple actions, no output schema), the description is remarkably complete. It covers all actions and their effects, prerequisites, limitations, and references sibling tools. It even explains the return format for status action (single vs array) despite no output schema. No gaps remain.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so baseline is 3. The description adds extra meaning beyond schema by explaining the action enum values (status behavior, stop without appIdentifier), the purpose of appIdentifier (unique ID, only used with stop, omitted stops all), host fallback to env vars, and port default. This enriches understanding beyond the raw schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Start/stop automation session to connect to a RUNNING Tauri app.' It specifies it is for Tauri apps only and distinguishes from browser automation (Chrome DevTools MCP) and Electron apps. It also notes it is required before using webview_* or ipc_* tools, effectively differentiating from siblings.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit usage guidelines: when to use (before other Tauri tools), when not to use (for browser automation or Electron apps). It explains behavior for each action (start, stop, status), including details about default app handling, stop without appIdentifier stops all sessions, and multiple concurrent connections. This gives clear guidance on how and when to invoke the tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/hypothesi/mcp-server-tauri'

If you have feedback or need assistance with the MCP directory API, please join our Discord server