Skip to main content
Glama

pursIdeUsages

Identify all instances where a specific function, type, or value is used across a PureScript project using the PureScript MCP Server. Ensures accurate refactoring by showing the impact of changes across modules.

Instructions

Find everywhere a specific function, type, or value is used across the project. PREREQUISITES: IDE server running and modules loaded. Essential for refactoring - shows impact of changes. If you plan to refactor, get usages before refactoring so you can make changes to all places that function is used.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
identifierYesThe identifier to find usages for.
moduleYesModule where the identifier is defined.
namespaceYesNamespace of the identifier.

Implementation Reference

  • Handler function for 'pursIdeUsages' tool. Validates input parameters (module, namespace, identifier), constructs params, sends 'usages' command to purs ide server via sendCommandToPursIde, and returns the JSON-formatted result.
    "pursIdeUsages": async (args) => {
        if (!args || typeof args.module !== 'string' || typeof args.namespace !== 'string' || typeof args.identifier !== 'string') {
            throw new Error("Invalid input: 'module', 'namespace', and 'identifier' (strings) are required for pursIdeUsages.");
        }
        const params = {
            module: args.module,
            namespace: args.namespace,
            identifier: args.identifier
        };
        const result = await sendCommandToPursIde({ command: "usages", params });
        return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
    },
  • Input schema definition for 'pursIdeUsages' tool, specifying required parameters: module, namespace (value/type/kind), identifier.
    {
        name: "pursIdeUsages",
        description: "Find everywhere a specific function, type, or value is used across the project. PREREQUISITES: IDE server running and modules loaded. Essential for refactoring - shows impact of changes. If you plan to refactor, get usages before refactoring so you can make changes to all places that function is used.",
        inputSchema: {
            type: "object",
            properties: {
                module: { type: "string", description: "Module where the identifier is defined." },
                namespace: { type: "string", enum: ["value", "type", "kind"], description: "Namespace of the identifier." },
                identifier: { type: "string", description: "The identifier to find usages for." }
            },
            required: ["module", "namespace", "identifier"],
            additionalProperties: false
        }
    },
  • index.js:1101-1113 (registration)
    Registration of the handler in INTERNAL_TOOL_HANDLERS map, which is used in tools/call to dispatch to the handler.
    "pursIdeUsages": async (args) => {
        if (!args || typeof args.module !== 'string' || typeof args.namespace !== 'string' || typeof args.identifier !== 'string') {
            throw new Error("Invalid input: 'module', 'namespace', and 'identifier' (strings) are required for pursIdeUsages.");
        }
        const params = {
            module: args.module,
            namespace: args.namespace,
            identifier: args.identifier
        };
        const result = await sendCommandToPursIde({ command: "usages", params });
        return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
    },
    "pursIdeList": async (args) => {
  • index.js:1158-1164 (registration)
    Registration via tools/list endpoint returning TOOL_DEFINITIONS array containing the pursIdeUsages tool definition (not excluded).
    if (method === 'tools/list') {
        const toolsToExclude = ['query_purescript_ast', 'query_purs_ide']; // Keep query_purs_ide for now, for direct access if needed
        const filteredToolDefinitions = TOOL_DEFINITIONS.filter(
            tool => !toolsToExclude.includes(tool.name)
        );
        return createSuccessResponse(id, { tools: filteredToolDefinitions });
    }
  • Helper function sendCommandToPursIde that establishes TCP connection to purs ide server, sends JSON command (like {command: 'usages', params}), receives and parses JSON response. Core communication layer used by the handler.
    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}`)));
        });
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively indicates this is a read-only analysis tool ('Find everywhere... is used') and adds useful context about prerequisites and refactoring workflow. However, it lacks details on output format, error handling, or performance characteristics that would enhance transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured with three sentences that each serve distinct purposes: stating the core functionality, listing prerequisites, and providing usage guidance. There's no wasted text, and the information is front-loaded with the main purpose immediately clear.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no annotations and no output schema, the description does well in covering purpose, prerequisites, and usage context. It could be more complete by describing the return format or what constitutes a 'usage' result, but given the schema's thorough parameter documentation and the clear behavioral context provided, it's largely adequate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all three parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema, maintaining the baseline score. It doesn't compensate but doesn't need to given the comprehensive schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('Find') and resource ('usages of a specific function, type, or value across the project'). It distinguishes itself from siblings like 'getFunctionNames' or 'getTopLevelDeclarations' by focusing on cross-project usage analysis rather than listing or querying definitions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on when to use this tool ('Essential for refactoring - shows impact of changes') and when to invoke it ('If you plan to refactor, get usages before refactoring'). It also mentions prerequisites ('IDE server running and modules loaded'), offering clear context for proper usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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