Skip to main content
Glama

create_module

Generate reusable code modules for cross-workflow automation in McFlow, enabling shared functionality across multiple workflows.

Instructions

Create a shared code module that can be used across workflows

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesName of the shared module
languageYesProgramming language for the module

Implementation Reference

  • ToolHandler.handleTool switch case for 'create_module' that instantiates NodeManager and calls createSharedModule with the provided name and language arguments.
    case 'create_module':
      const moduleManager = new NodeManager(this.workflowsPath);
      await moduleManager.initialize();
      return await moduleManager.createSharedModule(
        args?.name as string,
        args?.language as 'javascript' | 'python'
      );
  • The core implementation of createSharedModule in NodeManager. Creates a new shared module file in workflows/modules/ with appropriate template code for JavaScript or Python, checks for existence, and returns success/error message.
      async createSharedModule(name: string, language: 'javascript' | 'python'): Promise<any> {
        const modulesDir = path.join(this.workflowsPath, 'modules');
        await fs.mkdir(modulesDir, { recursive: true });
        
        const fileName = `${this.sanitizeFilename(name)}.${language === 'python' ? 'py' : 'js'}`;
        const filePath = path.join(modulesDir, fileName);
        
        // Check if module already exists
        try {
          await fs.access(filePath);
          return {
            content: [{
              type: 'text',
              text: `āŒ Module '${name}' already exists at ${filePath}`
            }]
          };
        } catch {
          // File doesn't exist, continue
        }
        
        // Create module template
        let template = '';
        if (language === 'javascript') {
          template = `/**
     * Shared Module: ${name}
     * Created by McFlow
     * 
     * This module can be imported in Code nodes using:
     * const ${name} = require('./modules/${fileName}');
     */
    
    // Example function
    function example() {
      return 'Hello from ${name}';
    }
    
    // Export functions for use in Code nodes
    module.exports = {
      example
    };`;
        } else {
          template = `"""
    Shared Module: ${name}
    Created by McFlow
    
    This module can be imported in Python Code nodes using:
    import sys
    sys.path.append('./modules')
    from ${this.sanitizeFilename(name)} import *
    """
    
    def example():
        """Example function"""
        return f"Hello from ${name}"
    
    # Functions are automatically available when imported`;
        }
        
        await fs.writeFile(filePath, template);
        
        return {
          content: [{
            type: 'text',
            text: `āœ… Created shared module: ${fileName}\nšŸ“ Location: ${filePath}\n\nYou can now edit this module and use it in your Code nodes.`
          }]
        };
      }
  • Tool registration in getToolDefinitions array, including name, description, and input schema definition for MCP protocol.
    {
      name: 'create_module',
      description: 'Create a shared code module that can be used across workflows',
      inputSchema: {
        type: 'object',
        properties: {
          name: {
            type: 'string',
            description: 'Name of the shared module',
          },
          language: {
            type: 'string',
            enum: ['javascript', 'python'],
            description: 'Programming language for the module',
          },
        },
        required: ['name', 'language'],
      },
    },
Behavior2/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 states the tool creates a module but doesn't mention permissions needed, whether it's idempotent, error handling, or what happens on success (e.g., returns a module ID). This is a significant gap for a creation tool with zero annotation coverage.

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 a single, efficient sentence that directly states the tool's purpose without redundancy. It's front-loaded and wastes no words, making it easy to parse quickly.

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

Completeness2/5

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

Given the tool creates a module (a mutation operation) with no annotations and no output schema, the description is incomplete. It doesn't explain what the tool returns, error conditions, or behavioral nuances, which are critical for an agent to use it effectively in workflows.

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?

The input schema has 100% description coverage, clearly documenting both parameters (name and language with enum). The description adds no additional parameter semantics beyond what the schema provides, such as naming conventions or language implications, so it meets the baseline for high schema coverage.

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

Purpose4/5

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

The description clearly states the action ('Create') and resource ('shared code module') with its purpose ('can be used across workflows'), making the tool's function understandable. However, it doesn't explicitly differentiate from sibling tools like 'create' or 'generate', which could be ambiguous in this context.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'create', 'generate', or 'generate_app' among the siblings. It lacks context about prerequisites, typical scenarios, or exclusions, leaving the agent without usage direction.

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

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/mckinleymedia/mcflow-mcp'

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