Skip to main content
Glama

test_aptos_contract

Test Aptos Move smart contracts using the Aptos CLI to verify functionality before deployment. Specify contract path, function, and arguments for targeted testing.

Instructions

Test an Aptos Move contract using the Aptos CLI.

Args:
    contract_path: Path to the contract directory or file
    function_name: Optional function to test specifically
    args: Optional list of arguments for the function

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contract_pathYes
function_nameNo
argsNo

Implementation Reference

  • The main handler function for the 'test_aptos_contract' MCP tool. It is decorated with @mcp.tool() which registers it as a tool in the FastMCP server. The function tests an Aptos Move contract by running the Aptos CLI 'aptos move test' command on the specified contract path, with optional function filtering.
    async def test_aptos_contract(contract_path: str, function_name: str = "", args: list = None) -> str:
        """
        Test an Aptos Move contract using the Aptos CLI.
        
        Args:
            contract_path: Path to the contract directory or file
            function_name: Optional function to test specifically
            args: Optional list of arguments for the function
        """
        contract_path = os.path.expanduser(contract_path)  # Expand ~ in paths
        
        if not os.path.exists(contract_path):
            return f"Contract path not found: {contract_path}"
        
        try:
            cmd = ["aptos", "move", "test"]
            
            if os.path.isfile(contract_path):
                cmd.extend(["--path", os.path.dirname(contract_path)])
                if function_name:
                    cmd.extend(["--filter", function_name])
            else:
                cmd.extend(["--path", contract_path])
                if function_name:
                    cmd.extend(["--filter", function_name])
            
            result = subprocess.run(cmd, capture_output=True, text=True)
            
            if result.returncode == 0:
                return f"Tests passed successfully:\n\n{result.stdout}"
            else:
                return f"Tests failed:\n\n{result.stderr}"
        
        except Exception as e:
            return f"Error testing contract: {str(e)}"
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions using 'Aptos CLI' which provides some context about execution method, but doesn't describe what 'test' means operationally (e.g., runs unit tests, validates bytecode, requires compilation), expected outputs, error conditions, or resource requirements.

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 appropriately sized with a clear purpose statement followed by parameter explanations. The structure is front-loaded with the main purpose first. It could be slightly more concise by integrating the Args section more naturally, but overall it's efficient.

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?

For a 3-parameter tool with no annotations and no output schema, the description is insufficient. It doesn't explain what 'testing' entails, what results to expect, error handling, or how this integrates with the Aptos development workflow. The minimal parameter explanations don't compensate for the lack of behavioral context.

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 description provides brief explanations for all three parameters in the Args section, adding meaning beyond the schema which has 0% description coverage. However, these explanations are minimal ('Path to the contract directory or file', 'Optional function to test specifically') and lack details about format, constraints, or examples.

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 ('Test an Aptos Move contract') and resource ('Aptos Move contract'), making the purpose immediately understandable. However, it doesn't differentiate this tool from sibling tools like 'aptos_abi_generate' or 'create_aptos_project', which prevents a perfect 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, when testing is appropriate, or how this differs from sibling tools like 'create_aptos_project' or 'generate_aptos_component'.

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

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/Tlazypanda/aptos-mcp-server'

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