Skip to main content
Glama
skippr-hq

Skippr Extension MCP Server

by skippr-hq

Restart Extension Server

skippr_restart_extension_server

Restart the WebSocket server that communicates with browser extensions to resolve connectivity issues or apply configuration changes.

Instructions

Restarts the WebSocket server that communicates with browser extensions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
portNoOptional port number for the extension server (defaults to WS_PORT env var or 4040)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
successYes
messageYes
portYes

Implementation Reference

  • Core handler function that restarts the WebSocket server. Closes the existing server (if any), creates a new one with the specified port (defaults to WS_PORT env var or 4040), and waits for it to start listening. Returns success/failure with port and message.
    export async function restartWebSocketServer(port?: number): Promise<{ success: boolean; message: string; port: number }> {
      const targetPort = port || parseInt(process.env.WS_PORT || '4040', 10);
    
      try {
        if (wss) {
          await new Promise<void>((resolve) => {
            wss!.close(() => {
              wss = null;
              resolve();
            });
          });
        }
    
        const server = createWebSocketServer(targetPort);
    
        await new Promise<void>((resolve, reject) => {
          const timeout = setTimeout(() => {
            reject(new Error('WebSocket server startup timeout'));
          }, 5000);
    
          server.once('listening', () => {
            clearTimeout(timeout);
            resolve();
          });
    
          server.once('error', (error) => {
            clearTimeout(timeout);
            reject(error);
          });
        });
    
        return {
          success: true,
          message: `WebSocket server restarted successfully on port ${targetPort}`,
          port: targetPort
        };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : 'Unknown error';
        console.error(`[restartWebSocketServer] Failed to restart WebSocket server: ${errorMessage}`, error);
    
        if ((error as any)?.code === 'EADDRINUSE') {
          return {
            success: false,
            message: `Port ${targetPort} is already in use by another process`,
            port: targetPort
          };
        }
    
        return {
          success: false,
          message: `Failed to restart WebSocket server: ${errorMessage}`,
          port: targetPort
        };
      }
    }
  • Input/output schema for skippr_restart_extension_server. Input: optional port number. Output: success boolean, message string, port number.
    inputSchema: z.object({
      port: z.number().optional().describe('Optional port number for the extension server (defaults to WS_PORT env var or 4040)')
    }).shape,
    outputSchema: z.object({
      success: z.boolean(),
      message: z.string(),
      port: z.number()
    }).shape
  • Registration of the tool as an MCP tool named 'skippr_restart_extension_server' with title 'Restart Extension Server'. The handler calls restartWebSocketServer(args.port).
    mcpServer.registerTool(
      'skippr_restart_extension_server',
      {
        title: 'Restart Extension Server',
        description: 'Restarts the WebSocket server that communicates with browser extensions',
        inputSchema: z.object({
          port: z.number().optional().describe('Optional port number for the extension server (defaults to WS_PORT env var or 4040)')
        }).shape,
        outputSchema: z.object({
          success: z.boolean(),
          message: z.string(),
          port: z.number()
        }).shape
      },
      async (args) => {
        const result = await restartWebSocketServer(args.port);
        return createStructuredResponse(result);
      }
    );
  • Helper function createWebSocketServer() that creates a new WebSocketServer instance on the given port if one doesn't already exist. Used by restartWebSocketServer.
    export function createWebSocketServer(port: number): WebSocketServer {
      if (wss) {
        return wss;
      }
    
      wss = new WebSocketServer({ port });
    
      wss.on('connection', (ws: WebSocket) => {
        let clientId: string | null = null;
    
        // Server-side heartbeat: Send ping to client every 30 seconds
        const heartbeatInterval = setInterval(() => {
          if (clientId) {
            const client = clients.get(clientId);
            if (client) {
              // Check if client responded to previous ping
              if (client.isAlive === false) {
                console.error(`[WebSocket] Client ${clientId} failed heartbeat check. Terminating connection.`);
                clearInterval(heartbeatInterval);
                ws.terminate();
                return;
              }
    
              // Mark as not alive, will be set back to true when pong is received
              client.isAlive = false;
    
              // Send ping message
              try {
                ws.send(JSON.stringify({ type: 'ping', timestamp: Date.now() }));
              } catch (error) {
                console.error(`[WebSocket] Failed to send heartbeat ping to client ${clientId}:`, error);
Behavior2/5

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

No annotations provided. The description lacks details on side effects (e.g., disconnecting connected extensions, required permissions, or server downtime).

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, no redundancy, front-loaded action and resource.

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 simplicity and the presence of an output schema, the description covers the basic purpose. However, it omits important behavioral context (e.g., effects on ongoing connections) for a restart operation.

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% with a clear parameter description. The tool description adds minimal context (default value logic) beyond the schema. Baseline 3 is appropriate.

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 restarts the WebSocket server for browser extensions, using a specific verb and resource. It distinguishes itself from sibling tools that operate on extensions or check status.

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 guidance on when to use this tool versus alternatives. It does not mention prerequisites, scenarios, or when restart is appropriate.

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/skippr-hq/extension-mcp-server'

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