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)}"

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