Skip to main content
Glama
simon-ami

Windows CLI MCP Server

get_command_history

Retrieve recent command execution records from Windows CLI sessions to review past actions, outputs, and timestamps for troubleshooting or auditing purposes.

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

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

Implementation Reference

  • Handler function for the 'get_command_history' tool. Checks if command logging is enabled, parses optional limit parameter, retrieves recent history entries from this.commandHistory, truncates output, and returns JSON-formatted history.
    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 list of tools returned by ListToolsRequestSchema, including description and input schema definition.
            {
              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 used in command history storage and output of get_command_history tool.
    export interface CommandHistoryEntry {
      command: string;
      output: string;
      timestamp: string;
      exitCode: number;
      connectionId?: string;
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves history but doesn't cover critical aspects: what 'executed commands' refers to (e.g., commands from 'execute_command' tool only, all server commands, system-wide), whether it requires specific permissions, how it handles pagination beyond the limit parameter, or if there are rate limits. The example response hints at output format but lacks explicit behavioral details.

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

Conciseness3/5

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

The description is front-loaded with a clear purpose statement, but the example usage and response occupy most of the text without adding significant explanatory value beyond the schema. While not verbose, the examples could be more concise or integrated with additional guidance. The structure is adequate but could be improved by trimming redundant examples.

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

Completeness2/5

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

Given the tool's complexity (retrieving command history) and lack of annotations and output schema, the description is incomplete. It doesn't explain the scope of 'executed commands' (e.g., tied to specific tools or sessions), behavioral constraints, or error handling. The example response provides some output format insight, but without an output schema, more detail on return values and structure is needed for adequate completeness.

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

Parameters3/5

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

Schema description coverage is 100%, with the 'limit' parameter fully documented in the schema (type, description with default and max). The description adds no additional parameter semantics beyond what's in the schema—it only shows an example usage with 'limit': 5, which aligns with but doesn't expand on the schema. This meets the baseline of 3 for high schema coverage.

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

Purpose4/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 as 'Get the history of executed commands' with a specific verb ('Get') and resource ('history of executed commands'). It distinguishes from siblings like 'execute_command' or 'ssh_execute' by focusing on historical retrieval rather than execution. However, it doesn't explicitly differentiate from other potential history-related tools that might exist in the future.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., whether commands must have been executed via this server), exclusions, or relationships with sibling tools like 'execute_command' (which might populate this history). The example usage shows a parameter but doesn't explain context for its application.

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

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