Skip to main content
Glama

stop_agent

Stop a loaded agent by disconnecting from relays. The active agent remains running.

Instructions

Stop a loaded agent. Disconnects from relays. Cannot stop the active agent.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes

Implementation Reference

  • The handler function for the 'stop_agent' tool. It prevents stopping the active agent, checks if the agent is loaded, disconnects from Nostr relays via agent.client.close(), scrubs secret key bytes from memory, and removes the agent from the registry.
    defineTool({
      name: 'stop_agent',
      description: 'Stop a loaded agent. Disconnects from relays. Cannot stop the active agent.',
      schema: StopAgentSchema,
      async handler(ctx, input) {
        if (input.name === ctx.activeAgentName) {
          return errorResult('Cannot stop the active agent. Switch to another agent first.');
        }
    
        const agent = ctx.registry.get(input.name);
        if (!agent) {
          return errorResult(`Agent "${input.name}" is not loaded.`);
        }
    
        agent.client.close();
        // best-effort scrub of secret key bytes before dropping the agent.
        if (agent.solanaKeypair) {
          agent.solanaKeypair.secretKey.fill(0);
        }
        agent.identity.scrub();
        ctx.registry.delete(input.name);
    
        return textResult(`Agent "${input.name}" stopped and removed.`);
      },
    }),
  • Zod schema for stop_agent input validation - expects a single required field 'name' (string).
    const StopAgentSchema = z.object({
      name: z.string(),
    });
  • agentTools (which includes stop_agent) is aggregated into allTools and registered with the MCP server via ListToolsRequestSchema/CallToolRequestSchema handlers.
    const allTools: ToolDefinition[] = [
      ...discoveryTools,
      ...customerTools,
      ...walletTools,
      ...dashboardTools,
      ...agentTools,
      ...feedbackContactsTools,
      ...policiesTools,
    ];
  • stop_agent is exported as part of the agentTools array from agent.ts, alongside create_agent, switch_agent, and list_agents.
    export const agentTools: ToolDefinition[] = [
  • The defineTool helper function that constructs a ToolDefinition with type-checked handler against the schema.
    export function defineTool<S extends z.ZodTypeAny>(def: {
      name: string;
      description: string;
      schema: S;
      handler: (ctx: AgentContext, input: z.infer<S>) => Promise<ToolResult>;
    }): ToolDefinition {
      return def as unknown as ToolDefinition;
    }
Behavior4/5

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

With no annotations, the description carries full burden. It reveals a side effect (disconnects from relays) and a constraint (cannot stop active agent), adding value beyond the schema.

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?

Extremely concise at 11 words across two sentences, front-loading the action and constraint without any unnecessary words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple tool with 1 parameter and no output schema, the description covers core behavior and a side effect but omits parameter explanation, which is a notable gap. It is minimally adequate but not fully complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The parameter 'name' has no description in schema, and the tool description does not clarify its meaning (e.g., agent name vs ID), leaving ambiguity about what value to provide.

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 action (stop), the object (loaded agent), and a restriction (cannot stop active agent), effectively distinguishing it from siblings like create_agent or switch_agent.

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

Usage Guidelines4/5

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

The description explicitly states when not to use it (cannot stop the active agent), implying it's for non-active agents. However, it does not provide explicit alternatives or contextual guidance relative to other tools.

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/elisymlabs/elisym'

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