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);

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