Skip to main content
Glama
UserB1ank

interactive-process-mcp

by UserB1ank

terminate_process

Terminate an interactive process by session ID with optional force kill (SIGKILL) and configurable grace period before escalation.

Instructions

Terminate an interactive process.

Args: session_id: The session ID to terminate. force: Use SIGKILL instead of SIGTERM. Default False. grace_period: Seconds to wait after SIGTERM before SIGKILL. Default 5.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
session_idYes
forceNo
grace_periodNo

Implementation Reference

  • Top-level MCP tool handler for terminate_process, registered via @mcp.tool() decorator. Fetches the session and delegates to session.terminate().
    @mcp.tool()
    def terminate_process(
        session_id: str,
        force: bool = False,
        grace_period: float = 5.0,
    ) -> dict:
        """Terminate an interactive process.
    
        Args:
            session_id: The session ID to terminate.
            force: Use SIGKILL instead of SIGTERM. Default False.
            grace_period: Seconds to wait after SIGTERM before SIGKILL. Default 5.
        """
        session = _mgr.get(session_id)
        if not session:
            return {"error": f"Session '{session_id}' not found"}
        session.terminate(force=force, grace_period=grace_period)
        return {"success": True}
  • Alternate handler in the tools-based registration. Delegates to SessionManager.terminate().
    def terminate_process(args: dict) -> dict:
        mgr.terminate(
            args["session_id"],
            force=args.get("force", False),
            grace_period=args.get("grace_period", 5.0),
        )
        return {"success": True}
  • Registration of terminate_process in the tools tuple list returned by create_tools().
    ("terminate_process", terminate_process),
    ("resize_pty", resize_pty),
    ("get_session_info", get_session_info),
  • SessionManager.terminate() — thread-safe lookup and delegation to Session.terminate().
    def terminate(self, session_id: str, force: bool = False, grace_period: float = 5.0) -> None:
        with self._lock:
            session = self._sessions.get(session_id)
        if session:
            session.terminate(force=force, grace_period=grace_period)
  • Session.terminate() — core termination logic: handles PTY mode (pexpect spawn) and pipe mode (subprocess.Popen), with force/grace_period semantics.
    def terminate(self, force: bool = False, grace_period: float = 5.0) -> None:
        if self.status != SessionStatus.RUNNING:
            return
        if self.mode == "pty":
            if force:
                self._process.terminate(force=True)
            else:
                self._process.terminate(force=False)
                import time
                time.sleep(grace_period)
                if self._process.isalive():
                    self._process.terminate(force=True)
        else:
            if force:
                self._process.kill()
            else:
                self._process.send_signal(signal.SIGTERM)
                try:
                    self._process.wait(timeout=grace_period)
                except subprocess.TimeoutExpired:
                    self._process.kill()
        if self._reader_thread:
            self._reader_thread.join(timeout=2.0)
        self.status = SessionStatus.EXITED
Behavior3/5

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

Discloses signal types (SIGTERM/SIGKILL) and grace period behavior, but omits side effects like session state or error conditions. No annotations to supplement.

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?

Concise: one-line summary then parameter descriptions. No fluff, but could be slightly more structured.

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?

Covers parameter roles and basic behavior, but lacks return value, error conditions, and post-termination effects. Output schema absent.

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

Parameters4/5

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

Description adds meaning beyond schema: force means SIGKILL, grace_period is wait time. Schema only provides defaults and types.

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?

Clear verb+resource: 'Terminate an interactive process.' Distinguishes from siblings like start_process and list_sessions.

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 explicit guidance on when to use or alternatives. Does not differentiate between graceful termination vs forced kill contexts.

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

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