Skip to content

Fix excessive whitespace in tool descriptions due to template literal indentation #200

@daxian-dbw

Description

@daxian-dbw

Problem

All tool descriptions in src/server.ts contain excessive leading whitespace due to the way template literals are indented in the code. This results in poor formatting when the descriptions are displayed to users through the MCP client.

Current Behavior

Tool descriptions appear with significant left padding. Below is an example of using desktop-commander in AIShell:

Image Image

Expected Behavior

Tool descriptions should appear clean without excessive indentation.

Root Cause

The template literals in the description fields are using the same indentation as the surrounding code, which includes the whitespace in the final string output.

Solution Options

  1. Manual formatting - Start template literals at column 0:

       description: `Get the complete server configuration as JSON. Config includes fields for:
    - blockedCommands (array of blocked shell commands)
    - defaultShell (shell to use for commands)
    ${CMD_PREFIX_DESCRIPTION}`,
  2. Use a dedent function - Create or import a utility to strip common leading

    import dedent from 'dedent';
    
    description: dedent`
        Get the complete server configuration as JSON. Config includes fields for:
        - blockedCommands (array of blocked shell commands)
        - defaultShell (shell to use for commands)
        ${CMD_PREFIX_DESCRIPTION}
    `

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions