getSpaces
Retrieve a list of Snapshot spaces to view governance platforms, with options to limit results or skip entries for efficient browsing.
Instructions
Get list of Snapshot spaces
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Number of spaces to fetch | |
| skip | No | Number of spaces to skip |
Implementation Reference
- src/services/snapshotService.ts:195-221 (handler)Core handler function that performs the GraphQL query to fetch paginated list of Snapshot spaces.async getSpaces(first: number = 20, skip: number = 0): Promise<Space[]> { const query = ` query Spaces { spaces( first: ${first}, skip: ${skip}, orderBy: "created", orderDirection: asc ) { id name about network symbol strategies { name params } admins members } } `; const result = await this.queryGraphQL(query); return result.spaces; }
- src/server.ts:17-20 (schema)Zod schema for validating input parameters (limit, skip) for the getSpaces tool.const SpacesParamsSchema = z.object({ limit: z.number().optional(), skip: z.number().optional() });
- src/server.ts:69-79 (registration)Tool registration in the listTools handler, defining name, description, and inputSchema.{ name: "getSpaces", description: "Get list of Snapshot spaces", inputSchema: { // Changed from parameters to inputSchema type: "object", properties: { limit: { type: "number", description: "Number of spaces to fetch" }, skip: { type: "number", description: "Number of spaces to skip" } } } },
- src/server.ts:145-157 (handler)MCP tool call dispatch handler that validates args, calls the service, and formats response.case "getSpaces": { const parsedArgs = SpacesParamsSchema.parse(args); const spaces = await this.snapshotService.getSpaces( parsedArgs.limit || 20, parsedArgs.skip || 0 ); return { content: [{ type: "text", text: JSON.stringify(spaces, null, 2) }] }; }
- TypeScript interface defining the structure of a Space object returned by getSpaces.interface Space { id: string; name: string; about?: string; network?: string; symbol?: string; strategies?: any[]; admins?: string[]; members?: string[]; }