get_points
Check remaining points for converting images to Ghibli-style animated videos using the MCP server.
Instructions
Get remaining points
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| api_key | Yes | API key for authentication |
Implementation Reference
- src/index.ts:157-176 (handler)The MCP tool handler for 'get_points', which extracts the api_key from arguments, calls ghibliClient.getPoints, and returns the remaining points as text content.case "get_points": { const apiKey = String(request.params.arguments?.api_key); if (!apiKey) { throw new Error("API key cannot be empty"); } try { const points = await ghibliClient.getPoints(apiKey); return { content: [{ type: "text", text: `Remaining points: ${points}` }] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : 'Unknown error'; throw new Error(`Get points failed: ${errorMessage}`); } }
- src/index.ts:80-93 (registration)Registration of the 'get_points' tool in the ListTools response, including its name, description, and input schema requiring api_key.{ name: "get_points", description: "Get remaining points", inputSchema: { type: "object", properties: { api_key: { type: "string", description: "API key for authentication" } }, required: ["api_key"] } },
- src/ghibli.ts:123-147 (helper)Helper method in GhibliClient that implements the core logic for fetching remaining points (credits) via API GET /api/user/credits.async getPoints(apiKey: string): Promise<number> { // 打印请求信息 process.stderr.write(`\n[Request] GET ${this.baseUrl}/api/user/credits\n`); process.stderr.write(`[Headers] ${JSON.stringify(this.getHeaders(apiKey), null, 2)}\n`); const response = await fetch(`${this.baseUrl}/api/user/credits`, { method: 'GET', headers: this.getHeaders(apiKey) }); // 打印响应状态 process.stderr.write(`[Response] Status: ${response.status} ${response.statusText}\n`); if (!response.ok) { const error = `API request failed: ${response.statusText}`; process.stderr.write(`[Error] ${error}\n`); throw new Error(error); } const result = await response.json(); // 打印响应数据 process.stderr.write(`[Response Data] ${JSON.stringify(result, null, 2)}\n`); return result.data?.left_credits || 0; }