Get User Info
get_user_infoRetrieve current user details from Emlog blog systems using the MCP Server interface. Simplify user information access for streamlined content management and operations.
Instructions
Get current user information
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:551-570 (handler)The handler function for the get_user_info tool. It fetches the current user's information using the EmlogClient and formats it into a text response for MCP.
async () => { try { const result = await emlogClient.getCurrentUser(); const user = result.userinfo; return { content: [{ type: "text", text: `User: ${user.nickname}\nEmail: ${user.email}\nUID: ${user.uid}\nDescription: ${user.description || 'N/A'}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } - src/index.ts:544-571 (registration)Registration of the get_user_info tool with the MCP server, including title, description, empty input schema, and inline handler.
server.registerTool( "get_user_info", { title: "Get User Info", description: "Get current user information", inputSchema: {} }, async () => { try { const result = await emlogClient.getCurrentUser(); const user = result.userinfo; return { content: [{ type: "text", text: `User: ${user.nickname}\nEmail: ${user.email}\nUID: ${user.uid}\nDescription: ${user.description || 'N/A'}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } ); - src/index.ts:546-550 (schema)Tool schema definition with no input parameters required.
{ title: "Get User Info", description: "Get current user information", inputSchema: {} }, - src/emlog-client.ts:417-421 (helper)Supporting method in EmlogClient that makes the API request to retrieve the current user's information.
async getCurrentUser(): Promise<{ userinfo: EmlogUser }> { const queryParams = this.buildParams(); const response = await this.api.get(`/?rest-api=userinfo&${queryParams.toString()}`); return response.data.data; } - src/emlog-client.ts:80-89 (schema)TypeScript interface defining the structure of user information returned by the API.
export interface EmlogUser { uid: number; nickname: string; role: string; avatar: string; email?: string; description: string; ip?: string; create_time: number; }