Skip to main content
Glama

visum_network_analysis

Analyze Visum network performance with detailed statistics and metrics to evaluate transportation system efficiency and identify improvement areas.

Instructions

Analyze the loaded Visum network with detailed statistics and performance metrics

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
includeGeometryNoInclude geometric analysis of network elements
sampleSizeNoNumber of sample elements to analyze (default: 50)

Implementation Reference

  • Complete tool definition including registration, input schema, and handler logic. The handler constructs and executes a comprehensive Python script for Visum network analysis (nodes, links, zones, geometry, samples) using PersistentVisumController.executeCustomCode, then formats and returns detailed statistics and performance metrics.
    server.tool(
      "visum_network_analysis",
      "Analyze the loaded Visum network with detailed statistics and performance metrics",
      {
        includeGeometry: z.boolean().optional().default(false).describe("Include geometric analysis of network elements"),
        sampleSize: z.number().optional().default(50).describe("Number of sample elements to analyze (default: 50)")
      },
      async ({ includeGeometry, sampleSize }) => {
        try {
          let analysisCode = `
    # Comprehensive network analysis
    import time
    try:
        start_time = time.time()
        
        # Basic network statistics
        num_nodes = visum.Net.Nodes.Count
        num_links = visum.Net.Links.Count
        num_zones = visum.Net.Zones.Count
        num_stops = visum.Net.Stops.Count if hasattr(visum.Net, 'Stops') else 0
        num_lines = visum.Net.Lines.Count if hasattr(visum.Net, 'Lines') else 0
        
        # Sample node analysis
        sample_nodes = []
        if num_nodes > 0:
            node_iter = visum.Net.Nodes.Iterator
            count = 0
            while node_iter.Valid and count < ${sampleSize}:
                node = node_iter.Item
                sample_nodes.append({
                    'id': node.AttValue('No'),
                    'x': node.AttValue('XCoord') if hasattr(node, 'AttValue') else None,
                    'y': node.AttValue('YCoord') if hasattr(node, 'AttValue') else None
                })
                node_iter.Next()
                count += 1
        
        # Sample link analysis  
        sample_links = []
        if num_links > 0:
            link_iter = visum.Net.Links.Iterator
            count = 0
            while link_iter.Valid and count < ${sampleSize}:
                link = link_iter.Item
                sample_links.append({
                    'from_node': link.AttValue('FromNodeNo'),
                    'to_node': link.AttValue('ToNodeNo'),
                    'length': link.AttValue('Length') if hasattr(link, 'AttValue') else None
                })
                link_iter.Next()
                count += 1
        `;
    
          if (includeGeometry) {
            analysisCode += `
        # Geometric analysis
        total_length = 0.0
        if num_links > 0:
            link_iter = visum.Net.Links.Iterator
            while link_iter.Valid:
                try:
                    length = link_iter.Item.AttValue('Length')
                    if length:
                        total_length += length
                except:
                    pass
                link_iter.Next()
        `;
          }
    
          analysisCode += `
        analysis_time = time.time() - start_time
        
        result = {
            'network_statistics': {
                'nodes': num_nodes,
                'links': num_links,
                'zones': num_zones,
                'stops': num_stops,
                'lines': num_lines
            },
            'sample_analysis': {
                'nodes': sample_nodes[:10],  # Limit output
                'links': sample_links[:10]   # Limit output
            },${includeGeometry ? `
            'geometric_analysis': {
                'total_network_length_km': round(total_length / 1000, 2) if 'total_length' in locals() else None
            },` : ''}
            'performance': {
                'analysis_time_seconds': round(analysis_time, 3)
            },
            'analysis_successful': True
        }
        
    except Exception as e:
        result = {
            'analysis_successful': False,
            'error': str(e)
        }`;
    
          const result = await visumController.executeCustomCode(
            analysisCode,
            "Analisi completa della rete Visum"
          );
    
          if (result.success && result.result?.analysis_successful) {
            const analysis = result.result;
            const stats = analysis.network_statistics;
            
            let geometryInfo = '';
            if (includeGeometry && analysis.geometric_analysis) {
              geometryInfo = `**Analisi Geometrica:**\n` +
                            `• **Lunghezza Totale Rete:** ${analysis.geometric_analysis.total_network_length_km || 'N/A'} km\n\n`;
            }
    
            let sampleInfo = '';
            if (analysis.sample_analysis) {
              const sampleNodes = analysis.sample_analysis.nodes?.length || 0;
              const sampleLinks = analysis.sample_analysis.links?.length || 0;
              sampleInfo = `**Analisi Campionaria:**\n` +
                          `• **Nodi Analizzati:** ${sampleNodes}\n` +
                          `• **Link Analizzati:** ${sampleLinks}\n\n`;
            }
    
            return {
              content: [
                {
                  type: "text", 
                  text: `✅ **Analisi Rete Completata**\n\n` +
                        `**Statistiche Rete:**\n` +
                        `• **Nodi:** ${stats.nodes?.toLocaleString() || 'N/A'}\n` +
                        `• **Link:** ${stats.links?.toLocaleString() || 'N/A'}\n` +
                        `• **Zone:** ${stats.zones?.toLocaleString() || 'N/A'}\n` +
                        `• **Fermate:** ${stats.stops?.toLocaleString() || 'N/A'}\n` +
                        `• **Linee:** ${stats.lines?.toLocaleString() || 'N/A'}\n\n` +
                        sampleInfo +
                        geometryInfo +
                        `**Performance:**\n` +
                        `• **Tempo Analisi:** ${analysis.performance?.analysis_time_seconds || 'N/A'}s\n` +
                        `• **Tempo Esecuzione Tool:** ${result.executionTimeMs?.toFixed(3) || 'N/A'}ms\n\n` +
                        `*Analisi della rete completata con successo*`
                }
              ]
            };
          } else {
            return {
              content: [
                {
                  type: "text",
                  text: `❌ **Errore Analisi Rete**\n\n` +
                        `**Errore:** ${result.result?.error || result.error || 'Errore sconosciuto'}\n\n` +
                        `*Assicurarsi che un progetto Visum sia caricato correttamente*`
                }
              ]
            };
          }
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `❌ **Errore durante l'analisi:**\n\n${error instanceof Error ? error.message : String(error)}`
              }
            ]
          };
        }
      }
    );
  • Zod schema defining optional parameters for the visum_network_analysis tool: includeGeometry (boolean, default false) and sampleSize (number, default 50).
    {
      includeGeometry: z.boolean().optional().default(false).describe("Include geometric analysis of network elements"),
      sampleSize: z.number().optional().default(50).describe("Number of sample elements to analyze (default: 50)")
    },
  • MCP server tool registration call for 'visum_network_analysis' using server.tool(name, description, schema, handler).
    server.tool(
      "visum_network_analysis",
      "Analyze the loaded Visum network with detailed statistics and performance metrics",
      {
        includeGeometry: z.boolean().optional().default(false).describe("Include geometric analysis of network elements"),
        sampleSize: z.number().optional().default(50).describe("Number of sample elements to analyze (default: 50)")
      },
      async ({ includeGeometry, sampleSize }) => {
        try {
          let analysisCode = `
    # Comprehensive network analysis
    import time
    try:
        start_time = time.time()
        
        # Basic network statistics
        num_nodes = visum.Net.Nodes.Count
        num_links = visum.Net.Links.Count
        num_zones = visum.Net.Zones.Count
        num_stops = visum.Net.Stops.Count if hasattr(visum.Net, 'Stops') else 0
        num_lines = visum.Net.Lines.Count if hasattr(visum.Net, 'Lines') else 0
        
        # Sample node analysis
        sample_nodes = []
        if num_nodes > 0:
            node_iter = visum.Net.Nodes.Iterator
            count = 0
            while node_iter.Valid and count < ${sampleSize}:
                node = node_iter.Item
                sample_nodes.append({
                    'id': node.AttValue('No'),
                    'x': node.AttValue('XCoord') if hasattr(node, 'AttValue') else None,
                    'y': node.AttValue('YCoord') if hasattr(node, 'AttValue') else None
                })
                node_iter.Next()
                count += 1
        
        # Sample link analysis  
        sample_links = []
        if num_links > 0:
            link_iter = visum.Net.Links.Iterator
            count = 0
            while link_iter.Valid and count < ${sampleSize}:
                link = link_iter.Item
                sample_links.append({
                    'from_node': link.AttValue('FromNodeNo'),
                    'to_node': link.AttValue('ToNodeNo'),
                    'length': link.AttValue('Length') if hasattr(link, 'AttValue') else None
                })
                link_iter.Next()
                count += 1
        `;
    
          if (includeGeometry) {
            analysisCode += `
        # Geometric analysis
        total_length = 0.0
        if num_links > 0:
            link_iter = visum.Net.Links.Iterator
            while link_iter.Valid:
                try:
                    length = link_iter.Item.AttValue('Length')
                    if length:
                        total_length += length
                except:
                    pass
                link_iter.Next()
        `;
          }
    
          analysisCode += `
        analysis_time = time.time() - start_time
        
        result = {
            'network_statistics': {
                'nodes': num_nodes,
                'links': num_links,
                'zones': num_zones,
                'stops': num_stops,
                'lines': num_lines
            },
            'sample_analysis': {
                'nodes': sample_nodes[:10],  # Limit output
                'links': sample_links[:10]   # Limit output
            },${includeGeometry ? `
            'geometric_analysis': {
                'total_network_length_km': round(total_length / 1000, 2) if 'total_length' in locals() else None
            },` : ''}
            'performance': {
                'analysis_time_seconds': round(analysis_time, 3)
            },
            'analysis_successful': True
        }
        
    except Exception as e:
        result = {
            'analysis_successful': False,
            'error': str(e)
        }`;
    
          const result = await visumController.executeCustomCode(
            analysisCode,
            "Analisi completa della rete Visum"
          );
    
          if (result.success && result.result?.analysis_successful) {
            const analysis = result.result;
            const stats = analysis.network_statistics;
            
            let geometryInfo = '';
            if (includeGeometry && analysis.geometric_analysis) {
              geometryInfo = `**Analisi Geometrica:**\n` +
                            `• **Lunghezza Totale Rete:** ${analysis.geometric_analysis.total_network_length_km || 'N/A'} km\n\n`;
            }
    
            let sampleInfo = '';
            if (analysis.sample_analysis) {
              const sampleNodes = analysis.sample_analysis.nodes?.length || 0;
              const sampleLinks = analysis.sample_analysis.links?.length || 0;
              sampleInfo = `**Analisi Campionaria:**\n` +
                          `• **Nodi Analizzati:** ${sampleNodes}\n` +
                          `• **Link Analizzati:** ${sampleLinks}\n\n`;
            }
    
            return {
              content: [
                {
                  type: "text", 
                  text: `✅ **Analisi Rete Completata**\n\n` +
                        `**Statistiche Rete:**\n` +
                        `• **Nodi:** ${stats.nodes?.toLocaleString() || 'N/A'}\n` +
                        `• **Link:** ${stats.links?.toLocaleString() || 'N/A'}\n` +
                        `• **Zone:** ${stats.zones?.toLocaleString() || 'N/A'}\n` +
                        `• **Fermate:** ${stats.stops?.toLocaleString() || 'N/A'}\n` +
                        `• **Linee:** ${stats.lines?.toLocaleString() || 'N/A'}\n\n` +
                        sampleInfo +
                        geometryInfo +
                        `**Performance:**\n` +
                        `• **Tempo Analisi:** ${analysis.performance?.analysis_time_seconds || 'N/A'}s\n` +
                        `• **Tempo Esecuzione Tool:** ${result.executionTimeMs?.toFixed(3) || 'N/A'}ms\n\n` +
                        `*Analisi della rete completata con successo*`
                }
              ]
            };
          } else {
            return {
              content: [
                {
                  type: "text",
                  text: `❌ **Errore Analisi Rete**\n\n` +
                        `**Errore:** ${result.result?.error || result.error || 'Errore sconosciuto'}\n\n` +
                        `*Assicurarsi che un progetto Visum sia caricato correttamente*`
                }
              ]
            };
          }
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `❌ **Errore durante l'analisi:**\n\n${error instanceof Error ? error.message : String(error)}`
              }
            ]
          };
        }
      }
    );
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'detailed statistics and performance metrics' but doesn't specify what these include, whether the analysis is read-only or modifies data, potential performance impacts, or error conditions. For a tool with no annotation coverage, this leaves significant gaps in understanding its behavior.

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, well-structured sentence that efficiently conveys the core purpose without unnecessary words. It's front-loaded with the main action ('Analyze') and resource, making it easy to parse. Every part of the sentence adds value.

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

Completeness3/5

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

Given the tool's complexity (analysis with parameters) and lack of annotations or output schema, the description is minimally adequate but incomplete. It specifies what the tool does but omits critical details like output format, behavioral traits, and usage context. For a tool with no output schema, it should ideally hint at return values, but it doesn't, leaving gaps in understanding.

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 fully documents both parameters ('includeGeometry' and 'sampleSize') with descriptions and defaults. The tool description adds no parameter-specific information beyond what's in the schema, such as how 'sampleSize' affects results or what 'geometric analysis' entails. This 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 tool's purpose: 'Analyze the loaded Visum network with detailed statistics and performance metrics.' It specifies the verb ('analyze'), resource ('loaded Visum network'), and output type ('detailed statistics and performance metrics'). However, it doesn't explicitly differentiate from sibling tools like 'visum_network_stats' or 'visum_custom_analysis', which might offer similar functionality.

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., a network must be loaded), exclusions, or comparisons to sibling tools like 'visum_network_stats' or 'visum_custom_analysis'. The agent must infer usage from the tool name and context alone.

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