Skip to main content
Glama

ping

Check server connectivity to verify QGIS MCP server availability and network status for GIS operations.

Instructions

Simple ping command to check server connectivity

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool 'ping' handler: Forwards the ping request to the QGIS socket server via the client and returns the formatted JSON response.
    @mcp.tool()
    def ping(ctx: Context) -> str:
        """Simple ping command to check server connectivity"""
        qgis = get_qgis_connection()
        result = qgis.send_command("ping")
        return json.dumps(result, indent=2)
  • Low-level ping handler in the QGIS plugin server that responds with a simple pong message.
    def ping(self, **kwargs):
        """Simple ping command"""
        return {"pong": True}
  • Registration of the 'ping' handler (and other commands) in the QGIS plugin's command dispatcher dictionary.
    handlers = {
        "ping": self.ping,
        "get_qgis_info": self.get_qgis_info,
        "load_project": self.load_project,
        "get_project_info": self.get_project_info,
        "execute_code": self.execute_code,
        "add_vector_layer": self.add_vector_layer,
        "add_raster_layer": self.add_raster_layer,
        "get_layers": self.get_layers,
        "remove_layer": self.remove_layer,
        "zoom_to_layer": self.zoom_to_layer,
        "get_layer_features": self.get_layer_features,
        "execute_processing": self.execute_processing,
        "save_project": self.save_project,
        "render_map": self.render_map,
        "create_new_project": self.create_new_project,
    }
  • Helper function to manage persistent connection to QGIS server, used by ping tool; includes connection health check.
    def get_qgis_connection():
        """Get or create a persistent Qgis connection"""
        global _qgis_connection
        
        # If we have an existing connection, check if it's still valid
        if _qgis_connection is not None:
            # Test if the connection is still alive with a simple ping
            try:
                # Just try to send a small message to check if the socket is still connected
                _qgis_connection.sock.sendall(b'')
                return _qgis_connection
            except Exception as e:
                # Connection is dead, close it and create a new one
                logger.warning(f"Existing connection is no longer valid: {str(e)}")
                try:
                    _qgis_connection.disconnect()
                except Exception:
                    pass
                _qgis_connection = None
        
        # Create a new connection if needed
        if _qgis_connection is None:
            _qgis_connection = QgisMCPServer(host="localhost", port=9876)
            if not _qgis_connection.connect():
                logger.error("Failed to connect to Qgis")
                _qgis_connection = None
                raise Exception("Could not connect to Qgis. Make sure the Qgis plugin is running.")
            logger.info("Created new persistent connection to Qgis")
        
        return _qgis_connection
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 tool is a 'simple ping command,' implying it's a read-only, non-destructive operation, but doesn't specify what 'ping' entails (e.g., network latency test, response time, success/failure output). For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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?

The description is a single, efficient sentence that directly states the tool's purpose without any wasted words. It's appropriately sized and front-loaded, making it easy for an agent to parse quickly.

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?

Given the tool's low complexity (0 parameters, no output schema, no annotations), the description is minimally adequate. It explains what the tool does but lacks details on behavior, output format, or usage context. With no annotations or output schema, the description should do more to compensate, but it only provides a basic purpose statement.

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?

The tool has 0 parameters, and the schema description coverage is 100% (though trivial since there are no parameters). The description doesn't need to add parameter semantics, so it meets the baseline of 4 for tools with no parameters, as it doesn't have to compensate for any gaps.

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

Purpose4/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 as a connectivity check ('ping command to check server connectivity'), using specific verbs ('check') and identifying the resource ('server connectivity'). However, it doesn't differentiate from sibling tools like 'get_qgis_info' which might also provide connectivity information, so it doesn't reach the highest score.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, context for use, or compare it to sibling tools like 'get_qgis_info' that might serve similar diagnostic purposes. The agent must infer usage from the purpose alone.

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/syauqi-uqi/qgis_mcp_modify1'

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