Skip to main content
Glama

project_execute

Execute Python commands on a project TCP server to run code within the Visum Thinker context for structured problem-solving tasks.

Instructions

Execute a command on a project TCP server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdYesProject ID to execute command on
codeYesPython code to execute in the Visum context
descriptionYesDescription of what the code does

Implementation Reference

  • Registration of the 'project_execute' MCP tool, including input schema (Zod) and inline handler function that delegates execution to ProjectServerManager.executeCommand and formats the MCP response.
    server.tool(
      "project_execute",
      "Execute a command on a project TCP server",
      {
        projectId: z.string().describe("Project ID to execute command on"),
        code: z.string().describe("Python code to execute in the Visum context"),
        description: z.string().describe("Description of what the code does")
      },
      async ({ projectId, code, description }) => {
        try {
          const result = await serverManager.executeCommand(projectId, code, description);
          
          if (result.success) {
            return {
              content: [
                {
                  type: "text",
                  text: `⚔ **Comando Eseguito**\n\nāœ… ${description}\n\nšŸ“Š **Risultato:**\n\`\`\`json\n${JSON.stringify(result.result, null, 2)}\n\`\`\`\n\nā±ļø **Performance:**\n- Tempo risposta: ${result.responseTimeMs}ms\n- Esecuzione VisumPy: ${result.executionTimeMs}ms`
                }
              ]
            };
          } else {
            return {
              content: [
                {
                  type: "text",
                  text: `āŒ **Errore Esecuzione**\n\n${result.error}`
                }
              ]
            };
          }
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `āŒ **Errore:** ${error instanceof Error ? error.message : String(error)}`
              }
            ]
          };
        }
      }
    );
  • Core handler logic in ProjectServerManager: forwards the Python code as a 'query' command to the project's TCP server via sendCommandToServer.
    async executeCommand(projectId: string, code: string, description: string): Promise<any> {
      return await this.sendCommandToServer(projectId, {
        type: 'query',
        code,
        description
      });
    }
  • TCP client implementation: Establishes TCP connection to the project-specific server (spawned by project_open), sends JSON command with code, receives and parses JSON response.
    async sendCommandToServer(projectId: string, command: any): Promise<any> {
      const serverInfo = this.activeServers.get(projectId);
      if (!serverInfo) {
        throw new Error('Server progetto non trovato');
      }
    
      return new Promise((resolve, reject) => {
        const client = createConnection(serverInfo.port, 'localhost');
        let buffer = '';
        
        client.on('connect', () => {
          const message = JSON.stringify({ ...command, requestId: Date.now() });
          client.write(message + '\n');
        });
    
        client.on('data', (data: any) => {
          buffer += data.toString();
          
          // Dividi per newlines per separare i messaggi
          const messages = buffer.split('\n');
          buffer = messages.pop() || ''; // Mantieni l'ultimo pezzo (potrebbe essere incompleto)
          
          for (const message of messages) {
            if (message.trim()) {
              try {
                // Rimuovi backslash-n letterali che il server TCP Python aggiunge
                const cleanedResponse = message.replace(/\\n$/g, '');
                const response = JSON.parse(cleanedResponse);
                
                // Ignora il messaggio di welcome, aspetta la risposta vera
                if (response.type === 'project_welcome') {
                  continue;
                }
                
                // Risposta al comando ricevuta (query_result, save_result, error, etc.)
                if (response.type === 'query_result' || response.type === 'save_result' || 
                    response.type === 'error' || response.type === 'shutdown_ack' ||
                    response.result !== undefined) {
                  client.end();
                  resolve(response);
                  return;
                }
              } catch (error) {
                // Ignora messaggi malformati, continua ad aspettare
                console.error('WARN: Messaggio TCP non parsabile:', message);
              }
            }
          }
        });
    
        client.on('error', (error: any) => {
          reject(error);
        });
    
        setTimeout(() => {
          client.end();
          reject(new Error('Timeout comando server'));
        }, 300000); // 5 minuti timeout per operazioni pesanti su reti grandi
      });
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions 'execute a command' but doesn't disclose critical behavioral traits: whether this is a read-only or destructive operation, authentication requirements, rate limits, expected execution environment (e.g., Visum context implied by parameter but not described), or what happens on the TCP server. This leaves significant gaps for safe and effective use.

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, clear sentence with zero wasted words. It's front-loaded with the core action and target, making it easy to parse quickly. Every word earns its place by conveying essential information without 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 code on a TCP server with no annotations and no output schema, the description is insufficient. It lacks details on behavioral risks (e.g., destructive effects), expected outputs, error handling, or how it integrates with sibling tools. For a tool that likely performs significant operations, more context is needed for safe agent 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 fully documents each parameter's purpose. The description adds no additional meaning beyond implying execution in a 'Visum context' (hinted by the 'code' parameter description but not elaborated). With high schema coverage, the baseline score of 3 is appropriate as the description doesn't enhance parameter understanding.

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 a command') and target ('on a project TCP server'), which is specific and actionable. It doesn't explicitly differentiate from siblings like 'project_execute_analysis' or 'visum_custom_analysis', but the verb+resource combination is unambiguous within the context of project operations.

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?

No guidance is provided on when to use this tool versus alternatives. With siblings like 'project_execute_analysis', 'visum_custom_analysis', and 'visum_create_procedure' that might overlap in executing code or commands, the description lacks any context about appropriate use cases, prerequisites, or distinctions.

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