Skip to main content
Glama

Visum Thinker MCP Server

MIT License
test-final-export.json•3.97 kB
{ "method": "tools/call", "params": { "name": "project_execute", "arguments": { "projectId": "S000009result_1278407893", "code": "import os\nimport csv\nimport xml.etree.ElementTree as ET\n\nresult = {'exported_files': [], 'errors': [], 'tables_found': 0}\n\ntry:\n # Get project info\n ver_path = visum.GetPath(1)\n project_dir = os.path.dirname(ver_path)\n project_name = os.path.splitext(os.path.basename(ver_path))[0]\n \n result['project'] = project_name\n \n # Parse layout XML\n lay_file = os.path.join(project_dir, 'tabelle_report.lay')\n tree = ET.parse(lay_file)\n root = tree.getroot()\n \n # Extract tables\n for list_item in root.iter('listLayoutItem'):\n try:\n # Get table name\n common = list_item.find('.//listLayoutCommonEntries')\n if common is None:\n continue\n \n list_title = common.get('listTitle', 'Unknown')\n \n # Get netObjectType\n graphic = list_item.find('.//listGraphicParameterLayoutItems')\n if graphic is None:\n continue\n \n net_type = graphic.get('netObjectType', '')\n if not net_type:\n continue\n \n # Get columns (attributeID)\n columns = []\n for attr_def in list_item.iter('attributeDefinition'):\n attr_id = attr_def.get('attributeID')\n if attr_id:\n columns.append(attr_id)\n \n if not columns:\n continue\n \n result['tables_found'] += 1\n \n # Map to Visum collection\n collection_map = {\n 'LINK': ('Links', 'No'),\n 'ZONE': ('Zones', 'No'),\n 'NODE': ('Nodes', 'No'),\n 'ODPAIR': ('ODPairs', 'No'),\n 'LINE': ('Lines', 'Name')\n }\n \n if net_type not in collection_map:\n result['errors'].append(f'{list_title}: tipo {net_type} non supportato')\n continue\n \n coll_name, key_attr = collection_map[net_type]\n collection = getattr(visum.Net, coll_name)\n \n # Export to CSV\n safe_title = list_title.replace(' ', '_').replace('(', '').replace(')', '')\n csv_file = os.path.join(project_dir, f'{project_name}_{safe_title}.csv')\n \n with open(csv_file, 'w', newline='', encoding='utf-8') as f:\n writer = csv.writer(f, delimiter=';')\n writer.writerow(columns)\n \n rows = 0\n for i in range(min(100, collection.Count)): # Max 100 righe per ora\n try:\n item = collection.ItemByKey(i+1) if key_attr == 'No' else collection.Item(i)\n row = []\n for col in columns:\n try:\n row.append(item.AttValue(col))\n except:\n row.append('')\n writer.writerow(row)\n rows += 1\n except:\n pass\n \n result['exported_files'].append({\n 'table': list_title,\n 'file': os.path.basename(csv_file),\n 'rows': rows,\n 'cols': len(columns)\n })\n \n except Exception as e:\n result['errors'].append(f'Table error: {str(e)}')\n \n result['status'] = 'SUCCESS'\n \nexcept Exception as e:\n result['status'] = 'FAILED'\n result['error'] = str(e)\n\nresult", "description": "Export visible tables from layout to CSV" } }, "jsonrpc": "2.0", "id": 1 }

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