import { Tool } from "@modelcontextprotocol/sdk/types.js"; import { GetProfileArgsSchema } from "../../schemas/upwork.js"; import { UpworkClient } from "../../services/upwork-client.js"; export const getProfileToolDefinition: Tool = { name: "upwork_get_profile", description: "Get your Upwork profile information", inputSchema: { type: "object", properties: {} } }; export async function getProfileHandler(args: unknown, upworkClient: UpworkClient) { const validatedArgs = GetProfileArgsSchema.parse(args); try { const response = await upworkClient.getClient().get('/profiles/v1/contractors/me'); return { content: [ { type: "text", text: JSON.stringify({ success: true, profile: response.data.contractor || response.data.profile || response.data }, null, 2) } ] }; } catch (error) { throw upworkClient.handleError(error); } } export const getProfileTool = { definition: getProfileToolDefinition, handler: getProfileHandler, schema: GetProfileArgsSchema };