get_profile
Retrieve detailed profile information for a specific Weibo user using their unique identifier (uid). Access essential data for analysis or integration purposes.
Instructions
获取指定微博用户的详细资料信息
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| uid | Yes | 微博用户的唯一标识符 |
Implementation Reference
- src/server.ts:35-46 (registration)Registration of the MCP 'get_profile' tool, including description, Zod input schema for 'uid', and async handler that delegates to WeiboCrawler.extractWeiboProfile(uid) and formats response as text content with JSON.server.tool("get_profile", "获取指定微博用户的详细资料信息", { uid: z.number().describe("微博用户的唯一标识符") }, async ({ uid }) => { const profile = await crawler.extractWeiboProfile(uid); return { content: [{ type: "text", text: JSON.stringify(profile) }] }; } );
- src/server.ts:37-39 (schema)Input schema definition for the 'get_profile' tool using Zod, requiring a numeric 'uid' parameter.{ uid: z.number().describe("微博用户的唯一标识符") },
- src/server.ts:40-45 (handler)Handler function for 'get_profile' tool that fetches profile via crawler and returns JSON string in MCP content format.async ({ uid }) => { const profile = await crawler.extractWeiboProfile(uid); return { content: [{ type: "text", text: JSON.stringify(profile) }] }; }
- src/weibo.ts:16-26 (helper)Core helper method in WeiboCrawler class that implements the profile fetching logic using axios GET to PROFILE_URL with UID, extracts userInfo from response, handles errors by returning empty object.async extractWeiboProfile(uid: number): Promise<Record<string, any>> { try { const response = await axios.get(PROFILE_URL.replace('{userId}', uid.toString()), { headers: DEFAULT_HEADERS }); return response.data.data.userInfo; } catch (error) { console.error(`无法获取UID为'${uid}'的用户资料`, error); return {}; } }