Skip to main content
Glama

write_to_terminal

Send text or commands to the Windows terminal through the WinTerm MCP server, enabling AI models to interact with the command line interface.

Instructions

Write text or commands to the terminal

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYesThe text or command to write to the terminal

Implementation Reference

  • Handler for 'write_to_terminal' tool: spawns a shell process with the given command, captures stdout/stderr output, stores in outputBuffer, and resolves with the output and exit code.
    case 'write_to_terminal': { const { command } = request.params.arguments as { command: string }; return new Promise((resolve, reject) => { const shell = os.platform() === 'win32' ? 'cmd.exe' : 'bash'; const shellArgs = os.platform() === 'win32' ? ['/c', command] : ['-c', command]; const proc = spawn(shell, shellArgs); let output = ''; proc.stdout.on('data', (data) => { output += data.toString(); this.outputBuffer.push(...data.toString().split('\n')); }); proc.stderr.on('data', (data) => { output += data.toString(); this.outputBuffer.push(...data.toString().split('\n')); }); proc.on('close', (code) => { resolve({ content: [ { type: 'text', text: `Command executed with exit code ${code}. Output:\n${output}`, }, ], }); }); proc.on('error', (err) => { reject(new McpError(ErrorCode.InternalError, err.message)); }); }); }
  • src/index.ts:42-55 (registration)
    Registration of the 'write_to_terminal' tool in ListToolsRequestHandler, including name, description, and input schema for the command parameter.
    { name: 'write_to_terminal', description: 'Write text or commands to the terminal', inputSchema: { type: 'object', properties: { command: { type: 'string', description: 'The text or command to write to the terminal', }, }, required: ['command'], }, },
  • Input schema definition for the 'write_to_terminal' tool, specifying a required 'command' string.
    inputSchema: { type: 'object', properties: { command: { type: 'string', description: 'The text or command to write to the terminal', }, }, 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/capecoma/winterm-mcp'

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