get_profile
Retrieve detailed profile information for a specific Weibo user by providing their unique identifier.
Instructions
获取指定微博用户的详细资料信息
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| uid | Yes | 微博用户的唯一标识符 |
Implementation Reference
- src/server.ts:35-46 (registration)Registration of the 'get_profile' MCP tool, including input schema (uid: number), description, and inline handler function that delegates to WeiboCrawler.extractWeiboProfile(uid) and returns JSON-formatted profile.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/weibo.ts:16-26 (handler)Core implementation of profile extraction: performs HTTP GET request to the Weibo profile API URL with default headers, 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 {}; } }
- src/consts.ts:10-10 (helper)API endpoint URL template used for fetching user profiles, with {userId} placeholder.export const PROFILE_URL = 'https://m.weibo.cn/api/container/getIndex?type=uid&value={userId}';
- src/consts.ts:4-4 (helper)Default HTTP headers used in profile extraction requests.export const DEFAULT_HEADERS = { 'Content-Type': 'application/json' };