Skip to main content
Glama

bridge_erc8004_trust_check

Verify trust status of ERC-8004 agents by checking AgentStamp verdicts with trust scores for secure AI agent interactions.

Instructions

Get an AgentStamp trust verdict for an ERC-8004 agent. Free. Returns trusted/untrusted with score.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
erc8004_agent_idYesERC-8004 agent ID (numeric token ID)

Implementation Reference

  • Implementation of the bridge_erc8004_trust_check MCP tool handler in src/mcp-server.js. It resolves the wallet from an ERC-8004 agent ID, checks local database and on-chain registries, calculates reputation, checks stamp status, and returns a trust verdict.
    server.tool(
      'bridge_erc8004_trust_check',
      'Get an AgentStamp trust verdict for an ERC-8004 agent. Free. Returns trusted/untrusted with score.',
      {
        erc8004_agent_id: z.string().regex(/^\d+$/, 'Must be a numeric token ID').describe('ERC-8004 agent ID (numeric token ID)'),
      },
      async ({ erc8004_agent_id }) => {
        try {
          const { getFullAgent } = require('./erc8004');
          const { getDb, resolvePrimaryWallet, getAllLinkedWallets } = require('./database');
          const { computeDelegationBonus } = require('./reputation');
          const db = getDb();
    
          // Check local link first
          const link = db.prepare('SELECT agentstamp_wallet FROM erc8004_links WHERE erc8004_agent_id = ?').get(erc8004_agent_id);
          let wallet;
    
          if (link) {
            wallet = link.agentstamp_wallet;
          } else {
            // Resolve from on-chain
            const onChain = await getFullAgent(erc8004_agent_id);
            if (!onChain.found) {
              return { content: [{ type: 'text', text: JSON.stringify({ trusted: false, score: 0, error: 'Agent not found in ERC-8004 registry' }, null, 2) }] };
            }
            wallet = onChain.agentWallet || onChain.owner;
          }
    
          const resolvedWallet = resolvePrimaryWallet(wallet);
          const walletInfo = getAllLinkedWallets(resolvedWallet);
          const allWallets = walletInfo.all;
          if (allWallets.length === 0) {
            return { content: [{ type: 'text', text: JSON.stringify({ trusted: false, score: 0, label: 'unknown' }, null, 2) }] };
          }
    
          const ph = allWallets.map(() => '?').join(',');
          const agent = db.prepare(
            `SELECT id, name, category, endorsement_count, status, wallet_verified FROM agents WHERE wallet_address IN (${ph}) AND status = 'active' ORDER BY registered_at ASC LIMIT 1`
          ).get(...allWallets);
    
          const stamp = db.prepare(
            `SELECT id, tier, expires_at FROM stamps WHERE wallet_address IN (${ph}) AND revoked = 0 AND expires_at > datetime('now') ORDER BY CASE tier WHEN 'gold' THEN 1 WHEN 'silver' THEN 2 WHEN 'bronze' THEN 3 WHEN 'free' THEN 4 ELSE 5 END LIMIT 1`
          ).get(...allWallets);
    
          let reputation = { score: 0, tier_label: 'new' };
          if (agent) {
            const rep = computeReputation(agent.id);
            if (rep) reputation = rep;
          }
    
          const delegationBonus = computeDelegationBonus(resolvedWallet, db);
          const trusted = reputation.score >= 10 || !!stamp || delegationBonus.bonus > 0;
    
          const result = {
            trusted,
            score: reputation.score,
            label: reputation.tier_label,
            tier: stamp?.tier || 'none',
            erc8004_agent_id,
            agent: agent ? { id: agent.id, name: agent.name, category: agent.category, endorsements: agent.endorsement_count } : null,
            stamp: stamp ? { id: stamp.id, tier: stamp.tier, expires_at: stamp.expires_at } : null,
          };
    
          return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
        } catch (err) {
          return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'ERC-8004 trust check failed' }, null, 2) }] };

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/vinaybhosle/agentstamp'

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