Skip to main content
Glama
get_contract_info.py2.06 kB
""" Retrieve smart contract details and metadata from blockchain. """ import json from typing import Union from mcp import types from pydantic import BaseModel from ...helpers import make_odos_request, resolve_chain_id from ...mcp import mcp # pylint: disable=duplicate-code class GetContractInfoArgs(BaseModel): """Arguments for getting contract info""" version: str # v3 or v2 chain_id: Union[str, int] @mcp.tool( name="get_contract_info", description=( "Get all relevant contract information" "for a given chain and router version (v2 or v3)" ), ) async def get_contract_info(args: GetContractInfoArgs) -> list[types.TextContent]: """ Gets contract information including router and executor addresses and ABIs. """ try: if args.version not in ["v2", "v3"]: raise ValueError("Version must be 'v2' or 'v3'") chain_id = resolve_chain_id(args.chain_id) # Build URL with path parameters url = f"/info/contract-info/{args.version}/{chain_id}" response_data = await make_odos_request(url, method="GET") output = { "message": f"Fetched contract info for {args.version} on chain {chain_id}.", "version": args.version, "chainId": response_data.get("chainId"), "routerAddress": response_data.get("routerAddress"), "executorAddress": response_data.get("executorAddress"), "routerAbi": response_data.get("routerAbi"), "erc20Abi": response_data.get("erc20Abi"), } return [types.TextContent(type="text", text=json.dumps(output, indent=2))] except ConnectionError as e: return [ types.TextContent( type="text", text=f"❌ API Error in get_contract_info: {str(e)}" ) ] except (ValueError, KeyError, TypeError) as e: return [ types.TextContent( type="text", text=f"❌ Unexpected Error in get_contract_info: {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/odos-xyz/odos-mcp'

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