pursIdeList
Retrieve available modules or import lists in a PureScript project to analyze structure and dependencies. Requires IDE server running with modules loaded.
Instructions
List available modules in the project or imports in a specific file. PREREQUISITES: IDE server running and modules loaded. Helps understand project structure and dependencies.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | No | Path to the .purs file (required for 'import' listType). | |
| listType | Yes | Type of list to retrieve. |
Implementation Reference
- index.js:1113-1126 (handler)The handler function that implements the core logic for the 'pursIdeList' MCP tool. Validates input (listType required, file for 'import'), forwards to purs ide server via 'list' command, and formats the response."pursIdeList": async (args) => { if (!args || typeof args.listType !== 'string') { throw new Error("Invalid input: 'listType' (string) is required for pursIdeList."); } const params = { type: args.listType }; if (args.listType === "import") { if (typeof args.file !== 'string') { throw new Error("'file' (string) is required when listType is 'import'."); } params.file = args.file; } const result = await sendCommandToPursIde({ command: "list", params }); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; }
- index.js:772-784 (schema)Input schema defining the parameters for the 'pursIdeList' tool: listType (availableModules or import) and optional file path for import listing.{ name: "pursIdeList", description: "List available modules in the project or imports in a specific file. PREREQUISITES: IDE server running and modules loaded. Helps understand project structure and dependencies.", inputSchema: { type: "object", properties: { listType: { type: "string", enum: ["availableModules", "import"], description: "Type of list to retrieve." }, file: { type: "string", description: "Path to the .purs file (required for 'import' listType)." } }, required: ["listType"], additionalProperties: false } }
- index.js:1113-1126 (registration)Registration of the 'pursIdeList' handler in the INTERNAL_TOOL_HANDLERS object, mapping the tool name to its execution function."pursIdeList": async (args) => { if (!args || typeof args.listType !== 'string') { throw new Error("Invalid input: 'listType' (string) is required for pursIdeList."); } const params = { type: args.listType }; if (args.listType === "import") { if (typeof args.file !== 'string') { throw new Error("'file' (string) is required when listType is 'import'."); } params.file = args.file; } const result = await sendCommandToPursIde({ command: "list", params }); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; }
- index.js:772-784 (registration)Registration of the 'pursIdeList' tool in the TOOL_DEFINITIONS array, used by the tools/list MCP method to advertise available tools and their schemas.{ name: "pursIdeList", description: "List available modules in the project or imports in a specific file. PREREQUISITES: IDE server running and modules loaded. Helps understand project structure and dependencies.", inputSchema: { type: "object", properties: { listType: { type: "string", enum: ["availableModules", "import"], description: "Type of list to retrieve." }, file: { type: "string", description: "Path to the .purs file (required for 'import' listType)." } }, required: ["listType"], additionalProperties: false } }
- index.js:169-204 (helper)Shared helper function used by pursIdeList (and other pursIde* tools) to send JSON commands to the running purs ide TCP server and receive/parse responses.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}`))); }); }