Skip to main content
Glama

getProposals

Retrieve governance proposals from a Snapshot space to analyze voting activity, filter by state, and track decision-making processes.

Instructions

Get proposals for a Snapshot space

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
spaceIdYesID of the space
stateNoFilter by proposal state (active, closed, pending, all)
limitNoNumber of proposals to fetch

Implementation Reference

  • MCP tool handler for 'getProposals': parses arguments using ProposalsParamsSchema, calls snapshotService.getProposals with spaceId, state, and limit, and returns the proposals as JSON text content.
    case "getProposals": {
      const parsedArgs = ProposalsParamsSchema.parse(args);
      const proposals = await this.snapshotService.getProposals(
        parsedArgs.spaceId,
        parsedArgs.state || "all",
        parsedArgs.limit || 20
      );
      return {
        content: [{
          type: "text",
          text: JSON.stringify(proposals, null, 2)
        }]
      };
    }
  • Zod schema (ProposalsParamsSchema) for input validation of getProposals tool: requires spaceId, optional state and limit.
    const ProposalsParamsSchema = z.object({
      spaceId: z.string(),
      state: z.string().optional(),
      limit: z.number().optional()
    });
  • src/server.ts:80-92 (registration)
    Tool registration in listTools handler: defines 'getProposals' with description and inputSchema matching the Zod schema.
    {
      name: "getProposals",
      description: "Get proposals for a Snapshot space",
      inputSchema: {  // Changed from parameters to inputSchema
        type: "object",
        properties: {
          spaceId: { type: "string", description: "ID of the space" },
          state: { type: "string", description: "Filter by proposal state (active, closed, pending, all)" },
          limit: { type: "number", description: "Number of proposals to fetch" }
        },
        required: ["spaceId"]
      }
    },
  • Core implementation of getProposals in SnapshotService: constructs and executes GraphQL query to fetch proposals for a space, filtered by state if specified, returns Proposal[].
    async getProposals(spaceId: string, state: string = "all", first: number = 20): Promise<Proposal[]> {
      const query = `
        query Proposals {
          proposals (
            first: ${first},
            skip: 0,
            where: {
              space_in: ["${spaceId}"]
              ${state !== "all" ? `, state: "${state}"` : ''}
            },
            orderBy: "created",
            orderDirection: desc
          ) {
            id
            title
            body
            choices
            start
            end
            snapshot
            state
            author
            space {
              id
              name
            }
          }
        }
      `;
    
      const result = await this.queryGraphQL(query);
      return result.proposals;
    }
  • TypeScript interface Proposal defining the structure of proposal objects returned by getProposals.
    interface Proposal {
      id: string;
      title: string;
      body?: string;
      choices: string[];
      start: number;
      end: number;
      snapshot: string;
      state: string;
      author: string;
      space: {
        id: string;
        name: string;
      };
    }

Tool Definition Quality

Score is being calculated. Check back soon.

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/crazyrabbitLTC/mcp-snapshot-server'

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