Skip to main content
Glama

checkConnectivity

Test TCP connectivity to a specified host and port to diagnose network connection issues with configurable timeout settings.

Instructions

Test TCP connectivity to a host and port

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hostYesTarget host
portYesTarget port
timeoutNoConnection timeout in milliseconds

Implementation Reference

  • The core handler function implementing the TCP connectivity check using Node.js net module. It creates a socket connection, handles connect, timeout, error, and close events, and resolves with a JSON-formatted result.
    handler: async ({ host, port, timeout = 5000 }: { host: string; port: number; timeout?: number }) => {
      return new Promise<{ content: Array<{ type: string, text: string }> }>((resolve) => {
        const result: NetworkConnectivityResult = {
          connected: false
        };
    
        const socket = createConnection(port, host);
        socket.setTimeout(timeout);
    
        socket.on('connect', () => {
          result.connected = true;
          socket.end();
        });
    
        socket.on('timeout', () => {
          result.error = 'Connection timed out';
          socket.destroy();
        });
    
        socket.on('error', (err) => {
          result.error = err.message;
        });
    
        socket.on('close', () => {
          resolve({
            content: [{
              type: 'text',
              text: JSON.stringify(result, null, 2)
            }]
          });
        });
      });
    }
  • Input schema defining the parameters for the checkConnectivity tool: host (string, required), port (number, required), timeout (number, optional default 5000).
    inputSchema: {
      type: 'object',
      properties: {
        host: {
          type: 'string',
          description: 'Target host'
        },
        port: {
          type: 'number',
          description: 'Target port'
        },
        timeout: {
          type: 'number',
          description: 'Connection timeout in milliseconds',
          default: 5000
        }
      },
      required: ['host', 'port']
    },
  • The complete tool definition object for 'checkConnectivity', including name, description, inputSchema, and handler, exported as part of networkTools.
    checkConnectivity: {
      name: 'checkConnectivity',
      description: 'Test TCP connectivity to a host and port',
      inputSchema: {
        type: 'object',
        properties: {
          host: {
            type: 'string',
            description: 'Target host'
          },
          port: {
            type: 'number',
            description: 'Target port'
          },
          timeout: {
            type: 'number',
            description: 'Connection timeout in milliseconds',
            default: 5000
          }
        },
        required: ['host', 'port']
      },
      handler: async ({ host, port, timeout = 5000 }: { host: string; port: number; timeout?: number }) => {
        return new Promise<{ content: Array<{ type: string, text: string }> }>((resolve) => {
          const result: NetworkConnectivityResult = {
            connected: false
          };
    
          const socket = createConnection(port, host);
          socket.setTimeout(timeout);
    
          socket.on('connect', () => {
            result.connected = true;
            socket.end();
          });
    
          socket.on('timeout', () => {
            result.error = 'Connection timed out';
            socket.destroy();
          });
    
          socket.on('error', (err) => {
            result.error = err.message;
          });
    
          socket.on('close', () => {
            resolve({
              content: [{
                type: 'text',
                text: JSON.stringify(result, null, 2)
              }]
            });
          });
        });
      }
    },
  • TypeScript interface defining the structure of the connectivity check result: connected (boolean) and optional error (string). Used in the handler.
    export interface NetworkConnectivityResult {
      connected: boolean;
      error?: string;
    }
  • src/index.ts:28-35 (registration)
    Registration of all tools including networkTools (which contains checkConnectivity) into the allTools object used by MCP server handlers for listing and calling tools.
    const allTools: ToolKit = {
      ...systemTools,
      ...networkTools,
      ...geoTools,
      ...generatorTools,
      ...dateTimeTools,
      ...securityTools
    };
Behavior2/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 states the tool tests TCP connectivity but doesn't describe what 'test' entails (e.g., success/failure criteria, error handling, or output format). It mentions a timeout parameter but doesn't explain default behavior or implications, leaving gaps in understanding the tool's operation.

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 with zero waste. It is appropriately sized and front-loaded, making it easy to understand quickly.

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

Completeness2/5

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

Given the tool's complexity (network testing with 3 parameters), no annotations, and no output schema, the description is incomplete. It lacks details on behavioral traits (e.g., what results look like, error cases) and doesn't compensate for the absence of structured output information, making it inadequate for full agent understanding.

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 description coverage is 100%, so the schema already documents all parameters (host, port, timeout) with descriptions. The description adds no additional meaning beyond implying TCP connectivity testing, which is covered by the tool's purpose. Baseline 3 is appropriate as the schema handles parameter documentation adequately.

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 'Test TCP connectivity to a host and port,' which is a specific verb (test) with resources (TCP connectivity, host, port). It distinguishes from siblings like pingHost (which likely uses ICMP) and traceroute (which traces route), though it doesn't explicitly mention these distinctions.

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 like pingHost or traceroute, nor does it mention any prerequisites or exclusions. It lacks context for tool selection among networking siblings.

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/cyanheads/toolkit-mcp-server'

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