Skip to main content
Glama

run_custom_tool

Run a custom tool from your project configuration by specifying its name and arguments. Use it to execute predefined scripts or commands with dynamic parameters via {{key}} placeholders.

Instructions

Execute a custom tool defined in project configuration

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
toolNameYesName of the custom tool to run
argsNoArguments to pass to the custom tool (replaces {{key}} placeholders)

Implementation Reference

  • The handler function that executes custom tools. It looks up the tool by name from project config customTools, substitutes {{key}} placeholders with provided args, then runs the command via runCommand with skipAllowedCheck=true.
    async runCustomTool(toolName: string, args?: Record<string, any>): Promise<ToolResult> {
      try {
        const config = await this.configService.loadProjectConfig();
        
        const customTool = config.customTools?.find(tool => tool.name === toolName);
        if (!customTool) {
          return {
            isError: true,
            content: [{
              type: 'text',
              text: `Custom tool '${toolName}' not found in project configuration`
            }]
          };
        }
    
        // Replace placeholders in command if args provided
        let command = customTool.command;
        if (args) {
          for (const [key, value] of Object.entries(args)) {
            command = command.replace(new RegExp(`\\{\\{${key}\\}\\}`, 'g'), String(value));
          }
        }
    
        return this.runCommand(command, {
          skipAllowedCheck: true, // Custom tools are pre-approved
          commitResult: true,
          commitMessage: `Executed custom tool: ${toolName}`
        });
    
      } catch (error) {
        return {
          isError: true,
          content: [{
            type: 'text',
            text: `Failed to execute custom tool: ${error}`
          }]
        };
      }
    }
  • src/index.ts:349-350 (registration)
    Registration of 'run_custom_tool' in the main tool execution switch statement, dispatching to SecureCommandService.runCustomTool.
    case 'run_custom_tool':
      return await this.secureCommandService.runCustomTool(args.toolName, args.args);
  • The schema definition for the run_custom_tool tool, specifying toolName (required string) and args (optional object for placeholder substitution).
      name: 'run_custom_tool',
      description: 'Execute a custom tool defined in project configuration',
      inputSchema: {
        type: 'object',
        properties: {
          toolName: { type: 'string', description: 'Name of the custom tool to run' },
          args: { type: 'object', description: 'Arguments to pass to the custom tool (replaces {{key}} placeholders)' }
        },
        required: ['toolName']
      }
    },
  • The ProjectConfig interface defining the customTools array structure (name, command, description, args) that stores custom tool definitions.
    customTools?: Array<{
      name: string;
      command: string;
      description: string;
      args?: Record<string, any>;
    }>;
  • The ToolResult interface used as the return type for all tool handlers including runCustomTool.
    export interface ToolResult {
      content: Array<{
        type: 'text' | 'image';
        text?: string;
        data?: string;
        mimeType?: string;
        _meta?: Record<string, any>;
      }>;
      isError?: boolean;
      _meta?: Record<string, any>;
Behavior2/5

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

No annotations are provided, and the description only says 'Execute' with no disclosure of behavioral traits such as side effects, permissions, or error handling. This leaves the agent with insufficient behavioral context.

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 concise sentence that front-loads the core purpose without any wasted words.

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?

The description only states purpose but lacks details on prerequisites, return values, or execution context. Given the tool runs arbitrary custom code, more context is needed for safe invocation.

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 coverage is 100%, so baseline is 3. The description does not add meaning beyond the parameter descriptions already in the schema, which adequately document toolName and args.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool executes a custom tool defined in project configuration, using a specific verb 'Execute' and resource 'custom tool defined in project configuration', distinguishing it from sibling tools like run_command or run_javascript.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when a custom tool is configured, but provides no explicit guidance on when to use alternatives or when not to use this tool.

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/agentics-ai/code-mcp'

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