Skip to main content
Glama
mcp360

MCP360 Universal Gateway

Official
by mcp360

execute

Execute MCP tools from 100+ services through a unified gateway by specifying service, tool, and parameters for integrated operations.

Instructions

execute tool

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
serviceYes
toolYes
parametersYes

Implementation Reference

  • The async handler function that implements the core logic of the 'execute' tool: validates tool existence, calls the target tool via GatewayClient, formats results, and handles errors.
    handler: async (args: any, client: GatewayClient) => {
      try {
        // Validate that tool exists
        const tools = await client.listTools();
        const tool = tools.find(t => t.name === args.tool_name);
    
        if (!tool) {
          return {
            content: [{
              type: 'text' as const,
              text: `Tool "${args.tool_name}" not found. Use the "search" tool to discover available tools.`,
            }],
            isError: true,
          };
        }
    
        // Execute the tool
        const result = await client.callTool(args.tool_name, args.arguments || {});
    
        // Format the result
        if (result.content) {
          // MCP standard response format
          return result;
        } else if (typeof result === 'object') {
          // Convert object result to text
          return {
            content: [{
              type: 'text' as const,
              text: JSON.stringify(result, null, 2),
            }],
          };
        } else {
          // Simple value result
          return {
            content: [{
              type: 'text' as const,
              text: String(result),
            }],
          };
        }
      } catch (error) {
        return {
          content: [{
            type: 'text' as const,
            text: `Error executing tool "${args.tool_name}": ${error instanceof Error ? error.message : 'Unknown error'}`,
          }],
          isError: true,
        };
      }
    },
  • The Zod input schema defining parameters for the 'execute' tool: required 'tool_name' and optional 'arguments'.
    inputSchema: z.object({
      tool_name: z.string().describe('Name of the tool to execute (use the search tool to discover available tools)'),
      arguments: z.record(z.any()).optional().describe('Tool-specific parameters as a JSON object. Each tool has different required and optional parameters.'),
    }),
  • The complete tool definition object exported as 'executeTool', registering the tool's metadata, schema, and handler for use in an MCP-compatible framework.
    export const executeTool = {
      name: 'execute',
      description: 'Execute any tool from any connected MCP server. First use the "search" tool to discover available tools and their parameters.',
      inputSchema: z.object({
        tool_name: z.string().describe('Name of the tool to execute (use the search tool to discover available tools)'),
        arguments: z.record(z.any()).optional().describe('Tool-specific parameters as a JSON object. Each tool has different required and optional parameters.'),
      }),
      handler: async (args: any, client: GatewayClient) => {
        try {
          // Validate that tool exists
          const tools = await client.listTools();
          const tool = tools.find(t => t.name === args.tool_name);
    
          if (!tool) {
            return {
              content: [{
                type: 'text' as const,
                text: `Tool "${args.tool_name}" not found. Use the "search" tool to discover available tools.`,
              }],
              isError: true,
            };
          }
    
          // Execute the tool
          const result = await client.callTool(args.tool_name, args.arguments || {});
    
          // Format the result
          if (result.content) {
            // MCP standard response format
            return result;
          } else if (typeof result === 'object') {
            // Convert object result to text
            return {
              content: [{
                type: 'text' as const,
                text: JSON.stringify(result, null, 2),
              }],
            };
          } else {
            // Simple value result
            return {
              content: [{
                type: 'text' as const,
                text: String(result),
              }],
            };
          }
        } catch (error) {
          return {
            content: [{
              type: 'text' as const,
              text: `Error executing tool "${args.tool_name}": ${error instanceof Error ? error.message : 'Unknown error'}`,
            }],
            isError: true,
          };
        }
      },
    };

Tool Definition Quality

Score is being calculated. Check back soon.

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/mcp360/mcp360-mcp'

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