Skip to main content
Glama
ShenghaiWang

Android Project MCP Server

by ShenghaiWang

instrumentedTest

Run instrumented tests for Android projects to verify app behavior on devices or emulators. Specify the project folder path to execute tests that interact with the Android framework.

Instructions

Run instrumented test for the Android project in the folder

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
folderYesThe full path of the current folder that the Android project sits

Implementation Reference

  • The shared handler function for all tools, including 'instrumentedTest', which parses arguments, sets the command to run 'instrumentedTest.sh', executes it via subprocess, and processes output to extract errors or success message.
    @server.call_tool()
    async def call_tool(name, arguments: dict) -> list[TextContent]:
        try:
            args = Folder(**arguments)
        except ValueError as e:
            raise McpError(ErrorData(code=INVALID_PARAMS, message=str(e)))
        # os.chdir(args.folder)
        script_dir = os.path.dirname(os.path.abspath(__file__))
    
        command = [""]
        if name == "build":
            command = [os.path.join(script_dir, "build.sh"), args.folder]
        elif name == "test":
            command = [os.path.join(script_dir, "test.sh"), args.folder]
        else:
            command = [os.path.join(script_dir, "instrumentedTest.sh"), args.folder]
    
        result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False)
        stdout_lines = result.stdout.decode("utf-8").splitlines()
        stderr_lines = result.stderr.decode("utf-8").splitlines()
        all_lines = stdout_lines + stderr_lines
        
        
        error_lines = [line for line in all_lines if "failure: " in line.lower() or "e: " in line.lower() or " failed" in line.lower()]
        error_message = "\n".join(error_lines)
        if not error_message:
            error_message = "Successful"
        return [
            TextContent(type="text", text=f"{error_message}")
            ]
  • Registration of the 'instrumentedTest' tool in the list_tools() function, specifying name, description, and input schema.
    Tool(
        name="instrumentedTest",
        description="Run instrumented test for the Android project in the folder",
        inputSchema=Folder.model_json_schema(),
    )
  • Pydantic BaseModel defining the input parameters for the 'instrumentedTest' tool (and others), consisting of a single 'folder' field.
    class Folder(BaseModel):
        """Parameters"""
        folder: Annotated[str, Field(description="The full path of the current folder that the Android project sits")]

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

B3.3/5.0
Behavior2/5

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

No annotations are provided, so the description must disclose behavior. It only says 'run instrumented test', but does not explain side effects (e.g., starting an emulator), whether it requires a device, or if it modifies the project. The description is too brief to inform the agent about potential impacts.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence, which is concise and front-loaded with the action. However, it could be slightly more informative without becoming verbose, so it earns a 4 rather than a 5.

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?

The tool is simple with one parameter and no output schema, but the description fails to mention what happens after the test runs (e.g., results, logs, on failure behavior). For a test tool, this information is important, making the description incomplete.

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?

There is only one parameter 'folder', and its schema description already covers 'The full path of the current folder that the Android project sits'. The tool description adds no additional meaning beyond the schema, so the baseline score of 3 applies.

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

Purpose5/5

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

The description clearly states the verb 'Run', the resource 'instrumented test', and the context 'for the Android project in the folder'. It distinguishes from sibling tools 'build' and 'test' by specifying 'instrumented test', implying a difference from unit tests or build actions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when instrumented tests need to be run, but it does not provide explicit guidance on when to use this tool versus 'test' or 'build'. No when-not-to-use or alternative recommendations are given.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools