Skip to main content
Glama

js.beautify

Format and beautify JavaScript code for improved readability during security analysis and vulnerability testing.

Instructions

Beautify and format JavaScript source code

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceYesJavaScript source code
indentSizeNoIndentation size

Implementation Reference

  • The handler function for the 'js.beautify' tool. It takes JS source code, optionally an indent size, beautifies it using the 'js-beautify' library, and returns the formatted code along with length metrics.
    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 for the 'js.beautify' tool, defining required 'source' string and optional 'indentSize' number.
    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)
    Registers the 'js.beautify' tool on the MCP server within the registerJsTools function, including schema and handler.
    '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); } } );
  • Imports the 'js-beautify' library used by the js.beautify tool handler.
    import beautify from 'js-beautify';
  • src/index.ts:36-36 (registration)
    Top-level call to registerJsTools, which includes registration of the 'js.beautify' tool.
    registerJsTools(server);

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