Skip to main content
Glama

test_code

Automatically generates test cases for provided code, supporting custom test frameworks to ensure robust functionality and quality assurance.

Instructions

Generates tests for the given code.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesCode to test
test_frameworkNoTest framework to use

Implementation Reference

  • Handler implementation for the 'test_code' tool. It destructures the input arguments, encodes the code to base64, constructs a prompt for generating tests using Claude CLI, executes it, and returns the generated test code as text content.
    case 'test_code': { const { code, test_framework } = args; logger.debug(`Processing test_code request, code length: ${code.length}`); const encodedCode = encodeText(truncateIfNeeded(code)); logger.debug(`Code encoded to base64, length: ${encodedCode.length}`); const framework = test_framework || 'default'; const prompt = `You are super professional engineer. Please generate tests for the following Base64 encoded code.\n\nCode:\n${encodedCode}\n\nTest framework (if specified):\n${framework || 'No specific framework provided. Please use a suitable default framework.'}`; logger.debug('Calling Claude CLI with prompt'); const output = await runClaudeCommand(['--print'], prompt); logger.debug(`Received response from Claude, length: ${output.length}`); return { content: [{ type: 'text', text: output }] }; }
  • Registration of the 'test_code' tool in the ListTools response, including its name, description, and input schema definition.
    { name: 'test_code', description: 'Generates tests for the given code.', inputSchema: { type: 'object', properties: { code: { type: 'string', description: 'Code to test' }, test_framework: { type: 'string', description: 'Test framework to use', default: '' } }, required: ['code'] } },
  • Input schema definition for the 'test_code' tool, specifying the expected parameters: code (required string) and optional test_framework.
    inputSchema: { type: 'object', properties: { code: { type: 'string', description: 'Code to test' }, test_framework: { type: 'string', description: 'Test framework to use', default: '' } }, required: ['code'] } },

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/KunihiroS/claude-code-mcp'

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