Skip to main content
Glama

visum_custom_analysis

Execute custom Python code to analyze Visum transportation models, enabling tailored data processing and specialized calculations for specific project requirements.

Instructions

Execute custom Python code with access to the active Visum instance

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pythonCodeYesPython code to execute. The 'visum' variable contains the active VisumPy instance. Store results in 'result' dictionary.
descriptionNoOptional description of the analysis being performed

Implementation Reference

  • Handler function that executes custom Python code on the persistent VisumPy instance via visumController.executeCustomCode, processes the result, filters output, and returns formatted Markdown response with results, performance metrics, or error messages.
    async ({ pythonCode, description }) => {
      try {
        const result = await visumController.executeCustomCode(pythonCode, description);
        
        if (result.success) {
          let analysisResults = '';
          if (result.result) {
            analysisResults = `**Risultati Analisi:**\n\`\`\`json\n${JSON.stringify(result.result, null, 2)}\n\`\`\`\n\n`;
          }
          
          let executionOutput = '';
          if (result.output) {
            const outputLines = result.output.split('\n').filter(line => 
              line.trim() && 
              !line.includes('=====') && 
              !line.includes('Executing analysis') &&
              !line.includes('SUCCESS: Tool call completed')
            );
            if (outputLines.length > 0) {
              executionOutput = `**Output Esecuzione:**\n\`\`\`\n${outputLines.slice(-20).join('\n')}\n\`\`\`\n\n`;
            }
          }
          
          return {
            content: [
              {
                type: "text",
                text: `✅ **Analisi Personalizzata Completata**\n\n` +
                      `**Descrizione:** ${description || 'Analisi Python personalizzata'}\n\n` +
                      analysisResults +
                      executionOutput +
                      `**Performance:**\n` +
                      `• **Tempo Esecuzione:** ${result.executionTimeMs?.toFixed(3) || 'N/A'}ms\n\n` +
                      `*Eseguito su istanza VisumPy persistente*`
              }
            ]
          };
        } else {
          return {
            content: [
              {
                type: "text",
                text: `❌ **Analisi personalizzata fallita**\n\n` +
                      `**Errore:** ${result.error || 'Errore sconosciuto'}\n\n` +
                      `**Codice tentato:**\n\`\`\`python\n${pythonCode}\n\`\`\`\n\n` +
                      `*Controllare la sintassi Python e l'uso corretto della variabile 'visum'*`
              }
            ]
          };
        }
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `❌ **Errore esecuzione analisi personalizzata:**\n\n${error instanceof Error ? error.message : String(error)}`
            }
          ]
        };
      }
  • Zod input schema defining 'pythonCode' (required string) for the Python script to run in VisumPy context, and optional 'description' string.
    pythonCode: z.string().describe("Python code to execute. The 'visum' variable contains the active VisumPy instance. Store results in 'result' dictionary."),
    description: z.string().optional().describe("Optional description of the analysis being performed")
  • MCP server.tool registration for 'visum_custom_analysis' tool, including description, schema, and inline handler.
    server.tool(
      "visum_custom_analysis",
      "Execute custom Python code with access to the active Visum instance",
      {
        pythonCode: z.string().describe("Python code to execute. The 'visum' variable contains the active VisumPy instance. Store results in 'result' dictionary."),
        description: z.string().optional().describe("Optional description of the analysis being performed")
      },
      async ({ pythonCode, description }) => {
        try {
          const result = await visumController.executeCustomCode(pythonCode, description);
          
          if (result.success) {
            let analysisResults = '';
            if (result.result) {
              analysisResults = `**Risultati Analisi:**\n\`\`\`json\n${JSON.stringify(result.result, null, 2)}\n\`\`\`\n\n`;
            }
            
            let executionOutput = '';
            if (result.output) {
              const outputLines = result.output.split('\n').filter(line => 
                line.trim() && 
                !line.includes('=====') && 
                !line.includes('Executing analysis') &&
                !line.includes('SUCCESS: Tool call completed')
              );
              if (outputLines.length > 0) {
                executionOutput = `**Output Esecuzione:**\n\`\`\`\n${outputLines.slice(-20).join('\n')}\n\`\`\`\n\n`;
              }
            }
            
            return {
              content: [
                {
                  type: "text",
                  text: `✅ **Analisi Personalizzata Completata**\n\n` +
                        `**Descrizione:** ${description || 'Analisi Python personalizzata'}\n\n` +
                        analysisResults +
                        executionOutput +
                        `**Performance:**\n` +
                        `• **Tempo Esecuzione:** ${result.executionTimeMs?.toFixed(3) || 'N/A'}ms\n\n` +
                        `*Eseguito su istanza VisumPy persistente*`
                }
              ]
            };
          } else {
            return {
              content: [
                {
                  type: "text",
                  text: `❌ **Analisi personalizzata fallita**\n\n` +
                        `**Errore:** ${result.error || 'Errore sconosciuto'}\n\n` +
                        `**Codice tentato:**\n\`\`\`python\n${pythonCode}\n\`\`\`\n\n` +
                        `*Controllare la sintassi Python e l'uso corretto della variabile 'visum'*`
                }
              ]
            };
          }
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `❌ **Errore esecuzione analisi personalizzata:**\n\n${error instanceof Error ? error.message : String(error)}`
              }
            ]
          };
        }
      }
    );
  • Helper method in PersistentVisumController that delegates custom Python code execution to the persistent Python subprocess via JSON stdin command.
    public async executeCustomCode(pythonCode: string, description?: string): Promise<VisumResponse> {
      return this.sendCommandToPersistentProcess(pythonCode, description);
    }
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 mentions 'access to the active Visum instance' and implies code execution, but fails to disclose critical traits: whether this is a read-only or destructive operation, potential security risks of arbitrary code execution, error handling, or output format. For a tool executing custom code, this is a significant gap in 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 a single, front-loaded sentence that directly states the tool's purpose without unnecessary words. Every element ('Execute custom Python code', 'with access to the active Visum instance') earns its place by conveying essential information efficiently. There is zero waste or redundancy.

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 complexity of executing custom Python code and the lack of annotations and output schema, the description is incomplete. It doesn't address safety, permissions, result handling (e.g., the 'result' dictionary mentioned in the schema), or error scenarios. For a powerful, open-ended tool like this, the description should provide more context to guide safe and effective use.

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 both parameters thoroughly. The description adds no additional meaning beyond what's in the schema—it doesn't explain parameter interactions, coding conventions, or examples. With high schema coverage, the baseline is 3, as the description doesn't compensate but also doesn't detract.

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 ('Execute custom Python code') and the target resource ('with access to the active Visum instance'), making the purpose immediately understandable. It distinguishes itself from siblings like 'project_execute' or 'visum_network_analysis' by specifying custom code execution rather than predefined operations. However, it doesn't explicitly contrast with all siblings, so it's not a perfect 5.

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. It doesn't mention prerequisites (e.g., requires an active Visum instance), exclusions, or compare it to siblings like 'project_execute_analysis' or 'visum_network_analysis'. The agent must infer usage from the purpose alone, which is insufficient for optimal tool selection.

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/multiluca2020/visum-thinker-mcp-server'

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