Skip to main content
Glama

pursIdeRebuild

Recompile a single PureScript module to check for errors, providing immediate feedback during code editing. Requires IDE server and loaded modules, faster than full project rebuild.

Instructions

Quickly recompile a single PureScript module and check for errors. PREREQUISITES: IDE server running and modules loaded. Much faster than full project rebuild. Use when editing code to get immediate feedback.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actualFileNoOptional: Real path if 'file' is 'data:' or a temp file.
codegenNoOptional: Codegen targets (e.g., 'js', 'corefn'). Defaults to ['js'].
fileYesPath to the module to rebuild, or 'data:' prefixed source code.

Implementation Reference

  • Handler function that executes the pursIdeRebuild tool. It validates the input arguments, constructs the parameters for the 'rebuild' command, sends it to the purs ide server using sendCommandToPursIde, and returns the MCP-formatted response with the result.
    "pursIdeRebuild": async (args) => { if (!args || typeof args.file !== 'string') { throw new Error("Invalid input: 'file' (string) is required for pursIdeRebuild."); } const params = { file: args.file, actualFile: args.actualFile, codegen: args.codegen // purs ide server defaults to js if undefined }; const result = await sendCommandToPursIde({ command: "rebuild", params }); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; },
  • Input schema defining the parameters for the pursIdeRebuild tool: requires 'file' (string), optional 'actualFile' and 'codegen' (array of strings).
    inputSchema: { type: "object", properties: { file: { type: "string", description: "Path to the module to rebuild, or 'data:' prefixed source code." }, actualFile: { type: "string", description: "Optional: Real path if 'file' is 'data:' or a temp file." }, codegen: { type: "array", items: { type: "string" }, description: "Optional: Codegen targets (e.g., 'js', 'corefn'). Defaults to ['js']." } }, required: ["file"], additionalProperties: false }
  • index.js:744-757 (registration)
    Registration of the pursIdeRebuild tool in the TOOL_DEFINITIONS array, which is returned by the tools/list MCP method. Includes name, description, and input schema.
    { name: "pursIdeRebuild", description: "Quickly recompile a single PureScript module and check for errors. PREREQUISITES: IDE server running and modules loaded. Much faster than full project rebuild. Use when editing code to get immediate feedback.", inputSchema: { type: "object", properties: { file: { type: "string", description: "Path to the module to rebuild, or 'data:' prefixed source code." }, actualFile: { type: "string", description: "Optional: Real path if 'file' is 'data:' or a temp file." }, codegen: { type: "array", items: { type: "string" }, description: "Optional: Codegen targets (e.g., 'js', 'corefn'). Defaults to ['js']." } }, required: ["file"], additionalProperties: false } },
  • Helper function sendCommandToPursIde used by the handler to communicate the 'rebuild' command over TCP to the running purs ide server and retrieve the response.
    function sendCommandToPursIde(commandPayload) { return new Promise((resolve, reject) => { if (!pursIdeProcess || !pursIdeIsReady || !pursIdeServerPort) { return reject(new Error("purs ide server is not running or not ready.")); } const client = new net.Socket(); let responseData = ''; client.connect(pursIdeServerPort, '127.0.0.1', () => { logToStderr(`[MCP Client->purs ide]: Sending command: ${JSON.stringify(commandPayload).substring(0,100)}...`, 'debug'); client.write(JSON.stringify(commandPayload) + '\n'); }); client.on('data', (data) => { responseData += data.toString(); if (responseData.includes('\n')) { const completeResponses = responseData.split('\n').filter(Boolean); responseData = ''; if (completeResponses.length > 0) { try { resolve(JSON.parse(completeResponses[0].trim())); } catch (e) { reject(new Error(`Failed to parse JSON response from purs ide: ${e.message}. Raw: ${completeResponses[0]}`)); } } client.end(); } }); client.on('end', () => { if (responseData.trim()) { try { resolve(JSON.parse(responseData.trim())); } catch (e) { reject(new Error(`Failed to parse JSON response from purs ide on end: ${e.message}. Raw: ${responseData}`));} } }); client.on('close', () => { logToStderr(`[MCP Client->purs ide]: Connection closed.`, 'debug'); }); client.on('error', (err) => reject(new Error(`TCP connection error with purs ide server: ${err.message}`))); }); }

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/avi892nash/purescript-mcp-tools'

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