Skip to main content
Glama

js.beautify

Format JavaScript code for readability and analysis during security testing, helping identify vulnerabilities by standardizing code structure.

Instructions

Beautify and format JavaScript source code

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceYesJavaScript source code
indentSizeNoIndentation size

Implementation Reference

  • The asynchronous handler function for the 'js.beautify' tool. It takes JavaScript source code and optional indent size, uses the 'js-beautify' library to format it, and returns the beautified code along with length information or an error.
    async ({ source, indentSize = 2 }: any): Promise<ToolResult> => { try { const beautified = beautify.js(source, { indent_size: indentSize, space_in_empty_paren: true, preserve_newlines: true, }); return formatToolResult(true, { beautified, originalLength: source.length, beautifiedLength: beautified.length, }); } catch (error: any) { return formatToolResult(false, null, error.message); } }
  • Input schema definition for the 'js.beautify' tool, specifying required 'source' parameter and optional 'indentSize'.
    description: 'Beautify and format JavaScript source code', inputSchema: { type: 'object', properties: { source: { type: 'string', description: 'JavaScript source code' }, indentSize: { type: 'number', description: 'Indentation size', default: 2 }, }, required: ['source'], },
  • src/tools/js.ts:47-76 (registration)
    Registration of the 'js.beautify' tool using server.tool(), including schema and handler function.
    'js.beautify', { description: 'Beautify and format JavaScript source code', inputSchema: { type: 'object', properties: { source: { type: 'string', description: 'JavaScript source code' }, indentSize: { type: 'number', description: 'Indentation size', default: 2 }, }, required: ['source'], }, }, async ({ source, indentSize = 2 }: any): Promise<ToolResult> => { try { const beautified = beautify.js(source, { indent_size: indentSize, space_in_empty_paren: true, preserve_newlines: true, }); return formatToolResult(true, { beautified, originalLength: source.length, beautifiedLength: beautified.length, }); } catch (error: any) { return formatToolResult(false, null, error.message); } } );
  • Import of the 'js-beautify' library, which is used as the core formatting utility in the tool handler.
    import beautify from 'js-beautify';

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/telmon95/VulneraMCP'

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