Skip to main content
Glama

run_tests

Execute Unity's Test Runner tests with specified filters and modes (EditMode, PlayMode, or All), enabling efficient testing within the Unity Editor MCP Server environment.

Instructions

Runs Unity's Test Runner tests

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
testFilterNoOptional test filter (e.g. specific test name or namespace)
testModeNoThe test mode to run (EditMode, PlayMode, or All)

Implementation Reference

  • Core execution logic for the 'run_tests' tool: parses parameters, sends request to McpUnity to run Unity Test Runner tests, handles response, extracts statistics and results, returns formatted text content with summary and JSON details.
    async function toolHandler(mcpUnity: McpUnity, params: any = {}): Promise<CallToolResult> {
      const {
        testMode = 'EditMode',
        testFilter = '',
        returnOnlyFailures = true,
        returnWithLogs = false
      } = params;
    
      // Create and wait for the test run
      const response = await mcpUnity.sendRequest({
        method: toolName,
        params: { 
          testMode,
          testFilter,
          returnOnlyFailures,
          returnWithLogs
        }
      });
      
      // Process the test results
      if (!response.success) {
        throw new McpUnityError(
          ErrorType.TOOL_EXECUTION,
          response.message || `Failed to run tests: Mode=${testMode}, Filter=${testFilter || 'none'}`
        );
      }
      
      // Extract test results
      const testResults = response.results || [];
      const testCount = response.testCount || 0;
      const passCount = response.passCount || 0;
      const failCount = response.failCount || 0;
      const skipCount = response.skipCount || 0;
      
      return {
        content: [
          {
            type: 'text',
            text: response.message
          },
          {
            type: 'text',
            text: JSON.stringify({
              testCount,
              passCount,
              failCount,
              skipCount,
              results: testResults
            }, null, 2)
          }
        ]
      };
    }
  • Zod schema defining the input parameters for the 'run_tests' tool.
    const paramsSchema = z.object({
      testMode: z.string().optional().default('EditMode').describe('The test mode to run (EditMode or PlayMode) - defaults to EditMode (optional)'),
      testFilter: z.string().optional().default('').describe('The specific test filter to run (e.g. specific test name or class name, must include namespace) (optional)'),
      returnOnlyFailures: z.boolean().optional().default(true).describe('Whether to show only failed tests in the results (optional)'),
      returnWithLogs: z.boolean().optional().default(false).describe('Whether to return the test logs in the results (optional)')
    });
  • Registration function for the 'run_tests' tool, which calls server.tool with name, description, schema, and a logging wrapper around the toolHandler.
    export function registerRunTestsTool(server: McpServer, mcpUnity: McpUnity, logger: Logger) {
      logger.info(`Registering tool: ${toolName}`);
      
      // Register this tool with the MCP server
      server.tool(
        toolName,
        toolDescription,
        paramsSchema.shape,
        async (params: any = {}) => {
          try {
            logger.info(`Executing tool: ${toolName}`, params);
            const result = await toolHandler(mcpUnity, params);
            logger.info(`Tool execution successful: ${toolName}`);
            return result;
          } catch (error) {
            logger.error(`Tool execution failed: ${toolName}`, error);
            throw error;
          }
        }
      );
    }
  • Application-level call to register the 'run_tests' tool during server initialization.
    registerRunTestsTool(server, mcpUnity, toolLogger);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but lacks behavioral details. It doesn't disclose whether this is a read-only or destructive operation, execution time, error handling, or output format (e.g., test results). The phrase 'Runs' implies execution but gives no further context on safety or side effects.

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 with no wasted words, making it easy to parse. It's front-loaded with the core action and resource, earning full marks for conciseness and structure.

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 involves execution and potential side effects), no annotations, and no output schema, the description is incomplete. It doesn't explain what happens during execution, what results to expect, or any constraints, leaving significant gaps for an agent to use the tool effectively.

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, documenting both parameters clearly. The description adds no additional meaning beyond what the schema provides, such as examples of test filters or implications of test modes. 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.

Purpose4/5

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

The description clearly states the action ('Runs') and the resource ('Unity's Test Runner tests'), making the purpose immediately understandable. However, it doesn't differentiate this tool from sibling tools like 'execute_menu_item' or 'package_manager', which could also involve Unity operations, so it doesn't reach the highest score.

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. There's no mention of prerequisites, context (e.g., when in Unity's workflow), or comparisons to siblings like 'execute_menu_item' for other Unity actions, leaving the agent to infer usage.

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

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/CoderGamester/mcp-unity'

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