Skip to main content
Glama

test_aptos_contract

Evaluate Aptos Move contracts by specifying the contract path, optionally testing a specific function and its arguments. This tool integrates with the Aptos CLI for effective contract validation.

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

NameRequiredDescriptionDefault
argsNo
contract_pathYes
function_nameNo

Input Schema (JSON Schema)

{ "properties": { "args": { "default": null, "items": {}, "title": "Args", "type": "array" }, "contract_path": { "title": "Contract Path", "type": "string" }, "function_name": { "default": "", "title": "Function Name", "type": "string" } }, "required": [ "contract_path" ], "title": "test_aptos_contractArguments", "type": "object" }

Implementation Reference

  • The main handler function for the 'test_aptos_contract' tool. It is decorated with @mcp.tool(), serving as both the implementation and registration. The function tests an Aptos Move contract using the Aptos CLI by running 'aptos move test', handling paths, optional function filtering, and returning test results or errors.
    @mcp.tool() 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)}"

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

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