Skip to main content
Glama
IQAIcom
by IQAIcom

GET_USER_CREATED_WIKIS

Retrieve wikis created by a specific user on IQ.wiki using their Ethereum address, with an optional time frame filter.

Instructions

Get wikis created by a specific user on IQ.wiki

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe Ethereum address of the user
timeFrameSecondsNoOptional time frame in seconds to filter results

Implementation Reference

  • The execute function that implements the tool's main logic by instantiating and calling the GetUserCreatedWikisService.
    execute: async (params: GetUserCreatedWikisParams) => {
    	try {
    		const service = new GetUserCreatedWikisService();
    		const wikis = await service.execute(params.id, params.timeFrameSeconds);
    
    		return service.format(wikis);
    	} catch (error) {
    		if (error instanceof Error) {
    			console.log(`Error in GET_USER_CREATED_WIKIS tool: ${error.message}`);
    			return `Error retrieving user created wikis: ${error.message}`;
    		}
    		return "An unknown error occurred while fetching user created wikis";
    	}
    },
  • Zod schema defining the input parameters: user ID (Ethereum address) and optional time frame.
    const getUserCreatedWikisParams = z.object({
    	id: z.string().min(1).describe("The Ethereum address of the user"),
    	timeFrameSeconds: z
    		.number()
    		.optional()
    		.describe("Optional time frame in seconds to filter results"),
    });
  • src/index.ts:18-18 (registration)
    The tool is registered with the FastMCP server instance.
    server.addTool(getUserCreatedWikisTool);
  • The GetUserCreatedWikisService class containing the execute method for GraphQL query and data processing, and format method for output formatting.
    export class GetUserCreatedWikisService {
    	async execute(id: string, timeFrameSeconds?: number) {
    		try {
    			const response: any = await client.request(USER_CREATED_WIKIS_QUERY, {
    				id,
    			});
    
    			if (!response.userById) {
    				throw new Error("user does not exist");
    			}
    			if (!response.userById.wikisCreated.activity) {
    				throw new Error("user has not created any wikis");
    			}
    
    			let wikis = response.userById.wikisCreated.activity[0].content;
    
    			// Filter by time if timeFrameSeconds is provided
    			if (timeFrameSeconds) {
    				const now = new Date();
    				const timeLimit = new Date(now.getTime() - timeFrameSeconds * 1000);
    
    				// Filter wikis by creation time
    				wikis = wikis.filter((wiki: any) => {
    					if (!wiki.created) return false;
    					const wikiDate = new Date(wiki.created);
    					return wikiDate >= timeLimit;
    				});
    
    				if (wikis.length === 0) {
    					// Convert seconds to a human-readable format for the error message
    					const timeFrameText =
    						timeFrameSeconds >= 86400
    							? `${timeFrameSeconds / 86400} day(s)`
    							: timeFrameSeconds >= 3600
    								? `${timeFrameSeconds / 3600} hour(s)`
    								: `${timeFrameSeconds / 60} minute(s)`;
    
    					throw new Error(
    						`No created wikis found in the last ${timeFrameText}`,
    					);
    				}
    			}
    
    			return wikis;
    		} catch (error: any) {
    			throw new Error(error.message);
    		}
    	}
    
    	format(wikis: any) {
    		return wikis
    			.map((wiki: any) => {
    				const date = new Date(wiki.created);
    				const formattedDate = date.toLocaleString();
    
    				return dedent`
    						๐Ÿ“œ Wiki Created
    						- Title: ${wiki.title}
    						- Summary: ${wiki.summary}
    						- Created: ${formattedDate}
    
    						๐Ÿ”— Source: ${IQ_BASE_URL}/${wiki.id}
    						๐Ÿ”— Transaction: https://polygonscan.com/tx/${wiki.transactionHash}
    					`;
    			})
    			.join("\n\n");
    	}
    }
Install Server

Other Tools

Related 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/IQAIcom/mcp-iqwiki'

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