Skip to main content
Glama

health_check

Verify LM Studio server status and response availability to enable function discovery and system diagnostics for Claude Desktop integration.

Instructions

Check if LM Studio is running and responding

WORKFLOW: System diagnostics and function discovery TIP: Start with health_check, use list_functions to explore capabilities SAVES: Claude context for strategic decisions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
detailedNoInclude detailed information about the loaded model and server status

Implementation Reference

  • Core handler function that executes the health_check tool logic: connects to LM Studio, lists loaded models, retrieves context length, and formats response using ResponseFactory.
    async execute(params: any, llmClient: any) {
      return await withSecurity(this, params, llmClient, async (secureParams) => {
        try {
          const client = new LMStudioClient({
            baseUrl: config.lmStudioUrl || 'ws://localhost:1234',
          });
    
          // Try to connect and get basic info
          const models = await client.llm.listLoaded();
          
          // Get context length from the active model if available
          let contextLength: number | undefined = undefined;
          if (models.length > 0) {
            try {
              const activeModel = models[0];
              // Try to get context length using LM Studio SDK
              contextLength = await activeModel.getContextLength();
            } catch (error) {
              // If getContextLength fails, try alternative method or leave undefined
              console.warn('Could not retrieve context length from model:', error);
            }
          }
          
          // Use ResponseFactory for consistent, spec-compliant output
          ResponseFactory.setStartTime();
          return ResponseFactory.createHealthCheckResponse(
            'healthy',
            'established',
            config.lmStudioUrl || 'ws://localhost:1234',
            undefined,
            undefined,
            secureParams.detailed ? {
              loadedModels: models.map(model => ({
                path: model.path,
                identifier: model.identifier,
                architecture: (model as any).architecture || 'unknown',
                contextLength: contextLength // Will be the same for all models since we only check the first one
              })),
              modelCount: models.length,
              hasActiveModel: models.length > 0,
              contextLength: contextLength, // Add context length to response
              serverInfo: {
                url: config.lmStudioUrl,
                protocol: 'websocket'
              },
              activeModel: models.length > 0 ? {
                path: models[0].path,
                identifier: models[0].identifier,
                architecture: (models[0] as any).architecture || 'unknown',
                contextLength: contextLength // Add context length to active model
              } : undefined
            } : undefined, // Don't provide details in non-detailed mode
            contextLength // Pass contextLength as separate parameter
          );
        } catch (error: any) {
          return ResponseFactory.createHealthCheckResponse(
            'unhealthy',
            'failed',
            config.lmStudioUrl || 'ws://localhost:1234',
            error.message || 'Failed to connect to LM Studio',
            'Please ensure LM Studio is running and a model is loaded'
          );
        }
      });
    }
  • Input schema definition for the health_check tool parameters.
    parameters = {
      detailed: {
        type: 'boolean' as const,
        description: 'Include detailed information about the loaded model and server status',
        default: false,
        required: false
      }
    };
  • Output schema interface HealthCheckResponse defining the structure of health_check responses.
    export interface HealthCheckResponse extends BaseResponse {
      data: {
        status: "healthy" | "unhealthy";
        connection: "established" | "failed";
        lmStudioUrl: string;
        timestamp: string;
        error?: string;
        suggestion?: string;
        contextLength?: number;       // Context length of the loaded model
        details?: {
          loadedModels: Array<{
            path: string;
            identifier: string;
            architecture: string;
            contextLength?: number;   // Context length for each model
          }>;
          modelCount: number;
          hasActiveModel: boolean;
          contextLength?: number;     // Context length of active model
          serverInfo: {
            url: string;
            protocol: string;
          };
          activeModel?: {
            path: string;
            identifier: string;
            architecture: string;
            contextLength?: number;   // Context length of active model
          };
        };
      };
    }
  • src/index.ts:156-172 (registration)
    Dynamic registration of system plugins including HealthCheckPlugin via pluginLoader.registerPlugin during server initialization.
    private async loadSystemPlugin(filePath: string): Promise<void> {
      try {
        // Use ES module dynamic import with proper URL
        const fileUrl = pathToFileURL(filePath).href;
        const module = await import(fileUrl);
        const PluginClass = module.default || module.HealthCheckPlugin || module.PathResolverPlugin || Object.values(module)[0];
        
        if (PluginClass && typeof PluginClass === 'function') {
          const plugin = new PluginClass();
          this.pluginLoader.registerPlugin(plugin);
          // Removed console.log to avoid JSON-RPC interference
        }
      } catch (error) {
        // Silent error handling to avoid JSON-RPC interference
        // console.error(`[Plugin Server] Error loading system plugin ${filePath}:`, error);
      }
    }
  • Helper factory method to create standardized HealthCheckResponse objects used by the handler.
    static createHealthCheckResponse(
      status: "healthy" | "unhealthy",
      connection: "established" | "failed",
      lmStudioUrl: string,
      error?: string,
      suggestion?: string,
      details?: HealthCheckResponse['data']['details'],
      contextLength?: number
    ): HealthCheckResponse {
      return {
        success: status === "healthy",
        timestamp: new Date().toISOString(),
        modelUsed: details?.activeModel?.identifier || 'none',
        executionTimeMs: this.getExecutionTime(),
        data: {
          status,
          connection,
          lmStudioUrl,
          timestamp: new Date().toISOString(),
          error,
          suggestion,
          contextLength,
          details
        }
      };
    }
Behavior3/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 checks if LM Studio is 'running and responding' which implies a read-only diagnostic operation. However, it doesn't disclose important behavioral details like what specific response format to expect, whether there are rate limits, or what happens if LM Studio is not running. The 'SAVES' section mentions it 'saves Claude context for strategic decisions' which adds some useful behavioral context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is structured with clear sections (main purpose, WORKFLOW, TIP, SAVES) but contains some redundancy. The 'TIP' section essentially repeats the workflow guidance. The 'SAVES' section adds value but could be more integrated. While appropriately sized, not every sentence earns its place equally.

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

Completeness4/5

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

Given this is a simple diagnostic tool with one optional parameter (100% schema coverage) and no output schema, the description provides adequate context. It explains the purpose, provides clear workflow guidance, and adds behavioral context about saving Claude context. For a tool of this complexity, the description is reasonably complete, though it could benefit from more detail about the expected response format.

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?

The input schema has 100% description coverage, with the single parameter 'detailed' well-documented in the schema itself. The description doesn't add any additional parameter information beyond what's already in the schema. According to the scoring rules, when schema_description_coverage is high (>80%), the baseline is 3 even with no param info in the description.

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: 'Check if LM Studio is running and responding.' This is a specific verb ('Check') and resource ('LM Studio') combination. However, it doesn't explicitly distinguish this from sibling tools like 'list_functions' or 'get_cache_statistics' that might also provide system status information.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit usage guidance: 'Start with health_check, use list_functions to explore capabilities.' This clearly indicates when to use this tool (first in workflow) and mentions an alternative tool ('list_functions') for different purposes. The 'WORKFLOW' section reinforces this strategic positioning.

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/houtini-ai/lm'

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