Skip to main content
Glama

getGovernanceProposals

Retrieve governance proposals for DeFi protocols on Snapshot, including status filters and voting results, to analyze protocol decisions and community sentiment.

Instructions

Snapshot 기반 DeFi 프로토콜 거버넌스 프로포절을 조회합니다 (상태 필터, 투표 결과 포함)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
protocolYes프로토콜 이름 또는 Snapshot space ID (e.g., 'uniswap', 'aave.eth')
stateNo프로포절 상태 필터active
limitNo조회할 프로포절 수

Implementation Reference

  • Handler function for getGovernanceProposals tool. Executes Snapshot GraphQL query, manages cache, and formats response.
    async function handler(
      args: z.infer<typeof inputSchema>
    ): Promise<GovernanceResult | ToolError> {
      const { protocol, state, limit } = args;
    
      // Snapshot space ID 결정
      const spaceId = resolveSpaceId(protocol);
    
      // 캐시 키 생성
      const cacheKey = `governance:${spaceId}:${state}:${limit}`;
      const cached = cache.get<GovernanceData>(cacheKey);
      if (cached.hit) {
        return {
          success: true,
          data: cached.data,
          cached: true,
          timestamp: Date.now(),
        };
      }
    
      try {
        const query = buildGraphQLQuery(state);
    
        // GraphQL 변수 구성 - state가 "all"이면 state 변수 생략
        const variables: Record<string, unknown> = {
          space: spaceId,
          first: limit,
        };
        if (state !== "all") {
          variables.state = state;
        }
    
        const response = await fetch(SNAPSHOT_GRAPHQL_URL, {
          method: "POST",
          headers: {
            "Content-Type": "application/json",
            "Accept": "application/json",
          },
          body: JSON.stringify({ query, variables }),
        });
    
        if (!response.ok) {
          return makeError(
            `Snapshot API 요청 실패: HTTP ${response.status}`,
            "API_ERROR"
          );
        }
    
        const json = await response.json() as {
          data?: {
            proposals?: Array<{
              id: string;
              title: string;
              body: string;
              state: string;
              author: string;
              created: number;
              start: number;
              end: number;
              choices: string[];
              scores: number[];
              scores_total: number;
              quorum: number;
              votes: number;
              space: { id: string; name: string };
            }>;
          };
          errors?: Array<{ message: string }>;
        };
    
        // GraphQL 오류 처리
        if (json.errors && json.errors.length > 0) {
          return makeError(
            `Snapshot GraphQL 오류: ${json.errors[0].message}`,
            "API_ERROR"
          );
        }
    
        const rawProposals = json.data?.proposals ?? [];
    
        // 응답 데이터를 반환 형식으로 변환
        const proposals: GovernanceProposal[] = rawProposals.map((p) => ({
          id: p.id,
          title: p.title,
          // body는 500자로 잘라서 반환 (토큰 절약)
          body: p.body.length > 500 ? p.body.slice(0, 500) + "..." : p.body,
          state: p.state,
          author: p.author,
          choices: p.choices,
          scores: p.scores,
          scorestotal: p.scores_total,
          quorum: p.quorum,
          votes: p.votes,
          startDate: new Date(p.start * 1000).toISOString(),
          endDate: new Date(p.end * 1000).toISOString(),
        }));
    
        const governanceData: GovernanceData = {
          space: spaceId,
          proposalCount: proposals.length,
          proposals,
        };
    
        // 캐시에 저장
        cache.set(cacheKey, governanceData, CACHE_TTL_SECONDS);
    
        return {
          success: true,
          data: governanceData,
          cached: false,
          timestamp: Date.now(),
        };
      } catch (err) {
        const message = sanitizeError(err);
        return makeError(`거버넌스 프로포절 조회 실패: ${message}`, "API_ERROR");
      }
    }
  • Zod schema for validating tool input parameters.
    const inputSchema = z.object({
      protocol: z.string().describe("프로토콜 이름 또는 Snapshot space ID (e.g., 'uniswap', 'aave.eth')"),
      state: z.enum(["active", "closed", "all"]).default("active").describe("프로포절 상태 필터"),
      limit: z.number().min(1).max(100).default(10).describe("조회할 프로포절 수"),
    });
  • Tool registration function for getGovernanceProposals.
    export function register(server: McpServer) {
      server.tool(
        "getGovernanceProposals",
        "Snapshot 기반 DeFi 프로토콜 거버넌스 프로포절을 조회합니다 (상태 필터, 투표 결과 포함)",
        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) }] };
        },
      );
    }
Behavior3/5

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

Discloses data source (Snapshot-based) and return payload richness (includes voting results). However, lacks critical behavioral details expected with no annotations: error handling for invalid spaces, rate limits, data freshness, or pagination behavior beyond the limit parameter.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single efficient Korean sentence with action front-loaded and supplemental details in parentheses. No redundancy; every clause earns its place by conveying scope, filtering capability, or return data.

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

Completeness4/5

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

Appropriate for a read-only retrieval tool with 100% schema coverage. Compensates for missing output schema by disclosing that voting results are included. Could strengthen by noting Snapshot API dependency or error conditions, but adequate for invocation decisions.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema coverage, baseline is 3. Adds value by contextualizing 'protocol' as Snapshot space IDs (e.g., 'aave.eth') via 'Snapshot 기반' phrase, and clarifies state parameter outcomes ('상태 필터') and return data ('투표 결과 포함').

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Specific verb (조회/retrieve) + specific resource (Snapshot-based DeFi governance proposals) clearly distinguishes from sibling token/transaction tools like getTokenInfo or getBalance. Identifies the external platform (Snapshot) and data type.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Implies usage context (when querying governance proposals) but lacks explicit prerequisites (e.g., valid Snapshot space ID format), when-not-to-use guidance, or alternatives. No siblings overlap with governance domain, so differentiation is implicit rather than stated.

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