UNPKG

@chinchillaenterprises/mcp-upwork

Version:

Modular Upwork MCP server for job search and proposal management via Upwork API

51 lines (45 loc) 1.58 kB
import { Tool } from "@modelcontextprotocol/sdk/types.js"; import { ReleaseMilestoneArgsSchema } from "../../schemas/upwork.js"; import { UpworkClient } from "../../services/upwork-client.js"; export const releaseMilestoneToolDefinition: Tool = { name: "upwork_release_milestone", description: "Release a milestone payment (for clients)", inputSchema: { type: "object", properties: { milestone_id: { type: "string", description: "Milestone ID" }, rating: { type: "number", minimum: 1, maximum: 5, description: "Rating (1-5 stars)" }, feedback: { type: "string", description: "Feedback text" } }, required: ["milestone_id", "rating"] } }; export async function releaseMilestoneHandler(args: unknown, upworkClient: UpworkClient) { const validatedArgs = ReleaseMilestoneArgsSchema.parse(args); try { const releaseData = { rating: validatedArgs.rating, feedback: validatedArgs.feedback }; const response = await upworkClient.getClient().put(`/hr/v2/milestones/${validatedArgs.milestone_id}/release`, releaseData); return { content: [ { type: "text", text: JSON.stringify({ success: true, milestone: response.data, message: "Milestone released successfully" }, null, 2) } ] }; } catch (error) { throw upworkClient.handleError(error); } } export const releaseMilestoneTool = { definition: releaseMilestoneToolDefinition, handler: releaseMilestoneHandler, schema: ReleaseMilestoneArgsSchema };