Skip to main content
Glama
mikeysrecipes

interactive-mcp

stop_intensive_chat

Closes an active intensive chat session to free system resources and complete the conversation flow after gathering information.

Instructions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesID of the intensive chat session to stop

Implementation Reference

  • Core handler function that stops the intensive chat session: writes close signal, kills process, marks inactive, schedules cleanup.
    export async function stopIntensiveChatSession(
      sessionId: string,
    ): Promise<boolean> {
      const session = activeSessions[sessionId];
    
      if (!session || !session.isActive) {
        return false; // Session doesn't exist or is already inactive
      }
    
      // Write close signal file
      const closeFilePath = path.join(session.outputDir, 'close-session.txt');
      await fs.writeFile(closeFilePath, '', 'utf8');
    
      // Give the process some time to exit gracefully
      await new Promise((resolve) => setTimeout(resolve, 500));
    
      try {
        // Force kill the process if it's still running
        if (!session.process.killed) {
          // Kill process group on Unix-like systems, standard kill on Windows
          try {
            if (os.platform() !== 'win32') {
              process.kill(-session.process.pid!, 'SIGTERM');
            } else {
              process.kill(session.process.pid!, 'SIGTERM');
            }
          } catch {
            // console.error("Error killing process:", killError);
            // Fallback or ignore if process already exited or group kill failed
          }
        }
      } catch {
        // Process might have already exited
      }
    
      // Mark session as inactive
      session.isActive = false;
    
      // Clean up session directory after a delay
      setTimeout(() => {
        // Use void to mark intentionally unhandled promise
        void (async () => {
          try {
            await fs.rm(session.outputDir, { recursive: true, force: true });
          } catch {
            // Ignore errors during cleanup
          }
    
          // Remove from active sessions
          delete activeSessions[sessionId];
        })();
      }, 2000);
    
      return true;
    }
  • src/index.ts:298-341 (registration)
    MCP server tool registration for 'stop_intensive_chat', including schema, description, and thin wrapper handler calling stopIntensiveChatSession.
    if (isToolEnabled('stop_intensive_chat')) {
      // Use properties from the imported intensiveChatTools object
      server.tool(
        'stop_intensive_chat',
        // Description is a string here
        typeof intensiveChatTools.stop.description === 'function'
          ? intensiveChatTools.stop.description(globalTimeoutSeconds) // Should not happen, but safe
          : intensiveChatTools.stop.description,
        intensiveChatTools.stop.schema, // Use schema property
        async (args) => {
          // Use inferred args type
          const { sessionId } = args;
          // Check if session exists
          if (!activeChatSessions.has(sessionId)) {
            return {
              content: [
                { type: 'text', text: 'Error: Invalid or expired session ID.' },
              ],
            };
          }
    
          try {
            // Stop the session
            const success = await stopIntensiveChatSession(sessionId);
            // Remove session from map if successful
            if (success) {
              activeChatSessions.delete(sessionId);
            }
            const message = success
              ? 'Session stopped successfully.'
              : 'Session not found or already stopped.';
            return { content: [{ type: 'text', text: message }] };
          } catch (error: unknown) {
            let errorMessage = 'Failed to stop intensive chat session.';
            if (error instanceof Error) {
              errorMessage = `Failed to stop intensive chat session: ${error.message}`;
            } else if (typeof error === 'string') {
              errorMessage = `Failed to stop intensive chat session: ${error}`;
            }
            return { content: [{ type: 'text', text: errorMessage }] };
          }
        },
      );
    }
  • Tool schema (Zod), capability, and detailed description for 'stop_intensive_chat' used in registration.
    const stopCapability: ToolCapabilityInfo = {
      description: 'Stop and close an active intensive chat session.',
      parameters: {
        type: 'object',
        properties: {
          sessionId: {
            type: 'string',
            description: 'ID of the intensive chat session to stop',
          },
        },
        required: ['sessionId'],
      },
    };
    
    const stopDescription: ToolRegistrationDescription = `<description>
      Stop and close an active intensive chat session. **Must be called** after all questions have been asked using 'ask_intensive_chat'.
    </description>
    
    <importantNotes>
    - (!important!) Closes the console window for the intensive chat.
    - (!important!) Frees up system resources.
    - (!important!) **Should always be called** as the final step when finished with an intensive chat session, typically at the end of the response message where 'start_intensive_chat' was called.
    </importantNotes>
    
    <whenToUseThisTool>
    - When you've completed gathering all needed information via 'ask_intensive_chat'.
    - When the multi-step process requiring intensive chat is complete.
    - When you're ready to move on to processing the collected information.
    - When the user indicates they want to end the session (if applicable).
    - As the final action related to the intensive chat flow within a single response message.
    </whenToUseThisTool>
    
    <features>
    - Gracefully closes the console window
    - Cleans up system resources
    - Marks the session as complete
    </features>
    
    <bestPractices>
    - Always stop sessions when you're done to free resources
    - Provide a summary of the information collected before stopping
    </bestPractices>
    
    <parameters>
    - sessionId: ID of the intensive chat session to stop
    </parameters>
    
    <examples>
    - { "sessionId": "abcd1234" }
    </examples>`;
    
    const stopSchema: ZodRawShape = {
      sessionId: z.string().describe('ID of the intensive chat session to stop'),
    };
    
    const stopToolDefinition: ToolDefinition = {
      capability: stopCapability,
      description: stopDescription,
      schema: stopSchema,
    };
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes what the tool does beyond the basic 'stop' action: closes the console window, frees system resources, marks the session as complete, and gracefully handles cleanup. However, it doesn't mention potential side effects like whether data is preserved or if the session can be restarted.

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

Conciseness3/5

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

While the information is well-structured with clear sections, the description is verbose with redundant information across sections. The core purpose could be communicated more efficiently without repeating the same guidance in <description>, <importantNotes>, <whenToUseThisTool>, and <bestPractices> sections.

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

Completeness4/5

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

For a single-parameter tool with no annotations and no output schema, the description provides comprehensive context about the tool's role in the workflow, behavioral effects, and usage patterns. It covers the essential information an agent needs to use this tool correctly within the intensive chat flow, though it could benefit from more detail about error conditions or return values.

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 schema description coverage is 100% (the single parameter 'sessionId' is fully documented in the schema), so the baseline is 3. The description adds minimal value beyond the schema by repeating the parameter information in the <parameters> section, but doesn't provide additional context about sessionId format, validation, or sourcing.

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's purpose with a specific verb ('stop and close') and resource ('active intensive chat session'). It explicitly distinguishes this tool from its sibling 'ask_intensive_chat' by stating it must be called after using that tool, and differentiates from 'start_intensive_chat' by being the final step in the flow.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool versus alternatives through the <whenToUseThisTool> section, which lists five specific scenarios. It also clearly states this should be the final step after 'ask_intensive_chat' and typically at the end of the response message where 'start_intensive_chat' was called, creating clear sequencing rules.

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/mikeysrecipes/interactive-mcp'

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