Skip to main content
Glama

execute_agent

Execute an AI agent with a specific goal to activate behavioral personas for dynamic AI persona management.

Instructions

Execute an agent element with a specific goal

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesThe agent name to execute
goalYesThe goal for the agent to achieve

Implementation Reference

  • Tool definition including name, description, input schema, and handler implementation for 'execute_agent'. The handler delegates execution to server.executeAgent(name, goal).
    {
      tool: {
        name: "execute_agent",
        description: "Execute an agent element with a specific goal",
        inputSchema: {
          type: "object",
          properties: {
            name: {
              type: "string",
              description: "The agent name to execute",
            },
            goal: {
              type: "string",
              description: "The goal for the agent to achieve",
            },
          },
          required: ["name", "goal"],
        },
      },
      handler: (args: ExecuteAgentArgs) => server.executeAgent(args.name, args.goal)
    },
  • Type definition for ExecuteAgentArgs used in the tool handler.
    interface ExecuteAgentArgs {
      name: string;
      goal: string;
    }
  • Registration of all element tools, including 'execute_agent', via getElementTools(instance) in the ToolRegistry.
    // Register element tools (new generic tools for all element types)
    this.toolRegistry.registerMany(getElementTools(instance));
  • IToolHandler interface definition for the executeAgent method signature used by the tool handler.
    executeAgent(name: string, goal: string): Promise<any>;
  • Access to ToolRegistry instance where tools are registered and handlers stored.
      logger.debug('ToolDiscoveryCache: Cache invalidated due to tool registration');
    }
    
    /**
     * Setup the ListToolsRequest handler with caching
     */
    private setupListToolsHandler(server: Server): void {
      server.setRequestHandler(ListToolsRequestSchema, async () => {
        const startTime = Date.now();
        
        // Try to get cached tools first
        let tools = this.toolCache.getToolList();
        
        if (!tools) {
          // Cache miss - fetch tools from registry
          tools = this.toolRegistry.getAllTools();
          
          // Cache the results for future requests
          this.toolCache.setToolList(tools);
          
          const duration = Date.now() - startTime;
          logger.info('ToolDiscoveryCache: Cache miss - fetched and cached tools', {
            toolCount: tools.length,
            duration: `${duration}ms`,
            source: 'registry'
          });
        } else {
          const duration = Date.now() - startTime;
          logger.debug('ToolDiscoveryCache: Cache hit - returned cached tools', {
            toolCount: tools.length,
            duration: `${duration}ms`,
            source: 'cache'
          });
        }
        
        return { tools };
      });
    }
    
    /**
     * Setup the CallToolRequest handler
     */
    private setupCallToolHandler(server: Server): void {
      server.setRequestHandler(CallToolRequestSchema, async (request) => {
        const { name, arguments: args } = request.params;
        
        try {
          const handler = this.toolRegistry.getHandler(name);
          
          if (!handler) {
            throw new McpError(
              ErrorCode.MethodNotFound,
              `Unknown tool: ${name}`
            );
          }
          
          // Normalize Unicode in all string arguments to prevent security bypasses
          const normalizedArgs = this.normalizeArgumentsUnicode(args, name);
          
          const response = await handler(normalizedArgs);
          
          // Wizard auto-trigger removed for v1.8.0
          // Manual wizard still available via config tool with action: 'wizard'
          
          return response;
        } catch (error) {
          if (error instanceof McpError) {
            throw error;
          }
          
          throw new McpError(
            ErrorCode.InternalError,
            `Error executing tool ${name}: ${error}`
          );
        }
      });
    }
    
    /**
     * Recursively normalize Unicode in all string values within arguments
     */
    private normalizeArgumentsUnicode(args: any, toolName: string): any {
      if (args === null || args === undefined) {
        return args;
      }
      
      if (typeof args === 'string') {
        const result = UnicodeValidator.normalize(args);
        if (result.detectedIssues && result.detectedIssues.length > 0) {
          logger.warn(`Unicode security issues detected in tool ${toolName}:`, {
            issues: result.detectedIssues,
            severity: result.severity
          });
        }
        return result.normalizedContent;
      }
      
      if (Array.isArray(args)) {
        return args.map(item => this.normalizeArgumentsUnicode(item, toolName));
      }
      
      if (typeof args === 'object') {
        const normalized: any = {};
        for (const [key, value] of Object.entries(args)) {
          // Normalize both keys and values to prevent Unicode attacks in property names
          const normalizedKey = typeof key === 'string' ? 
            UnicodeValidator.normalize(key).normalizedContent : key;
          normalized[normalizedKey] = this.normalizeArgumentsUnicode(value, toolName);
        }
        return normalized;
      }
      
      // For non-string primitive types, return as-is
      return args;
    }
    
    /**
     * Get the tool registry
     */
    getToolRegistry(): ToolRegistry {
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 states the action ('Execute') but does not explain what happens during execution (e.g., if it runs a process, returns output, or modifies state), potential side effects, permissions needed, or error handling, which is insufficient for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is front-loaded and to the point, though it could benefit from more detail to improve clarity and completeness.

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 an agent, lack of annotations, and no output schema, the description is incomplete. It fails to explain what the tool returns, how execution works, or any behavioral traits, making it inadequate for proper agent use without additional context.

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?

The input schema has 100% description coverage, with parameters 'name' and 'goal' clearly documented. The description adds no additional meaning beyond the schema, such as examples or constraints, but since the schema is comprehensive, the baseline score of 3 is appropriate as it doesn't detract from understanding.

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

Purpose3/5

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

The description states the tool's purpose as 'Execute an agent element with a specific goal,' which includes a verb ('Execute') and resource ('agent element'), but it's vague about what 'execute' entails (e.g., running, triggering, or activating an agent). It does not distinguish from siblings like 'activate_element' or 'deactivate_element,' leaving ambiguity in its specific function.

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. The description lacks context on prerequisites, such as whether the agent must be active or configured, and does not mention sibling tools like 'activate_element' or 'deactivate_element' for comparison, leaving usage unclear.

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/DollhouseMCP/DollhouseMCP'

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