Skip to main content
Glama

get_compiled_code

Retrieve compiled JavaScript and CSS output for Svelte components to debug compilation issues and analyze generated code.

Instructions

Get the compiled JavaScript and CSS output for a Svelte component. Useful for debugging compilation issues.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesAbsolute path to the .svelte file

Implementation Reference

  • Registration of the "get_compiled_code" tool in Svelte tools module.
    server.registerTool(
      "get_compiled_code",
      {
        title: "Get Compiled Code",
        description:
          "Get the compiled JavaScript and CSS output for a Svelte component. Useful for debugging compilation issues.",
        inputSchema: z.object({
          filePath: z
            .string()
            .describe("Absolute path to the .svelte file"),
        }),
      },
  • Handler implementation for "get_compiled_code", which makes an LSP request to '$/getCompiledCode'.
    async ({ filePath }): Promise<ToolResult> => {
      try {
        const prep = await prepareDocumentRequest(lsp, filePath);
        if ("error" in prep) return textResult(prep.error);
    
        const result = await lsp.request("$/getCompiledCode", prep.uri);
    
        if (!result) {
          return textResult(
            `No compiled code available for ${basename(filePath)}.`
          );
        }
    
        const parts: string[] = [];
    
        if (result.js) {
          parts.push("=== Compiled JavaScript ===");
          parts.push(result.js);
        }
    
        if (result.css) {
          parts.push("");
          parts.push("=== Compiled CSS ===");
          parts.push(result.css);
        }
    
        if (parts.length === 0) {
          return textResult(
            `Compiled code for ${basename(filePath)} is empty.`
          );
        }
    
        return textResult(parts.join("\n"));
      } catch (ex) {
        return textResult(formatError(ex));
      }
    }
  • Input schema definition for the "get_compiled_code" tool using Zod.
    inputSchema: z.object({
      filePath: z
        .string()
        .describe("Absolute path to the .svelte file"),
    }),

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/adainrivers/SvelteLS.MCP'

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