Skip to main content
Glama

run_test

Execute test commands in development directories to verify code functionality and identify issues. Supports npm, yarn, and pnpm package managers for comprehensive testing workflows.

Instructions

Run tests in the current directory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandNoTest command to run (e.g., "npm test", "yarn test")npm test
directoryNoDirectory to run tests in (default: current directory)

Implementation Reference

  • The main handler function for the 'run_test' tool. It executes the test command (default 'npm test') in the specified directory using execSync, captures output, and returns success or throws error with details.
    private async runTest(args: any) {
      const command = args?.command || 'npm test';
      const directory = args?.directory || process.cwd();
      
      try {
        const output = execSync(command, { 
          cwd: directory, 
          encoding: 'utf8',
          timeout: 300000 // 5 minutes
        });
        
        return {
          content: [
            {
              type: 'text',
              text: `Tests passed!\nCommand: ${command}\nDirectory: ${directory}\nOutput:\n${output}`
            }
          ]
        };
      } catch (error: any) {
        throw new Error(`Tests failed: ${error.message}\nStderr: ${error.stderr || 'N/A'}`);
      }
    }
  • The tool schema definition including name, description, and input schema for parameters 'command' and 'directory'.
    {
      name: 'run_test',
      description: 'Run tests in the current directory',
      inputSchema: {
        type: 'object',
        properties: {
          command: {
            type: 'string',
            description: 'Test command to run (e.g., "npm test", "yarn test")',
            default: 'npm test'
          },
          directory: {
            type: 'string',
            description: 'Directory to run tests in (default: current directory)'
          }
        }
      }
    },
  • src/index.ts:141-142 (registration)
    The dispatch case in the CallToolRequestHandler that routes calls to the 'run_test' tool to the runTest handler method.
    case 'run_test':
      return await this.runTest(args);
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 action ('Run tests') but doesn't explain what happens during execution (e.g., output format, error handling, side effects like file changes, or performance implications). For a tool that executes commands, this lack of detail is a significant gap.

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 function without unnecessary words. It's front-loaded and appropriately sized for its purpose, making it easy to parse 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 complexity of running tests (which can involve execution, output, and potential side effects), the description is incomplete. With no annotations and no output schema, it fails to explain what the tool returns (e.g., test results, exit codes) or behavioral traits. This leaves critical gaps for an agent to understand the tool's full context.

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, fully documenting both parameters ('command' and 'directory') with examples and defaults. The description doesn't add any meaning beyond this, as it only mentions 'current directory' which is covered by the schema. With high schema coverage, the baseline score of 3 is appropriate.

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

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Run tests in the current directory' clearly states the verb ('Run') and resource ('tests'), but it's vague about what type of tests or framework is involved. It doesn't distinguish from sibling tools like 'check_package_json' or 'run_build', which might also involve testing-related activities. The purpose is understandable but lacks specificity.

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 (e.g., needing a test setup), exclusions, or how it differs from siblings like 'lint_code' or 'run_build'. Without such context, an agent might misuse it or overlook better options.

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/TeodorTrotea/mcptest'

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