Skip to main content
Glama

run_test

Execute test commands in a specified directory using the Build MCP Server. Simplifies development workflows by running tests with defined commands, supporting npm, yarn, and pnpm, and providing detailed error reporting.

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 schema definition for the 'run_test' tool, including inputSchema with optional command (default 'npm test') and directory parameters, registered in the ListTools response.
    { 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 registration/dispatch point in the CallToolRequestSchema handler switch statement, which routes calls to the runTest method.
    case 'run_test': return await this.runTest(args);

Other Tools

Related 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