Skip to main content
Glama

watch_process

Spawn and monitor local processes to capture stdout, stderr, and exit codes for real-time feedback in development workflows.

Instructions

Spawn and monitor a local process, capturing stdout/stderr and exit code

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYesCommand to run
argsNoCommand arguments
cwdNoWorking directory (optional)
action_idNoLink events to an agent action

Implementation Reference

  • The handler function 'handleWatchProcess' that executes the tool logic for 'watch_process'.
    private async handleWatchProcess(args: Record<string, unknown>) {
      const schema = z.object({
        command: z.string(),
        args: z.array(z.string()).default([]),
        cwd: z.string().optional(),
        action_id: z.string().optional(),
      });
      const parsed = schema.parse(args);
      const id = uuidv4();
      const now = new Date().toISOString();
    
      const config: ProcessConfig = {
        kind: 'process',
        command: parsed.command,
        args: parsed.args,
        cwd: parsed.cwd,
      };
      const watch: WatchRecord = {
        id,
        kind: 'process',
        config,
        action_id: parsed.action_id ?? null,
        created_at: now,
        active: true,
        last_poll_at: null,
      };
    
      insertWatch(watch);
      const watcher = new ProcessWatcher(id, parsed.action_id ?? null, this.registry.getNotifyFn(), config);
      this.registry.register(watcher);
    
      return {
        content: [{
          type: 'text' as const,
          text: JSON.stringify({ watch_id: id, status: 'running', command: parsed.command }),
        }],
      };
    }
  • src/server.ts:71-84 (registration)
    The definition and registration of the 'watch_process' tool in the MCP server tool list.
    {
      name: 'watch_process',
      description: 'Spawn and monitor a local process, capturing stdout/stderr and exit code',
      inputSchema: {
        type: 'object',
        properties: {
          command: { type: 'string', description: 'Command to run' },
          args: { type: 'array', items: { type: 'string' }, description: 'Command arguments' },
          cwd: { type: 'string', description: 'Working directory (optional)' },
          action_id: { type: 'string', description: 'Link events to an agent action' },
        },
        required: ['command'],
      },
    },

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/jarvisassistantux/loopsense'

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