Skip to main content
Glama

getApprovalStatus

Check ERC-20 token approval status for wallet addresses to identify spending risks across multiple EVM chains.

Instructions

ERC-20 토큰 승인(allowance) 상태를 조회합니다. 주요 프로토콜 자동 체크, 리스크 레벨 판정

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ownerYes지갑 주소
tokenYes토큰 심볼 (USDC, USDT) 또는 contract address
spenderNo특정 spender 주소 (미지정 시 주요 프로토콜 자동 조회)
chainNoEVM 체인ethereum

Implementation Reference

  • The core handler logic that fetches allowance data from the blockchain for a given owner, token, and spender(s), calculates risk, and caches the result.
    async function handler(args: z.infer<typeof inputSchema>): Promise<ToolResult<ApprovalStatusData>> {
      const { owner, token, spender, chain } = args;
    
      // 토큰 주소 확인
      let tokenAddress = token;
      if (!isValidAddress(token)) {
        const meta = resolveTokenMeta(token, chain);
        if (!meta) return makeError(`Token '${token}' not found on ${chain}`, "TOKEN_NOT_FOUND");
        const addresses = meta.addresses;
        const addr = addresses[chain];
        if (!addr) return makeError(`Token '${token}' not available on ${chain}`, "TOKEN_NOT_FOUND");
        tokenAddress = addr;
      }
    
      const cacheKey = `approval:${chain}:${owner}:${tokenAddress.toLowerCase()}:${spender ?? "auto"}`;
      const cached = cache.get<ApprovalStatusData>(cacheKey);
      if (cached.hit) return makeSuccess(chain, cached.data, true);
    
      try {
        const client = getClient(chain);
        const spendersToCheck = spender
          ? [{ name: "custom", address: spender }]
          : getProtocolSpenders(chain);
    
        if (spendersToCheck.length === 0) {
          return makeError(`No known protocol spenders for ${chain}`, "INVALID_INPUT");
        }
    
        const results = await Promise.allSettled(
          spendersToCheck.map(async (s) => {
            const allowance = await client.readContract({
              address: tokenAddress as `0x${string}`,
              abi: ERC20_ALLOWANCE_ABI,
              functionName: "allowance",
              args: [owner as `0x${string}`, s.address as `0x${string}`],
            });
            return { ...s, allowance: allowance as bigint };
          }),
        );
    
        const approvals: ApprovalEntry[] = [];
        for (const result of results) {
          if (result.status === "fulfilled") {
            const { name, address, allowance: raw } = result.value;
            if (raw > 0n) {
              approvals.push({
                protocol: name,
                spender: address,
                allowance: raw >= UNLIMITED_THRESHOLD ? "unlimited" : raw.toString(),
                isUnlimited: raw >= UNLIMITED_THRESHOLD,
              });
            }
          }
        }
    
        // 리스크 레벨 결정
        const unlimitedCount = approvals.filter((a) => a.isUnlimited).length;
        let riskLevel: "safe" | "moderate" | "high" = "safe";
        if (unlimitedCount >= 3) riskLevel = "high";
        else if (unlimitedCount >= 1 || approvals.length >= 3) riskLevel = "moderate";
    
        const tokenMeta = resolveTokenMeta(token);
        const data: ApprovalStatusData = {
          owner,
          token: tokenMeta?.symbol ?? token,
          tokenAddress,
          approvals,
          riskLevel,
        };
    
        cache.set(cacheKey, data, CACHE_TTL);
        return makeSuccess(chain, data, false);
      } catch (err) {
        const message = sanitizeError(err);
        return makeError(`Failed to check approvals: ${message}`, "RPC_ERROR");
      }
    }
  • Input validation schema for the getApprovalStatus tool using zod.
    const inputSchema = z.object({
      owner: z.string().describe("지갑 주소"),
      token: z.string().describe("토큰 심볼 (USDC, USDT) 또는 contract address"),
      spender: z.string().optional().describe("특정 spender 주소 (미지정 시 주요 프로토콜 자동 조회)"),
      chain: z.enum(SUPPORTED_CHAINS).default("ethereum").describe("EVM 체인"),
    });
  • Registration of the getApprovalStatus tool with the McpServer.
    export function register(server: McpServer) {
      server.tool(
        "getApprovalStatus",
        "ERC-20 토큰 승인(allowance) 상태를 조회합니다. 주요 프로토콜 자동 체크, 리스크 레벨 판정",
        inputSchema.shape,
        async (args) => {
          const result = await handler(args as z.infer<typeof inputSchema>);
          return { content: [{ type: "text" as const, text: JSON.stringify(result, null, 2) }] };
        },
      );
    }
Behavior4/5

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

With no annotations provided, the description carries the full disclosure burden and succeeds in communicating key behavioral traits: it notes the '주요 프로토콜 자동 체크' (auto-check major protocols) functionality and '리스크 레벨 판정' (risk level determination), indicating this performs analysis beyond raw data retrieval. However, it omits explicit read-only safety disclosure.

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?

Extremely compact with two efficient phrases delivering the core purpose and key features without redundancy. The telegraphic style ('주요 프로토콜 자동 체크, 리스크 레벨 판정') sacrifices grammatical completeness for brevity but remains interpretable, though a full sentence structure would improve clarity slightly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the good schema coverage (100%) but absence of annotations and output schema, the description adequately covers the tool's purpose and special features (risk assessment). However, it lacks disclosure of return value structure (allowance amounts, risk ratings) which would be expected for a complete specification without output schema documentation.

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?

With 100% schema description coverage, the structured schema already fully documents all 4 parameters (owner, token, spender, chain). The description doesn't add syntax, format constraints, or examples beyond the schema declarations, warranting the baseline score of 3.

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 specific action (조회합니다/query) and resource (ERC-20 토큰 승인/allowance 상태), distinguishing it from siblings like getBalance or getTokenInfo which handle different token aspects. It effectively identifies the tool's domain as ERC-20 allowance checking.

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 explicit guidance on when to use this tool versus alternatives (e.g., when to check approvals vs token balances), nor does it mention prerequisites like requiring an owner address. The risk assessment feature is mentioned but not contextualized with usage scenarios.

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/calintzy/evmscope'

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