Skip to main content
Glama

shutdown_llm_server

Terminates a local LLM server process running on a given port, ensuring safe shutdown.

Instructions

指定されたポートで稼働しているローカル LLM サーバープロセスを安全に終了させます。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
portYes終了させるサーバーのポート番号

Implementation Reference

  • Handler for the shutdown_llm_server tool. Validates port argument is an integer, then delegates to process_manager.shutdown_server via asyncio.to_thread.
    elif name == "shutdown_llm_server":
        port = arguments.get("port")
        if not isinstance(port, int):
            raise ValueError("Port must be an integer")
            
        result_msg = await asyncio.to_thread(process_manager.shutdown_server, port)
        return [types.TextContent(type="text", text=result_msg)]
  • Schema definition for shutdown_llm_server tool. Defines 'port' as required integer parameter.
    types.Tool(
        name="shutdown_llm_server",
        description="指定されたポートで稼働しているローカル LLM サーバープロセスを安全に終了させます。",
        inputSchema={
            "type": "object",
            "properties": {
                "port": {"type": "integer", "description": "終了させるサーバーのポート番号"}
            },
            "required": ["port"],
        },
    ),
  • Tool registration via @server.list_tools() decorator. shutdown_llm_server is one of 8 tools listed in the handle_list_tools function.
    return [
        types.Tool(
            name="check_system_environment",
            description="現在のシステム環境(Apple Siliconか、空きメモリが何GBあるかなど)を診断します。",
            inputSchema={
                "type": "object",
                "properties": {},
            },
        ),
        types.Tool(
            name="check_llm_status",
            description="指定されたポートでサーバーがリッスンしているか(稼働中か)を確認します。",
            inputSchema={
                "type": "object",
                "properties": {
                    "port": {"type": "integer", "description": "確認するポート番号"}
                },
                "required": ["port"],
            },
        ),
        types.Tool(
            name="list_running_servers",
            description="現在バックグラウンドで稼働しているすべてのローカルLLMサーバー(ポート番号とモデル名)の一覧を取得します。",
            inputSchema={
                "type": "object",
                "properties": {},
            },
        ),
        types.Tool(
            name="search_mlx_models",
            description="Hugging Faceからダウンロード可能なMLXフォーマットのLLMモデルを検索・リストアップします。",
            inputSchema={
                "type": "object",
                "properties": {
                    "search_query": {
                        "type": "string",
                        "description": "検索キーワード(例: 'llama', 'qwen')。未指定の場合は人気のMLXモデルを返します。"
                    },
                    "limit": {
                        "type": "integer",
                        "description": "取得する最大件数。デフォルトは10。"
                    }
                },
            },
        ),
        types.Tool(
            name="download_model",
            description="Hugging Faceから指定されたMLXモデルを事前にダウンロードし、ローカルにキャッシュします。大きなモデルの起動前の準備に利用します。",
            inputSchema={
                "type": "object",
                "properties": {
                    "model_name": {
                        "type": "string",
                        "description": "ダウンロードするモデル名 (例: mlx-community/Llama-3-8B-Instruct-4bit)"
                    }
                },
                "required": ["model_name"],
            },
        ),
        types.Tool(
            name="launch_llm_server",
            description="mlx_lm.server をサブプロセスとしてバックグラウンドで起動します。空きメモリが少ない場合は起動が拒否されます。",
            inputSchema={
                "type": "object",
                "properties": {
                    "model_name": {
                        "type": "string",
                        "description": "起動するモデル名 (例: mlx-community/Llama-3-8B-Instruct-4bit)",
                    },
                    "port": {"type": "integer", "description": "サーバーを起動するポート番号"},
                    "memory_requirement_gb": {
                        "type": "number",
                        "description": "起動に必要な空きメモリの目安(GB)。未指定時はデフォルトで 4.0GB。"
                    }
                },
                "required": ["model_name", "port"],
            },
        ),
        types.Tool(
            name="restart_llm_server",
            description="指定されたポートで稼働しているサーバーを一度停止し、再起動します。モデルの切り替えなどにも使用できます。",
            inputSchema={
                "type": "object",
                "properties": {
                    "port": {"type": "integer", "description": "再起動するサーバーのポート番号"},
                    "model_name": {
                        "type": "string",
                        "description": "(オプション)新しく起動するモデル名。省略した場合は現在そのポートで稼働しているモデルをそのまま再起動します。"
                    },
                    "memory_requirement_gb": {
                        "type": "number",
                        "description": "(オプション)起動に必要な空きメモリの目安(GB)。未指定時はデフォルトで 4.0GB。"
                    }
                },
                "required": ["port"],
            },
        ),
        types.Tool(
            name="shutdown_llm_server",
            description="指定されたポートで稼働しているローカル LLM サーバープロセスを安全に終了させます。",
            inputSchema={
                "type": "object",
                "properties": {
                    "port": {"type": "integer", "description": "終了させるサーバーのポート番号"}
                },
                "required": ["port"],
            },
        ),
    ]
  • MlxProcessManager.shutdown_server - the core helper that terminates the server process by PID, with graceful termination and fallback to kill on timeout.
    def shutdown_server(self, port: int) -> str:
        """指定されたポートで稼働しているサーバープロセスを終了させる"""
        state = self._load_state()
        port_str = str(port)
    
        if port_str not in state:
            return f"Error: No running server found on port {port}."
    
        pid = state[port_str]["pid"]
    
        try:
            proc = psutil.Process(pid)
            proc.terminate()
            proc.wait(timeout=5)
        except psutil.NoSuchProcess:
            pass
        except psutil.TimeoutExpired:
            proc.kill()
        except Exception as e:
            return f"Error during shutdown: {str(e)}"
    
        state = self._load_state()
        if port_str in state:
            del state[port_str]
            self._save_state(state)
    
        return f"Successfully shut down server on port {port} (PID: {pid})."
Behavior3/5

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

The description mentions 'safe termination' but lacks detail on side effects (e.g., data loss), required permissions, or confirmation feedback. No annotations are provided, so the description partially covers behavioral transparency.

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?

Single sentence, front-loaded with action and target. No superfluous words, highly efficient.

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 one-parameter tool, the description is mostly adequate but omits what happens after termination (e.g., response, confirmation) and any prerequisites. With no output schema, more detail would improve completeness.

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% and the parameter description already explains the port number. The tool description adds no additional semantic value beyond what the schema provides.

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 (terminate), the target (local LLM server process), and the condition (running on specified port). It distinguishes well from sibling tools like launch_llm_server (start) and restart_llm_server (stop+start).

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?

Usage is implied by the tool name and description, but no explicit when-to-use or when-not-to-use guidance is provided. Sibling tools exist for related actions (e.g., restart), but no alternatives are mentioned.

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/globalpocket/mcp-mlx-launcher'

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