Skip to main content
Glama

get_command_history

Retrieves a specified number of recently executed command entries from the Windows CLI MCP Server, including command details, outputs, timestamps, and exit codes for auditing or troubleshooting.

Instructions

Get the history of executed commands

Example usage:

{ "limit": 5 }

Example response:

[ { "command": "Get-Process", "output": "...", "timestamp": "2024-03-20T10:30:00Z", "exitCode": 0 } ]

Input Schema

NameRequiredDescriptionDefault
limitNoMaximum number of history entries to return (default: 10, max: 1000)

Input Schema (JSON Schema)

{ "properties": { "limit": { "description": "Maximum number of history entries to return (default: 10, max: 1000)", "type": "number" } }, "type": "object" }

Implementation Reference

  • Handler for the get_command_history tool: checks if logging is enabled, parses optional limit parameter, retrieves and truncates recent command history entries from the class's commandHistory array, and returns them as JSON.
    case "get_command_history": { if (!this.config.security.logCommands) { return { content: [{ type: "text", text: "Command history is disabled in configuration. Consult the server admin for configuration changes (config.json - logCommands)." }] }; } const args = z.object({ limit: z.number() .min(1) .max(this.config.security.maxHistorySize) .optional() .default(10) }).parse(request.params.arguments); const history = this.commandHistory .slice(-args.limit) .map(entry => ({ ...entry, output: entry.output.slice(0, 1000) // Limit output size })); return { content: [{ type: "text", text: JSON.stringify(history, null, 2) }] }; }
  • src/index.ts:324-355 (registration)
    Registration of the get_command_history tool in the ListTools response, including name, description, and input schema.
    { name: "get_command_history", description: `Get the history of executed commands Example usage: \`\`\`json { "limit": 5 } \`\`\` Example response: \`\`\`json [ { "command": "Get-Process", "output": "...", "timestamp": "2024-03-20T10:30:00Z", "exitCode": 0 } ] \`\`\``, inputSchema: { type: "object", properties: { limit: { type: "number", description: `Maximum number of history entries to return (default: 10, max: ${this.config.security.maxHistorySize})` } } } },
  • Type definition for CommandHistoryEntry, which structures the data returned by the get_command_history tool.
    export interface CommandHistoryEntry { command: string; output: string; timestamp: string; exitCode: number; connectionId?: string; }

Other Tools

Related 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/simon-ami/win-cli-mcp-server'

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